Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
La prueba de Jest pasa pero... tiene un mensaje de consola Está intentando acceder a una propiedad o método del entorno de Jest después de que se haya eliminado

Mi prueba pasa pero tiene un error de referencia en la consola:

Está intentando acceder a una propiedad o método del entorno Jest después de que se haya desmantelado.

Prueba:

 import {render, screen, cleanup, fireEvent, waitFor } from '@testing-library/react'; import {create, act} from 'react-test-renderer'; import Comp1 from './Comp1'; import ReactDOM from 'react-dom'; import "@testing-library/jest-dom"; import { QueryClient, QueryClientProvider } from 'react-query'; const queryClient = new QueryClient(); it('Should wait for response', () => { act(() => { waitFor(() => { render(<QueryClientProvider client={queryClient}><Comp1 /></QueryClientProvider>); expect(screen.getByTestId('loading', {}, { timeout: 2000 })).toBeInTheDocument(); }); }); });

¿Algunas ideas? esto verifica la respuesta de una llamada api async/await.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Es un problema asíncrono, debe agregar async , wait :

 it('Should wait for response', async () => { render( <QueryClientProvider client={queryClient}> <Comp1 /> </QueryClientProvider> ); await waitFor(() => { expect(screen.getByTestId('loading', {})).toBeInTheDocument(); }); });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!