Skip to content

Commit

Permalink
fix: log globals warning only once (#1252)
Browse files Browse the repository at this point in the history
Resolves #1249
  • Loading branch information
MatanBobi committed Nov 17, 2023
1 parent d80319f commit fd52a59
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ if (typeof process === 'undefined' || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
teardown(() => {
cleanup()
})
} else {
} else if (!process.env.RTL_AFTEREACH_WARNING_LOGGED) {
process.env.RTL_AFTEREACH_WARNING_LOGGED = true
console.warn(
`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.`,
)
Expand All @@ -39,7 +40,8 @@ if (typeof process === 'undefined' || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
afterAll(() => {
setReactActEnvironment(previousIsReactActEnvironment)
})
} else {
} else if (!process.env.RTL_AFTERALL_WARNING_LOGGED) {
process.env.RTL_AFTERALL_WARNING_LOGGED = true
console.warn(
'The current test runner does not support beforeAll/afterAll hooks. This means you should be setting IS_REACT_ACT_ENVIRONMENT manually.',
)
Expand Down

0 comments on commit fd52a59

Please sign in to comment.