axios-hooks
axios-hooks copied to clipboard
Response contamination when using axios-hooks with testing-library due to LRU cache
The useAxios hook uses a LRU cache by default. When writing tests, the cache is not invalidated between tests (at least not with testing-library). This makes previous responses "bleed" into subsequent tests. This behavior can easily be disabled in the test suite setup with the following:
beforeAll(() => {
useAxios.configure({cache: false})
})
I'm not sure if it deserves a place in the docs, but I thought I would mention it here to -- possibly -- save someone a bit of time.
Reference to the issue I originally landed on: https://github.com/testing-library/react-testing-library/issues/716
It would be great to include this in the docs. Would you like to send a PR?
Yes, I'll work on one 👍
@eelkevdbos any updates?
@simoneb, is this still relevant? If it is, I can make some time today for a PR on the docs.
@eelkevdbos it would be great if you could do it!