# Category: karma-jasmine

## Karma jasmine test angular 5 cannot call Promise

I am new to karma jasmine test and I am struggling with a test that always gives this error when I launch the test: Error: Cannot call Promise.then from within a sync test. I am using angular 5. Here is my test code: fdescribe(‘CommentComponent’, () => { let component: CommentComponent; let fixture: ComponentFixture<CommentComponent>; let commentService: CommentService; const stationId = 900; let station: Station; let comment: Comment; beforeEach(fakeAsync(() => { station = new Station(); station.id = […]

## AngularJS + Karma + Jasmine: beforeEach() – angular.module vs angular.mock.module

I am new to Jasmine and Karma testing. I am trying to Unit test AngularJs Service. While writing Specs, I came around two types of Code for injecting Module. 1st Type beforeEach(angular.mock.module(“app”)); 2nd Type beforeEach(function () { angular.module(“app”); }); Can anybody explain the difference between the above two in simple plain English with a simple example. And also, which code to use in what kind of scenario? I tried to Google it, but was not […]