New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: guard against process and process.env not defined #1254
Conversation
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If process.env
is not defined, we'll not provide this functionality at all since we won't have a place to save the flag.
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.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also updated this text because we received a couple of issues about it.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit e5dbeeb:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1254 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 192 192
Branches 40 40
=========================================
Hits 192 192
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
We will revert this change instead. |
What: This PR guards against
process
being not defined in browser environments.Why: It's breaking in browser environments.
How:
Checklist:
docs site
CC: @AviVahl