testing-library / testing-library/react-testing-library

Bug: global.IS_REACT_ACT_ENVIRONMENT = false does not disable missing act warnings

Open
#1,108 9 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs more information
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

  1. Clone https://github.com/anilanar/react-18-act-env ; which is a create-react-app with an adjustment to App component to trigger an async setState and an adjustment to the test to wait for that async state update.
  2. npm install
  3. npm 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.