Skip to content

Commit 95082d7

Browse files
committed
chore: add warnings when globals are missing
1 parent 6de5f4c commit 95082d7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ if (typeof process === 'undefined' || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
2020
teardown(() => {
2121
cleanup()
2222
})
23+
} else {
24+
console.warn(
25+
`The current test runner does not support afterEach/teardown. This means won't be able to run automatic cleanup and you should be callin cleanup() manually.`,
26+
)
2327
}
2428

2529
// No test setup with other test runners available
26-
/* istanbul ignore else */
2730
if (typeof beforeAll === 'function' && typeof afterAll === 'function') {
2831
// This matches the behavior of React < 18.
2932
let previousIsReactActEnvironment = getIsReactActEnvironment()
@@ -35,6 +38,10 @@ if (typeof process === 'undefined' || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
3538
afterAll(() => {
3639
setReactActEnvironment(previousIsReactActEnvironment)
3740
})
41+
} else {
42+
console.warn(
43+
'The current test runner does not support beforeAll/afterAll. This means you should be setting IS_REACT_ACT_ENVIRONMENT manually.',
44+
)
3845
}
3946
}
4047

0 commit comments

Comments
 (0)