Open MrAngry777 opened 2 years ago
I think I have the same issue.
same issue
same
Same issue
In my case, after deleting jest.restoreAllMocks
and jest.resetAllMocks
in afterEach
, it worked.
I think jest.resetAllMocks
and jest.restoreAllMocks
also resets axios mock, and in the test suite No-mocked axios instance is used.
I am using axios-mock-adapter to test my components. The strange thing is that only a single test can be run successfully because the next one always breaks. Each test works fine if run individually.
Here is my setup.
util.ts
The exported client is used internally by all my components
component.test.tsx
The second test (I mean the second that is run not the order they are defined) always breaks because of an error in the useEffect() hook which throws:
And this is the function that breaks:
BTW I am aware those tests look the same. That is exactly the point. Earlier there was a delay introduced in the second one but while debugging I changed them to pinpoint the problem but with no luck.