I have the bellow test, based on the test documentation , but when I run yarn test, I’m getting some errors, why that?
errors: You are trying to access a property or method of the Jest environment after it has been torn down. : > _getFakeTimers().useRealTimers();
Call retries were exceeded
at ChildProcessWorker.initialize
the test:
test('should render mock graphql responses', async () => {
jest.useFakeTimers()
const ticketMock = {
request: {
query: GET_TICKETS,
},
result: {
data: {
tickets: [
{
id: 10,
title: 'Hello',
},
],
},
},
}
const { getByText } = render(<Ticket />, {
graphql: { mocks: [ticketMock] },
})
expect(getByText(/Loading/)).toBeDefined()
await waitFor(() => { getByText})
await flushPromises()
jest.runAllTimers()
expect(getByText(/Hello/)).toBeDefined()
})
Does anyone know how I solve this? in react-apollo documentation only has references to test using the ql method from apollo-client, nothing about the react-apollo and their useQuery methods.