testing-library / testing-library/react-testing-library
React act() warning persists with latest versions (React 18.3.1 + RTL 16.3.0 + Vitest 2.1.0)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 19.7k
- Forks
- 1.2k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 1
Description
Summary
The "Warning: The current testing environment is not configured to support act(...)" warning persists with the latest versions of React, React Testing Library, and Vitest as of January 2025.
Environment
- React: 18.3.1
- React DOM: 18.3.1
- @testing-library/react: 16.3.0
- Vitest: 2.1.0
- Node: 20+
- Environment: jsdom
Related Issues
This appears to be a continuation of:
- #1336 (June 2024) - Same warning with RTL v16
- #1338 (June 2024) - Vitest + RTL + userEvent warnings
- #1061 (2022) - Original issue, claimed resolved but persists
Problem Description
Despite following all documented solutions and having the latest versions:
- ✅ React 18.3.1+ (required version)
- ✅ Single React version in dependency tree (verified with
npm ls react) - ✅ Latest @testing-library/react (16.3.0)
- ✅ Properly using
act()from @testing-library/react - ✅ Removed manual
IS_REACT_ACT_ENVIRONMENTsettings (as docs suggest these are ineffective in React 18.3.1+)
The warning still appears when running tests with Vitest.
Minimal Reproduction
import { render, screen, fireEvent, waitFor, act } from '@testing-library/react';
import { describe, it, expect, vi } from 'vitest';
const TestComponent = () => {
const [loading, setLoading] = useState(false);
const handleClick = async () => {
setLoading(true);
await fetch('/api/test');
setLoading(false);
};
return (
<button onClick={handleClick}>
{loading ? 'Loading...' : 'Click me'}
</button>
);
};
describe('TestComponent', () => {
it('should handle async state updates', async () => {
global.fetch = vi.fn().mockResolvedValue({ ok: true });
render(<TestComponent />);
const button = screen.getByText('Click me');
await act(async () => {
fireEvent.click(button);
await waitFor(() => {
expect(screen.getByText('Loading...')).toBeInTheDocument();
});
});
// Warning appears here despite proper act() usage
});
});
Expected Behavior
No warnings when using act() properly with supported versions.
Actual Behavior
Warning: The current testing environment is not configured to support act(...)
Question for Maintainers
- Is this a known limitation of the Vitest + React 18.3.1+ combination?
- Is there a timeline for resolving this compatibility issue?
- Should these warnings be considered acceptable/ignorable with the current tech stack?
Tests function correctly despite the warnings, but they create noise in CI/CD pipelines and developer workflows.
Additional Context
Multiple developers have reported this same issue across different projects with identical tech stacks, suggesting this is a systematic compatibility problem rather than individual configuration issues.
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
No repository files or tests are named. Start by running the minimal reproduction with the listed React, React Testing Library, Vitest, Node, and jsdom versions, then trace the test-environment setup that produces the warning. Done means identifying a reproducible compatibility cause and documenting or validating a fix that removes the warning without breaking the test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react, typescript
- Domain
- frontend, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100