-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathindex.ts
35 lines (30 loc) · 1.14 KB
/
index.ts
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
33
34
35
import './helpers/ensure-peer-deps';
import './matchers/extend-expect';
import { getIsReactActEnvironment, setReactActEnvironment } from './act';
import { flushMicroTasks } from './flush-micro-tasks';
import { cleanup } from './pure';
if (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {
// If we're running in a test runner that supports afterEach
// then we'll automatically run cleanup afterEach test
// this ensures that tests run in isolation from each other
// if you don't like this then either import the `pure` module
// or set the RNTL_SKIP_AUTO_CLEANUP env variable to 'true'.
if (typeof afterEach === 'function') {
afterEach(async () => {
await flushMicroTasks();
cleanup();
});
}
if (typeof beforeAll === 'function' && typeof afterAll === 'function') {
// This matches the behavior of React < 18.
let previousIsReactActEnvironment = getIsReactActEnvironment();
beforeAll(() => {
previousIsReactActEnvironment = getIsReactActEnvironment();
setReactActEnvironment(true);
});
afterAll(() => {
setReactActEnvironment(previousIsReactActEnvironment);
});
}
}
export * from './pure';