testing-library / testing-library/react-testing-library
Bug: global.IS_REACT_ACT_ENVIRONMENT = false does not disable missing act warnings
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 19.7k
- Forks
- 1.2k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 1
Description
This issue was first created in facebook/react, see https://github.com/facebook/react/issues/24854.
The rational behind why we want to disable act warnings: https://github.com/facebook/react/issues/23197
Potentially related to using jest. Didn't confirm.
React version: 18.2.0
Steps To Reproduce
- Clone https://github.com/anilanar/react-18-act-env ; which is a
create-react-appwith an adjustment toAppcomponent to trigger an asyncsetStateand an adjustment to the test to wait for that async state update. npm installnpm test -- --watchAll
The current behavior
It logs Warning: An update to App inside a test was not wrapped in act(...).
The expected behavior
It does not log that warning.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the warning by cloning the linked react-18-act-env example, installing dependencies, and running the stated npm test command. Inspect the adjusted App component and its test around the async state update and global.IS_REACT_ACT_ENVIRONMENT; done means the update still completes without logging the missing act warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100