diff --git a/__mocks__/axios.ts b/__mocks__/axios.ts index 91ed4589..2e6257f2 100644 --- a/__mocks__/axios.ts +++ b/__mocks__/axios.ts @@ -1,5 +1,3 @@ -// TODO: move __mocks__ folder back to root once facebook/create-react-app#7539 is fixed - const requests = { get: vi.fn((path) => { if (path === '/settings.json') { diff --git a/src/routing/routing.component.test.tsx b/src/routing/routing.component.test.tsx index 856ad0ce..da28c973 100644 --- a/src/routing/routing.component.test.tsx +++ b/src/routing/routing.component.test.tsx @@ -67,7 +67,6 @@ describe('Routing component', () => { afterEach(() => { vi.clearAllMocks(); - vi.useRealTimers(); }); it('renders component with no plugin routes', () => { @@ -393,7 +392,7 @@ describe('Routing component', () => { }); it("single-spa reloads a plugin when it hasn't loaded for some reason", () => { - vi.useFakeTimers(); + vi.useFakeTimers({ shouldAdvanceTime: true }); state.scigateway.authorisation.provider = new TestAuthProvider('logged in'); state.scigateway.siteLoading = false; state.scigateway.plugins = [ @@ -421,9 +420,11 @@ describe('Routing component', () => { 'test_plugin_name' ); - expect(clearIntervalSpy).toHaveBeenCalledWith(expect.any(Number)); + // Could not use toHaveBeenCalledWith(expect.any(Number)) as it is a mocked object in this test + expect(clearIntervalSpy).toHaveBeenCalled(); // restore clearInterval to avoid errors with it not being a function on unmount clearIntervalSpy.mockRestore(); + vi.useRealTimers(); }); }); diff --git a/src/tour/tour.component.test.tsx b/src/tour/tour.component.test.tsx index 46f5e7bf..03cbedb1 100644 --- a/src/tour/tour.component.test.tsx +++ b/src/tour/tour.component.test.tsx @@ -145,7 +145,7 @@ describe('Tour component', () => { content: 'Plugin link test', }, ]; - vi.useFakeTimers(); + vi.useFakeTimers({ shouldAdvanceTime: true }); const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime, });