Solvedzone.js Error: Missing: SyncTestZoneSpec
AbnerCrivellari posts at
19 Answers
Share
Original✔️Accepted Answer
@AbnerCrivellari , the loading order is not correct,
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import 'zone.js/dist/jasmine-patch';
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/proxy.js';
import 'zone.js/dist/sync-test';
you need to load proxy
and sync-test
before jasmine-patch
, if you use the latest version of zone.js
you can delete those lines just use zone-testing
.
so your test.ts
will become
// you only need this one file, and you need to load it first.
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
declare const __karma__: any;
declare const require: any;
// Prevent Karma from running prematurely.
__karma__.loaded = function () {
};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
// Finally, start Karma to run the tests.
__karma__.start();
Related Issues:
49
zone.js Runtime Error Zone already loaded
I had the same issue after following the tutorial from the docs: https://github.com/angular/angularf...
17
zone.js IE11 - SecurityError zone.js (192,25)
@kevinkuszyk I think I may find the possible reason when run ng serve there will be websocket to con...
12
zone.js 'Uncaught TypeError: Cannot set property stack of [object Object] which has only a getter' with Angular
You can work around this by changing line 135 in node_modules/zone.js/dist/long-stack-trace-zone.js ...
8
zone.js Error: Missing: SyncTestZoneSpec
@AbnerCrivellari the loading order is not correct you need to load proxy and sync-test before jasmin...
I was trying to run unit tests using jasmine, karma and angular. But for some reason I'm getting the following error.
Chrome 64.0.3282 (Windows 10.0.0) ERROR
Uncaught Error: Missing: SyncTestZoneSpec
at http://localhost:9876/_karma_webpack_/vendor.bundle.js:63353
Chrome 64.0.3282 (Windows 10.0.0) ERROR
Uncaught Error: Missing: SyncTestZoneSpec
at http://localhost:9876/_karma_webpack_/vendor.bundle.js:63353
I already search for solution but all of them is not working.
p.s: I'm using the latest version for zone.js, jasmine and karma