Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

130
Vistas
¿Tengo una llamada de acto inútil o se trata de un problema de React 18?

Actualmente estoy recibiendo un error en mi prueba:

 12 | const response = await axios.get('http://mock-api-call/weather/get-weather'); 13 | > 14 | setWeather(response.data.result.weather); | ^ 15 | }; 16 | 17 | useEffect(() => {

El error hace referencia a mi llamada api en el componente. Originalmente, recibí un mensaje de error de React para envolver mis pruebas en una función de acto con la que seguí sus indicaciones, pero no sé si lo seguí correctamente, aunque todas las pruebas funcionan. Me gustaría saber si He usado actuar incorrectamente para saber si se trata de un problema de React 18. Aquí hay algunos ejemplos de pruebas:

 jest.mock('axios'); const mockedAxios = axios as jest.Mocked<typeof axios>; describe('Return Weather Component Data', () => { beforeEach(() => { mockedAxios.get.mockResolvedValue({ data: { result: { weather: { forcast: 'Sunny', max: 28, min: 17, description: 'Clear skys all day with a warm summber breaze ariving in the afternoon', }, }, }, }); }); test('should return description', async () => { await act(async () => { const { getByText } = render(<WeatherComponent />); waitFor(() => { expect( getByText('Clear skys all day with a warm summber breaze ariving in the afternoon'), ).toBeInTheDocument(); }); }); }); test('should return forcast', async () => { await act(async () => { const { getByText } = render(<WeatherComponent />); waitFor(() => { expect(getByText(/Sunny/i)).toBeInTheDocument(); }); }); }); test('should return temp', async () => { await act(async () => { const { getByText } = render(<WeatherComponent />); waitFor(() => { expect(getByText(/Sunny with a low of 17 and a high of 28/i)).toBeInTheDocument(); }); }); }); });

mensaje de error:

 Warning: The current testing environment is not configured to support act(...)
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda