This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
testProxyZone is null in simple angular 5 / karma test run #1035
Closed
Description
I have logged a question for this, but I think it's possibly a bug.
testProxyZone
is null in the function below. TypeError: Cannot read property 'run' of null
all the packages are updated to the latest release version
function wrapTestInZone(testBody) {
// The `done` callback is only passed through if the function expects at least one argument.
// Note we have to make a function with correct number of arguments, otherwise jasmine will
// think that all functions are sync or async.
return testBody && (testBody.length ? function (done) {
return testProxyZone.run(testBody, this, [done]);
} : function () {
return testProxyZone.run(testBody, this); // <= this is null.
});
}
The testProxyZone is null even though my base.spec.js
contains the necessary imports.
import "core-js"
import "zone.js/dist/zone";
import "zone.js/dist/long-stack-trace-zone";
import "zone.js/dist/proxy";
import "zone.js/dist/sync-test";
import "zone.js/dist/jasmine-patch";
import "zone.js/dist/async-test";
import "zone.js/dist/fake-async-test";
import { TestBed } from "@angular/core/testing";
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from "@angular/platform-browser-dynamic/testing";
TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
the test contains the necessary import / setup
import { TestBed } from "@angular/core/testing";
describe("karma sanity check",
() => {
beforeEach(() =>
{
TestBed.configureTestingModule({ providers: [] });
});
it("1+1=2", () => expect(1 + 1).toBe(2));
});
and the configuration references the necessary libraries?
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'karma-typescript'],
plugins: [
require('karma-jasmine'),
require('karma-typescript'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter')
],
files: [
{ pattern: 'base.spec.ts'},
{ pattern: 'wwwroot/ts/**/*.spec.ts' }
],
preprocessors: {
"**/*.ts": ["karma-typescript"]
},
mime: {
'text/x-typescript': ['ts', 'tsx']
},
coverageIstanbulReporter: {
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
karmaTypescriptConfig: {
tsconfig: "./tsconfig.json"
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
Metadata
Metadata
Assignees
Labels
No labels