React act() warning persists with latest versions (React 18.3.1 + RTL 16.3.0 + Vitest 2.1.0)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Tranquilo
- Stack tecnológico
- javascript, react, typescript
- Área
- frontend, testing-qa
Línea de trabajo
No se nombran archivos del repositorio ni pruebas. Empieza ejecutando la reproducción mínima con las versiones indicadas de React, React Testing Library, Vitest, Node y jsdom; después, sigue la configuración del entorno de pruebas que produce la advertencia. Se considera terminado cuando se identifica una causa de compatibilidad reproducible y se documenta o valida un fix que elimina la advertencia sin romper la prueba.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- JavaScript
- Estrellas
- 19.7k
- Forks
- 1.2k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de testing-library/react-testing-library
-
fireEvent.select does not wrap its automatic native focus in actPosiblemente ocupada @sergioperezcheco la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict modeQuizá libre de nuevo @suhailopensource la tomó hace 72 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
testing-library/react-testing-library#1466 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
testing-library/react-testing-library#1459 · 2 comentarios ·
-
perf: optimize container lookup with early exitQuizá libre de nuevo @Ch-Abhinav-Chowdary la tomó hace 298 días y no hay ningún pull request abierto. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 35/100
testing-library/react-testing-library#1430 · 1 comentario ·
-
`fireEvent.mouseEnter` does not forward `relatedTarget` (relatedTarget is the window instead)Posiblemente ocupada @swarnim02 la tomó hace 316 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
Todos los issues de testing-library/react-testing-library
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
processing/p5.sound.js#123 ·
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 82/100
PhilflowIO/dav-mcp#146 ·
Los mantenedores suelen responder en 1 día
-
Add a light/dark theme toggleAbiertogood first issue hacktoberfest
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Tanishq964/trail-kit.#4 ·
-
Request: <brand-name>Abiertonew icon permissions in review
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
simple-icons/simple-icons#15067 ·
Los mantenedores suelen responder en 1 día
-
status: needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
mastra-ai/mastra#26562 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día