-
Notifications
You must be signed in to change notification settings - Fork 472
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
Safe check for setImmediate and clearImmediate #916
Safe check for setImmediate and clearImmediate #916
Conversation
Jest is planning to sandbox setImmediate, and this would not work since setImmediate and clearImmediate would be undefined.
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 014ed78:
|
It would be good to check if this is enough to fix jestjs/jest#11222. |
That's great, I'm trying to find a reasonable way to add tests for this. |
Looks like jestjs/jest#11222 (comment) works! |
Codecov Report
@@ Coverage Diff @@
## master #916 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 26 26
Lines 944 948 +4
Branches 285 287 +2
=========================================
+ Hits 944 948 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
That's awesome! It just finished testing it. |
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.
Haven't looked into the issue but this seems ok. Just some minor issues with the testing approach to consider.
Make sure that if the test breaks, it would not break other tests either by properly restoring those global variables in an afterEach call.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Yeah. I also tested temporarily deleting |
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.
LGTM 👍 And with the 👍👍 from several folks, I'd say we can merge this.
Hope you don't mind I added a little comment to explain why we have the extra check. |
@all-contributors please add @renatoalencar for code and tests |
I've put up a pull request to add @renatoalencar! 🎉 |
That's awesome, thanks. |
@all-contributors please add @gaearon for bugs and review |
I've put up a pull request to add @gaearon! 🎉 |
🎉 This PR is included in version 7.30.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
thanks! |
What:
Avoid crashing when
setImmediate
andclearImmediate
is not defined, which is now the case for JSDOM.Why:
See #914
How:
Safe check suggested by @gaearon
Checklist:
docs site