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

Merged
merged 4 commits into from
Oct 28, 2021

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Oct 19, 2021

What:

waitFor no longer triggers "missing act" warnings when using real timers.

Why:

Accomodate reactwg/react-18#102

How:

Run with IS_REACT_ACT_ENVIRONMENT when using our act.
Run without IS_REACT_ACT_ENVIRONMENT in waitFor (advancing timers is still wrapped in act to flush updates).

I'm quite uncomfortable with the implementation. We need to accomodate thenables in our act so we have to make sure we're resetting IS_REACT_ACT_ENVIRONMENT not too early.

I didn't enable IS_REACT_ACT_ENVIRONMENT in 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:

@eps1lon eps1lon changed the title feat: Use concurrent React when available (#937) fix: Don't trigger "missing act" warnings when using waitFor+real timers Oct 19, 2021
@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 19, 2021

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:

Sandbox Source
React Configuration
react-testing-library-examples Configuration

@codecov
Copy link

codecov bot commented Oct 19, 2021

Codecov Report

Merging #980 (94d6333) into alpha (c888cb6) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             alpha      #980   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          179       224   +45     
  Branches        38        46    +8     
=========================================
+ Hits           179       224   +45     
Flag Coverage Δ
experimental 94.19% <100.00%> (+1.45%) ⬆️
latest 91.07% <86.36%> (-0.55%) ⬇️
next 94.19% <100.00%> (+1.45%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/act-compat.js 100.00% <100.00%> (ø)
src/pure.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c888cb6...94d6333. Read the comment docs.

@eps1lon
Copy link
Member Author

eps1lon commented Oct 28, 2021

It's an alpha so 🤷🏻‍♂️

@eps1lon eps1lon merged commit a045bc3 into testing-library:alpha Oct 28, 2021
@eps1lon eps1lon deleted the feat/spurious-act-warnings branch October 28, 2021 08:45
eps1lon added a commit to eps1lon/react-testing-library that referenced this pull request Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant