mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
test: reduce noise from test warnings (#8251)
This commit is contained in:
parent
cdb1297246
commit
e680921517
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -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());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user