fix: Don't trigger "missing act" warnings when using waitFor+real timers#980
Merged
eps1lon merged 4 commits intotesting-library:alphafrom Oct 28, 2021
Merged
Conversation
waitFor+real timers
|
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 94d6333:
|
Codecov Report
@@ Coverage Diff @@
## alpha #980 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 179 224 +45
Branches 38 46 +8
=========================================
+ Hits 179 224 +45
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Member
Author
|
It's an alpha so 🤷🏻♂️ |
eps1lon
added a commit
to eps1lon/react-testing-library
that referenced
this pull request
Nov 22, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What:
waitForno longer triggers "missing act" warnings when using real timers.Why:
Accomodate reactwg/react-18#102
How:
Run with
IS_REACT_ACT_ENVIRONMENTwhen using ouract.Run without
IS_REACT_ACT_ENVIRONMENTinwaitFor(advancing timers is still wrapped in act to flush updates).I'm quite uncomfortable with the implementation. We need to accomodate thenables in our
actso we have to make sure we're resettingIS_REACT_ACT_ENVIRONMENTnot too early.I didn't enable
IS_REACT_ACT_ENVIRONMENTin our global setup (i.e. the main entrypoint) since that would enable "missing act" warnings in non-jest environments.We probably want to do this anyway but that should be handled in a separate PR since it would be new behavior.
Checklist:
[ ]Documentation added to thedocs site
Integration testing (tests failed due to flaky BrowserStack): https://app.circleci.com/pipelines/github/mui-org/material-ui/53844/workflows/c2a6f9d9-2d63-4cea-bfd2-87a92cdb1d61
[ ]TypeScript definitions updated