Donnerstag, 17. Mai 2018

Jasmine runner TypeError 'next' in Angular5 Tests

I stumbled upon an error, which a karma runner gives me in some of our jasmine tests:

TypeError: Cannot read property 'next' of undefined
    at <Jasmine>
    at Function.continuer node_modules/q/q.js:1278:1)
    at UserContext.<anonymous> node_modules/q/q.js:1305:1)
    at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke node_modules/zone.js/dist/zone.js:388:1)
    at ProxyZoneSpec.webpackJsonp../node_modules/zone.js/dist/proxy.js.ProxyZoneSpec.onInvoke node_modules/zone.js/dist/proxy.js:128:1)
    at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke node_modules/zone.js/dist/zone.js:387:1)
    at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.run node_modules/zone.js/dist/zone.js:138:1)
    at runInTestZone node_modules/zone.js/dist/jasmine-patch.js:145:1)
    at UserContext.<anonymous> node_modules/zone.js/dist/jasmine-patch.js:160:1)
    at <Jasmine>

I couldn't find something wrong with the test itself, but I noticed an strange import:

[async] from "q";

This was the reason for the strange error message. Correct import ist

[async] from "@angular/core/testing";

Keine Kommentare:

Kommentar veröffentlichen