React act() warning persists with latest versions (React 18.3.1 + RTL 16.3.0 + Vitest 2.1.0)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Tranquilla
- Stack tecnologico
- javascript, react, typescript
- Ambito
- frontend, testing-qa
Direzione di ricerca
Non vengono indicati file del repository né test. Inizia eseguendo la riproduzione minima con le versioni elencate di React, React Testing Library, Vitest, Node e jsdom, quindi analizza a ritroso la configurazione dell’ambiente di test che produce l’avviso. Il lavoro è terminato quando viene identificata una causa di compatibilità riproducibile e viene documentato o convalidato un fix che rimuove l’avviso senza compromettere il test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- JavaScript
- Stelle
- 19.7k
- Fork
- 1.2k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di testing-library/react-testing-library
-
fireEvent.select does not wrap its automatic native focus in actForse già presa @sergioperezcheco l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict modeForse di nuovo libera @suhailopensource l’ha presa 73 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
testing-library/react-testing-library#1466 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
testing-library/react-testing-library#1459 · 2 commenti ·
-
perf: optimize container lookup with early exitForse di nuovo libera @Ch-Abhinav-Chowdary l’ha presa 299 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 35/100
testing-library/react-testing-library#1430 · 1 commento ·
-
`fireEvent.mouseEnter` does not forward `relatedTarget` (relatedTarget is the window instead)Forse già presa @swarnim02 l’ha presa 316 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
Tutte le issue di testing-library/react-testing-library
Issue simili
-
bug confirmed perf
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
videojs/video.js#9400 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
agent/scanner bug hive/hosted-available-lke648397-260827-5n31
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
rescript-lang/rescript#8765 ·
I maintainer di solito rispondono entro 1 giorno
-
feedback simulation workshop
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
githubnext/gh-aw-workshop#4417 ·
I maintainer di solito rispondono entro 1 giorno
-
[Good First Issue]: Add unit tests for NetworkVersionInfoForse già presa @attilayener l’ha presa oggi. ApertaGood First Issue hacktoberfest
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
hiero-ledger/hiero-sdk-js#4489 ·
I maintainer di solito rispondono entro 1 giorno