You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/getting-started/test-environment.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,3 +9,19 @@ we also make sure Jest test methods run in Zone context. Then we initialize the
9
9
10
10
While `setup-jest.js` above is for running Jest with **CommonJS** mode, we also provide [`setup-jest.mjs`](https://github.com/thymikee/jest-preset-angular/blob/main/setup-jest.mjs)
11
11
to run with **ESM** mode.
12
+
13
+
### Configure test environment
14
+
15
+
When creating Angular test environment with `TestBed`, it is possible to specify the behavior of `teardown` via `globalThis` in the Jest setup file.
16
+
For example:
17
+
18
+
```ts
19
+
// setup-test.ts
20
+
globalThis.ngJest= {
21
+
destroyAfterEach: true,
22
+
};
23
+
24
+
import'jest-preset-angular/setup-jest';
25
+
```
26
+
27
+
`jest-preset-angular` will look at `globalThis.ngJest` and pass the correct `destroyAfterEach` to `TestBed`.
0 commit comments