karma-jasmine

Karma error - Unknown provider: $$asyncCallbackProvider

℡╲_俬逩灬. 提交于 2019-12-01 15:58:41
Trying to run my karma test through grunt but getting an error: Error: [$injector:modulerr] Failed to instantiate module ngMock due to: Error: [$injector:unpr] Unknown provider: $$asyncCallbackProvider I removed 'ngAnimate' but does not resolve it. How can I run the grunt karma test without this error? I had the same problem just now, and fixed it by making sure the version of my angular-mock dependancy was the same as that angular. You can do this in your bower.json file (change "angular-mocks": "~1.3.0" to "angular-mocks": "^1.3.0" or a specific version). While I have no doubt that 3sdmx's

Karma error - Unknown provider: $$asyncCallbackProvider

孤街浪徒 提交于 2019-12-01 15:00:28
问题 Trying to run my karma test through grunt but getting an error: Error: [$injector:modulerr] Failed to instantiate module ngMock due to: Error: [$injector:unpr] Unknown provider: $$asyncCallbackProvider I removed 'ngAnimate' but does not resolve it. How can I run the grunt karma test without this error? 回答1: I had the same problem just now, and fixed it by making sure the version of my angular-mock dependancy was the same as that angular. You can do this in your bower.json file (change

Angular mock $httpBackend give No pending request to flush

半城伤御伤魂 提交于 2019-12-01 14:59:54
Following the official guide at angularJS $httpBackend I'll do this test, but Karma give me this error : Error: No pending request to flush ! at Function.$httpBackend.flush Test 'use strict'; describe('profileCtrl', function () { var scope, $httpBackend; beforeEach(angular.mock.module('maap')); beforeEach(angular.mock.inject(function($rootScope, $controller, _$httpBackend_){ $httpBackend = _$httpBackend_; $httpBackend.when('GET', 'profile').respond([{id: 1, name: 'Bob'}]); scope = $rootScope.$new(); $controller('profileCtrl', {$scope: scope}); })) it('should fetch list of users', function(){

Requirejs do not add “.js” for modules using karma

喜你入骨 提交于 2019-12-01 14:24:52
I have simple test, that must work in webstorm using karma and requirejs. The problem is that for some reason requirejs do not add ".js" for modules i was loading for tests. So it crashed trying to load "../ts/mamats/mama", while "../ts/mamats/mama.js" exists Test (main.jasmine.js): define(["require", "exports", "../ts/mamats/mama"], function(require, exports, mama) { describe("first test", function () { it("should be true", function () { var object = new mama.block(); expect(object instanceof mama.block).toBe(true); }); }); }); //# sourceMappingURL=main.jasmine.js.map every thing works

Requirejs do not add “.js” for modules using karma

对着背影说爱祢 提交于 2019-12-01 13:04:33
问题 I have simple test, that must work in webstorm using karma and requirejs. The problem is that for some reason requirejs do not add ".js" for modules i was loading for tests. So it crashed trying to load "../ts/mamats/mama", while "../ts/mamats/mama.js" exists Test (main.jasmine.js): define(["require", "exports", "../ts/mamats/mama"], function(require, exports, mama) { describe("first test", function () { it("should be true", function () { var object = new mama.block(); expect(object

Angular 2 Jasmine testing, Loading all components in app.component.ts?

梦想与她 提交于 2019-12-01 12:18:45
I'm working on a small test app to learn Angular 2 and unit testing in Angular 2 a bit better. Coming from a react - Jest background; it feels weird to include all components in the app.component.ts. This is what the component Hierarchy looks like for what I have so far: App.Component > Layout.Component > Header.Component > Nav.Component When I run npm test, I get the error of main-header' is not a known element: When I'd fix this by Importing and declaring the component bound to that selector in App.Component.spec.ts, I would just get the same error for the next component/selector inline. Had

Angular 2 Jasmine testing, Loading all components in app.component.ts?

自古美人都是妖i 提交于 2019-12-01 10:26:50
问题 I'm working on a small test app to learn Angular 2 and unit testing in Angular 2 a bit better. Coming from a react - Jest background; it feels weird to include all components in the app.component.ts. This is what the component Hierarchy looks like for what I have so far: App.Component > Layout.Component > Header.Component > Nav.Component When I run npm test, I get the error of main-header' is not a known element: When I'd fix this by Importing and declaring the component bound to that

How do I trigger a mousemove event in an angularjs unit test

余生颓废 提交于 2019-12-01 09:16:07
I have implemented an angularjs directive that use mouse event; clicking on component and moving mouse up or down it can changes a value. So i need to know how do I trigger a mousemove event in a unit test (i use karma/jasmine); I'd like to have a suggestion to testing this component when mouse goes up or down in an unit test. Component template is something like that: <div class="rotativeContent"> <p class="rotativeLabel">{{label}}</p> <pie class="zero"></pie> <p class="rotativeValue">{{ngModel}}</p> <input type="hidden" ng-model="ngModel"/> </div> and javascript code is: var Component =

How do I trigger a mousemove event in an angularjs unit test

爷,独闯天下 提交于 2019-12-01 06:08:31
问题 I have implemented an angularjs directive that use mouse event; clicking on component and moving mouse up or down it can changes a value. So i need to know how do I trigger a mousemove event in a unit test (i use karma/jasmine); I'd like to have a suggestion to testing this component when mouse goes up or down in an unit test. Component template is something like that: <div class="rotativeContent"> <p class="rotativeLabel">{{label}}</p> <pie class="zero"></pie> <p class="rotativeValue">{

How to correctly use SharedModules with Router while testing angular 2 application?

馋奶兔 提交于 2019-12-01 05:42:53
I'm trying to unit test a (angular 2) component with routerLink and routerLinkActive but all test cases fail with following error message. ( Note: I have stubbed the router and other related dependencies. Here's the reference that I used for the same.). Cannot read property 'subscribe' of undefined I have also noticed that when routerLink and routerLinkActive are removed from my template, all test cases will run without any errors. I think the error is caused by either RouterTestingModule or SharedModule (contains component for displaying and validating password input field) . So I tried