Skip to content

Commit fd52a59

Browse files
authoredNov 17, 2023
fix: log globals warning only once (#1252)
Resolves #1249
1 parent d80319f commit fd52a59

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎src/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ if (typeof process === 'undefined' || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
2020
teardown(() => {
2121
cleanup()
2222
})
23-
} else {
23+
} else if (!process.env.RTL_AFTEREACH_WARNING_LOGGED) {
24+
process.env.RTL_AFTEREACH_WARNING_LOGGED = true
2425
console.warn(
2526
`The current test runner does not support afterEach/teardown hooks. This means we won't be able to run automatic cleanup and you should be calling cleanup() manually.`,
2627
)
@@ -39,7 +40,8 @@ if (typeof process === 'undefined' || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
3940
afterAll(() => {
4041
setReactActEnvironment(previousIsReactActEnvironment)
4142
})
42-
} else {
43+
} else if (!process.env.RTL_AFTERALL_WARNING_LOGGED) {
44+
process.env.RTL_AFTERALL_WARNING_LOGGED = true
4345
console.warn(
4446
'The current test runner does not support beforeAll/afterAll hooks. This means you should be setting IS_REACT_ACT_ENVIRONMENT manually.',
4547
)

0 commit comments

Comments
 (0)
Please sign in to comment.