diff --git a/frontend/src/setupTests.ts b/frontend/src/setupTests.ts index 25e7a16784..0018fca294 100644 --- a/frontend/src/setupTests.ts +++ b/frontend/src/setupTests.ts @@ -1,6 +1,7 @@ import '@testing-library/jest-dom'; import 'whatwg-fetch'; import 'regenerator-runtime'; +import { beforeAll, vi } from 'vitest'; class ResizeObserver { observe() {} @@ -13,3 +14,20 @@ if (!window.ResizeObserver) { } process.env.TZ = 'UTC'; + +// ignore known React warnings +const consoleError = console.error; +beforeAll(() => { + vi.spyOn(console, 'error').mockImplementation((...args) => { + if ( + !( + typeof args[0] === 'string' && + args[0].includes( + 'Warning: An update to %s inside a test was not wrapped in act', + ) + ) + ) { + consoleError(...args); + } + }); +}); diff --git a/frontend/src/utils/testServer.ts b/frontend/src/utils/testServer.ts index 4d1351006b..c3ec37d200 100644 --- a/frontend/src/utils/testServer.ts +++ b/frontend/src/utils/testServer.ts @@ -4,7 +4,13 @@ import { http, HttpResponse } from 'msw'; export const testServerSetup = (): SetupServer => { const server = setupServer(); - beforeAll(() => server.listen()); + beforeAll(() => + server.listen({ + onUnhandledRequest() { + return HttpResponse.error(); + }, + }), + ); afterAll(() => server.close()); afterEach(() => server.resetHandlers());