Skip to content

Commit

Permalink
fix: guard against process and process.env not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
MatanBobi committed Nov 17, 2023
1 parent fd52a59 commit e5dbeeb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ if (typeof process === 'undefined' || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
teardown(() => {
cleanup()
})
} else if (!process.env.RTL_AFTEREACH_WARNING_LOGGED) {
} else if (process?.env && !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.`,
`The current test runner does not support afterEach/teardown hooks or globals are not injected. This means we won't be able to run automatic cleanup and you should be calling cleanup() manually.`,
)
}

Expand All @@ -40,10 +40,10 @@ if (typeof process === 'undefined' || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
afterAll(() => {
setReactActEnvironment(previousIsReactActEnvironment)
})
} else if (!process.env.RTL_AFTERALL_WARNING_LOGGED) {
} else if (process?.env && !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.',
'The current test runner does not support beforeAll/afterAll hooks or globals are not injected. This means you should be setting IS_REACT_ACT_ENVIRONMENT manually.',
)
}
}
Expand Down

0 comments on commit e5dbeeb

Please sign in to comment.