forked from thymikee/jest-preset-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-jest.js
27 lines (25 loc) · 1.02 KB
/
setup-jest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require('zone.js/bundles/zone-testing-bundle.umd');
const { getTestBed } = require('@angular/core/testing');
const {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} = require('@angular/platform-browser-dynamic/testing');
let teardown = globalThis.ngJest?.teardown;
const configuredDestroyAfterEach = globalThis.ngJest?.destroyAfterEach;
if (configuredDestroyAfterEach) {
console.warn(
'Passing destroyAfterEach for configuring the test environment has been deprecated.' +
' Please pass a `teardown` object with ModuleTeardownOptions interface instead,' +
' see https://github.com/angular/angular/blob/6952a0a3e68481564b2bc4955afb3ac186df6e34/packages/core/testing/src/test_bed_common.ts#L98'
);
teardown = {
destroyAfterEach: true,
};
}
if (teardown !== undefined) {
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
teardown,
});
} else {
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
}