karma-jasmine

Some of your tests did a full page reload - error when running Jasmine tests

白昼怎懂夜的黑 提交于 2019-12-03 00:58:54
I'm running into an issue where when I run my tests on Jasmine, I get this error below. The problem is, it seems to happen when I try to execute a certain amount of tests. It doesn't seem to be tied to a particular test, as if I comment out some, the tests pass. If I uncomment some tests, the error appears. If I comment out ones that were uncommented before, they all pass again. (ie if I have red, green, blue and orange test and it fails, I comment out orange and blue it passes, then I uncomment blue and orange it fails again, but if I comment out red and green it passes again). Chrome 41.0

ReferenceError: module is not defined - Karma/Jasmine configuration with Angular/Laravel app

China☆狼群 提交于 2019-12-03 00:53:51
I have an existing Angular/Laravel app in which Laravel acts as an API to the angular frontend serving only JSON data. The page that loads the angular app, index.php , is currently served by Laravel. From there, Angular takes over. I'm have a very difficult time trying to get started with Karma/Jasmine. When running my tests using karma start or karma start karma.conf.js from the root directory of my project, I get the following error: ReferenceError: module is not defined Full output: INFO [karma]: Karma v0.12.28 server started at http://localhost:9876/ INFO [launcher]: Starting browser

Angular Karma Jasmine Error: Illegal state: Could not load the summary for directive

本秂侑毒 提交于 2019-12-02 21:32:26
I'm developing a github repository (with angular 7 and angular-cli), and I have some tests with Karma and Jasmine working in the master branch. Now I'm trying to add lazy loading feature, the thing is, that the tests that before passed, now they do not. It's funny because only the tests from the lazy loading module are failing... Here is the code and the error: import {async, TestBed} from '@angular/core/testing'; import {APP_BASE_HREF} from '@angular/common'; import {AppModule} from '../../app.module'; import {HeroDetailComponent} from './hero-detail.component'; describe('HeroDetailComponent'

Spy on the result of an Observable Subscription with Jasmine

元气小坏坏 提交于 2019-12-02 20:49:09
问题 I am Jasmine unit testing an angular component, which uses Observables. My component has this lifecycle hook that I am testing: ngOnInit() { this.dataService.getCellOEE(this.cell).subscribe(value => this.updateChart(value)); } I have a test that ensures that getCellOEE has been called, but now I want to check that updateChart is called when the observable resolves with a new value. This is what I have so far: let fakeCellService = { getCellOEE: function (value): Observable<Array<IOee>> {

Jasmine-karma : how to check navigation functionality in Ionic?

为君一笑 提交于 2019-12-02 17:50:55
问题 I have written a test case for navController using spyOn, getting error called : Error: <spyOn> : push() method does not exist Usage: spyOn(<object>, <methodName>) exp.ts : import { Component } from '@angular/core'; import { NavController } from 'ionic-angular'; import { Injectable } from '@angular/core' ; import { HttpClient, HttpResponse, HttpErrorResponse, HttpHeaders } from '@angular/common/http' ; import { SubmittingHc } from '../submitting-conditions/submitting-conditions'; @Injectable(

Debug Tests in NG Test

自古美人都是妖i 提交于 2019-12-02 17:28:38
I am using Angular CLI and VS code but none of my breakpoints in my spec files seem to be getting hit when I run ng test? Do I need to do some config? The other answers are completely valid answers but having been using Angular for around 18 months now I tend to do it in the browser - chrome tools! Run ng test then f12 and find the spec file via the webpack context. Add a breakpoint(s) and refresh and it will hit said breakpoints. As per screenshot titusfx In the new release of VSCode (1.14.0) they follow this recipe : You can debug the Angular App entirely ( including the unit tests ), the

what is the real difference between ng test and ng e2e

天涯浪子 提交于 2019-12-02 17:06:45
I am afraid someone close my question but I couldn't find a satisfying question (maybe because I am very limited in Angular 2+ world and I understood something wrong). As far as I could understand after few Hello World done and few YouTube demo watched: ng test: you write your test using Jasmine language you test your test with many Browsers available using Karma you execute either unit or integrated testing all xxx.compnent.spec.ts run and a final report similar to JUnit is showed in browser ng e2e: you write your test using Jasmine language you test your test with many Browsers available

Testing Angular component with unsubscribe Error during cleanup of component

混江龙づ霸主 提交于 2019-12-02 16:13:16
I'm testing a component which subscribe router params. Every test pass and everything works fine. But if I look in the console, I can see an error: Error during cleanup of component ApplicationViewComponent localConsole.(anonymous function) @ context.js:232 Do you know why this occurs? I tried removing the unsubscribe() from ngOnDestroy() method and the error disappears. Is karma/jasmine supporting unsubscribe() automatically? Here is the component and tests Component import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Subscription }

Expected Response with status: null null for URL: null to equal 'Project11'

≡放荡痞女 提交于 2019-12-02 13:59:24
I am using angular7 and doing unit testing in jasmine and karma. And I am facing error - Error: Expected Response with status: null null for URL: null to equal 'Project11'. My packages versions are - "@types/jasmine": "~2.8.6", "@types/jasminewd2": "~2.0.3", "@types/jquery": "^3.3.22", "@types/node": "~8.9.4", "codelyzer": "~4.2.1", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~1.7.1", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~1.4.2", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "^5.4.1", "ts-node":

Test for rejected promise with Jasmine

ⅰ亾dé卋堺 提交于 2019-12-02 12:43:56
In my Angular2 app which uses AngularFire2, I have an AuthService which tries to authenticate anonymously with Firebase. I am trying to write a test that expects AngularFireAuth 's signInAnonymously to return a rejected promise; for authState to be null and an error to be thrown. I an new to Jasmine and testing in general but I think I may need to be using asynchronous tests but I'm getting quite stuck. Here is a simplified AuthService : import { Injectable } from '@angular/core'; import { AngularFireAuth } from 'angularfire2/auth'; import * as firebase from 'firebase/app'; import { Observable