-
Notifications
You must be signed in to change notification settings - Fork 308
/
setup-jest.js
32 lines (25 loc) · 983 Bytes
/
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
28
29
30
31
32
console.warn(`
Importing "setup-jest.js" directly is deprecated. The file "setup-jest.js" will be removed in the future.
Please use "setupZoneTestEnv" function instead. Example:
// setup-jest.ts
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';
setupZoneTestEnv();
`);
require('zone.js');
require('zone.js/testing');
const { TextEncoder, TextDecoder } = require('util');
const { getTestBed } = require('@angular/core/testing');
const {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} = require('@angular/platform-browser-dynamic/testing');
if (typeof globalThis.TextEncoder === 'undefined') {
globalThis.TextEncoder = TextEncoder;
globalThis.TextDecoder = TextDecoder;
}
const testEnvironmentOptions = globalThis.ngJest?.testEnvironmentOptions ?? Object.create(null);
getTestBed().initTestEnvironment(
[BrowserDynamicTestingModule],
platformBrowserDynamicTesting(),
testEnvironmentOptions,
);