You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: