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

[Feature Request] Add warnings when globals aren't injected

Open
#1,257 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
19.7k
Forks
1.2k
Avg merge
3d 16h
Merged PRs (30d)
1

Description

Describe the feature you'd like:

As a followup to https://github.com/testing-library/react-testing-library/issues/1240.
If a user isn't injecting globals (like in vitest), they need to call cleanup on their own and also set the REACT_IS_ACT_ENVIRONMENT. In case they aren't doing that, we should warn them because this will break the behavior.

Suggested implementation:

We can log a warning in case globals aren't injected, but this won't cover the option where users can call cleanup on their own.

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

Start by tracing how global injection and cleanup are configured for users of Vitest, including handling of REACT_IS_ACT_ENVIRONMENT. Define the warning behavior for missing globals and determine how the case where users call cleanup themselves can be detected or documented; done means both setup paths receive appropriate guidance without breaking existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.