fix: Don't trigger "missing act" warnings when using waitFor+real timers
#980
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