Clear React Query cache before each test

environments/review-improve-tr-g862o5/deployments/747
Justin 2022-08-10 10:30:58 -04:00
rodzic b2530dadd5
commit 968ec3a7d2
2 zmienionych plików z 9 dodań i 1 usunięć

Wyświetl plik

@ -37,6 +37,8 @@ const queryClient = new QueryClient({
},
defaultOptions: {
queries: {
staleTime: 0,
cacheTime: Infinity,
retry: false,
},
},
@ -123,4 +125,5 @@ export {
rootReducer,
mockWindowProperty,
createTestStore,
queryClient,
};

Wyświetl plik

@ -2,9 +2,14 @@
import { __clear as clearApiMocks } from '../__mocks__/api';
import { queryClient } from './test-helpers';
// API mocking
jest.mock('soapbox/api');
afterEach(() => clearApiMocks());
afterEach(() => {
clearApiMocks();
queryClient.clear();
});
// Mock IndexedDB
// https://dev.to/andyhaskell/testing-your-indexeddb-code-with-jest-2o17