jasmine

Using ngMock to simulate $http calls in service unit tests

六眼飞鱼酱① 提交于 2019-12-03 16:44:13
I've been looking at this for hours. I've tried example after example. I just can't seem to get this to work. Please help =) I am doing all this on a clean clone of the angular-seed repo (git://github.com/angular/angular-seed.git). I have made no changes except those listed below. Problem: When I run the following, the test works. Note that in this version, the service returns a value before doing any kind of $http call. ./app/js/services/services.js 'use strict'; angular.module('myApp.services', []) .factory("exampleService", function ($http) { return {value:"goodValue"}; $http.get("

Unit Testing dependency injection

折月煮酒 提交于 2019-12-03 16:42:56
问题 I am brand new to jasmine and karma. I believe I have the environment setup properly and I am able to run very basic unit tests, but as soon as I try to instantiate a controller I am given an unknown provider error and I am unsure how to debug this. Do I need to pass in a stateProvider dependency? I don't see this in the angular-seed example. Bower.json: { "name": "starter", "description": "A starter project for AngularJS", "version": "2.0.0", "homepage": "https://starter.com", "private":

Angular 2: How to mock ChangeDetectorRef while unit testing

爱⌒轻易说出口 提交于 2019-12-03 16:29:30
问题 I have just started with Unit-Testing, and I have been able to mock my own services and some of Angular and Ionic as well, but no matter what I do ChangeDetectorRef stays the same. I mean which kind of sorcery is this? beforeEach(async(() => TestBed.configureTestingModule({ declarations: [MyComponent], providers: [ Form, DomController, ToastController, AlertController, PopoverController, {provide: Platform, useClass: PlatformMock}, { provide: NavParams, useValue: new NavParams({data: new

How to make a list of failed specs using jasmine custom reporter to post to slack?

帅比萌擦擦* 提交于 2019-12-03 16:23:27
I am trying to work on a custom jasmine reporter and get a list of all the failed specs in the specDone function: specDone: function(result) { if(result.status == 'failed') { failedExpectations.push(result.fullName); console.log(failedExpectations); } } where failedExpectations will store an entire list of the failed specs and i need to access this in the afterLaunch function in the protractor config file. But due to the fact that the config file loads everytime a new spec runs it basically gets overwritten and scoping is such that I cannot access it in the afterLaunch function, that is where

Using importsScripts within Blob in a karma environment

和自甴很熟 提交于 2019-12-03 16:19:11
问题 I am working on a small project of mine using karma, and jasmine. My targeted browser is chrome 32. I am trying to import scripts within a web worker whom I have instanciated through a blob as follows : describeAsyncAppliPersephone("When the application project to DOM", function() { it("it should call the function of DomProjection in the project associated with its event", function() { var eventSentBack = { eventType: 'testReceived', headers: { id: 14, version: 4 }, payLoad: { textChanged:

Protractor + AngularJS + Jasmine get output results on xml file

半腔热情 提交于 2019-12-03 16:10:20
I'm trying to export protractor results to xml files, i found this great link on web: https://github.com/angular/protractor/issues/60 After running : npm install jasmine-reporters i added the following lines to my protracotr config file: require('jasmine-reporters'); jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter( 'C:\temp\test', true, true)); and i get the following error: jasmine.console_reporter.js:2 if (! jasmine) { ^ ReferenceError: jasmine is not defined i attached here my config file, please advise what am i doing wrong, and how can i fix this: require('jasmine-reporters');

How to test a directive's controller using angularJS-karma-jasmine?

百般思念 提交于 2019-12-03 16:00:40
Goal: Write a passing test for the waCarousel directive scope variable: self.awesomeThings . Expect this test pass when self.awsomeThings.length.toBe(3) to is true? Question: How can I properly write this test? rather how do I inject a directives controller? Directive: angular.module('carouselApp') .directive('waCarousel', function() { return { templateUrl: '../../../views/carousel/wa.carousel.html', controller: function($scope) { var self = this; self.awesomeThings = [1, 2, 3]; return $scope.carousel = self; } } }); Unit Test: describe('waCarousel Unit', function() { // am I missing a

How to import 'describe', 'expect' and 'it' into a typescript tests for IDE to not to highlight them

微笑、不失礼 提交于 2019-12-03 15:49:17
Wrote some tests and everything successfully runs, but my IDE (webstorm) highlights describe , expect and it and says "cannot find name". I want to keep everythig clean and get rid of these, but have no idea how. We use protractor and jasmine. Some more of the script: import {HomePO} from './pageobjects/home' import {browser } from 'protractor' describe('Smoke test', function() { it('should initialize', function() { let width = 320; let height = 568; browser.driver.manage().window().setSize(width, height); }); it('should open homepage', function() { HomePO.get(); expect(HomePO.isCurrentPage())

Good IDE for node.js + coffeescript + jasmine [closed]

限于喜欢 提交于 2019-12-03 15:41:41
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . What good IDEs are there to develop with the combination of Jasmine, node.js and coffeescript. So far, we're considering WebStorm, but

karma start Cannot find module 'jasmine-core'

主宰稳场 提交于 2019-12-03 15:33:44
问题 I was getting the following error when I ran "karma start" module.js:340 throw err; ^ Error: Cannot find module 'jasmine-core' at Function.Module._resolveFilename (module.js:338:15) at Function.require.resolve (module.js:384:19) at initJasmine (/usr/lib/node_modules/karma-jasmine/lib/index.js:8:42) at Array.invoke [as 0] (/usr/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15) at get (/usr/lib/node_modules/karma/node_modules/di/lib/injector.js:48:43) at /usr/lib/node_modules/karma