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

feat: Enable "missing act" warnings in React 18 by default #994

Merged
merged 2 commits into from Nov 23, 2021

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Nov 18, 2021

What:

Enables "missing act" warnings in React 18 for test runners that implement beforeAll and afterAll (e.g. Jest).
This can be disabled the same way auto-cleanup can be disabled.

Why:

Ensures same behavior regarding missing act warnings across as React 16 and 17

How:

Set IS_REACT_ACT_ENVIRONMENT to true once before tests start.

Checklist:

  • [ ] Documentation added to the
    docs site Will wait until React docs for IS_REACT_ACT_ENVIRONMENT are available.
  • Tests
  • [ ] TypeScript definitions updated
  • Ready to be merged

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 18, 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 3c5c261:

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

@codecov
Copy link

codecov bot commented Nov 18, 2021

Codecov Report

Merging #994 (3c5c261) into alpha (d8c6b4d) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             alpha      #994   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          226       233    +7     
  Branches        46        47    +1     
=========================================
+ Hits           226       233    +7     
Flag Coverage Δ
experimental 94.42% <100.00%> (+0.17%) ⬆️
latest 90.55% <100.00%> (+0.29%) ⬆️
next 94.42% <100.00%> (+0.17%) ⬆️

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/index.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 d8c6b4d...3c5c261. Read the comment docs.

@eps1lon eps1lon marked this pull request as ready for review November 18, 2021 11:49
@eps1lon
Copy link
Member Author

eps1lon commented Nov 23, 2021

The warning is a pretty important part of the migration story to understand why certain tests might start failing or at least excibit different behavior. At least with React 18 users are able to disable the "missing act" warning if they truly want to so this change should be fairly safe.

The only issue might if people reset their modules in beforeEach so we may want to switch to beforeEach instead of beforeAll.

@eps1lon eps1lon merged commit 8e536f8 into testing-library:alpha Nov 23, 2021
@eps1lon eps1lon deleted the feat/missing-act-warning branch November 23, 2021 15:15
@github-actions
Copy link

🎉 This PR is included in version 13.0.0-alpha.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@IanVS
Copy link

IanVS commented Jul 27, 2022

For anyone else finding this and wondering what the same way auto-cleanup can be disabled is, the docs are at: https://testing-library.com/docs/react-testing-library/setup#skipping-auto-cleanup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants