Skip to content

Commit bf13638

Browse files
committed
feat: Enable "missing act" warnings in React 18 by default
1 parent d8c6b4d commit bf13638

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/index.js

+11
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,15 @@ if (typeof process === 'undefined' || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
2222
}
2323
}
2424

25+
// This matches the behavior of React < 18.
26+
if (typeof beforeAll === 'function' && typeof afterAll === 'function') {
27+
beforeAll(() => {
28+
global.IS_REACT_ACT_ENVIRONMENT = true
29+
})
30+
31+
afterAll(() => {
32+
global.IS_REACT_ACT_ENVIRONMENT = false
33+
})
34+
}
35+
2536
export * from './pure'

tests/setup-env.js

-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
11
import '@testing-library/jest-dom/extend-expect'
2-
3-
beforeEach(() => {
4-
global.IS_REACT_ACT_ENVIRONMENT = true
5-
})
6-
7-
afterEach(() => {
8-
global.IS_REACT_ACT_ENVIRONMENT = false
9-
})

0 commit comments

Comments
 (0)