Skip to content

Commit

Permalink
chore: add warnings when globals are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
MatanBobi committed Oct 13, 2023
1 parent 6de5f4c commit 95082d7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ if (typeof process === 'undefined' || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
teardown(() => {
cleanup()
})
} else {
console.warn(
`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.`,
)
}

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

Expand Down

0 comments on commit 95082d7

Please sign in to comment.