2022-02-18 09:51:10 +01:00
|
|
|
import '@testing-library/jest-dom';
|
2022-05-05 17:15:22 +02:00
|
|
|
import 'whatwg-fetch';
|
2022-05-25 11:12:53 +02:00
|
|
|
import 'regenerator-runtime';
|
2024-09-25 12:56:09 +02:00
|
|
|
import { beforeAll, vi } from 'vitest';
|
2018-02-16 20:45:05 +01:00
|
|
|
|
2023-10-19 16:50:37 +02:00
|
|
|
class ResizeObserver {
|
|
|
|
observe() {}
|
|
|
|
unobserve() {}
|
|
|
|
disconnect() {}
|
|
|
|
}
|
|
|
|
|
2024-10-18 15:38:46 +02:00
|
|
|
class IntersectionObserver {
|
|
|
|
root: any;
|
|
|
|
rootMargin: any;
|
|
|
|
thresholds: any;
|
|
|
|
|
|
|
|
observe() {}
|
|
|
|
unobserve() {}
|
|
|
|
disconnect() {}
|
|
|
|
takeRecords() {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 16:50:37 +02:00
|
|
|
if (!window.ResizeObserver) {
|
|
|
|
window.ResizeObserver = ResizeObserver;
|
|
|
|
}
|
|
|
|
|
2024-10-18 15:38:46 +02:00
|
|
|
if (!window.IntersectionObserver) {
|
|
|
|
window.IntersectionObserver = IntersectionObserver;
|
|
|
|
}
|
|
|
|
|
2019-10-09 19:58:49 +02:00
|
|
|
process.env.TZ = 'UTC';
|
2024-09-25 12:56:09 +02:00
|
|
|
|
2024-10-17 14:02:47 +02:00
|
|
|
const errorsToIgnore = [
|
|
|
|
'Warning: An update to %s inside a test was not wrapped in act',
|
|
|
|
"Failed to create chart: can't acquire context from the given item",
|
|
|
|
];
|
|
|
|
|
|
|
|
const warningsToIgnore = [
|
|
|
|
'[MSW] Found a redundant usage of query parameters in the request handler URL for',
|
|
|
|
'MUI: You have provided an out-of-range value',
|
|
|
|
];
|
|
|
|
|
|
|
|
const logsToIgnore = ['An exception was caught and handled.'];
|
|
|
|
|
2024-09-25 12:56:09 +02:00
|
|
|
// ignore known React warnings
|
|
|
|
const consoleError = console.error;
|
2024-10-17 14:02:47 +02:00
|
|
|
const consoleWarn = console.warn;
|
|
|
|
const consoleLog = console.log;
|
2024-09-25 12:56:09 +02:00
|
|
|
beforeAll(() => {
|
2024-10-17 14:02:47 +02:00
|
|
|
const shouldIgnore = (messagesToIgnore: string[], args: any[]) =>
|
|
|
|
typeof args[0] === 'string' &&
|
|
|
|
messagesToIgnore.some((msg) => args[0].includes(msg));
|
|
|
|
|
2024-09-25 12:56:09 +02:00
|
|
|
vi.spyOn(console, 'error').mockImplementation((...args) => {
|
2024-10-17 14:02:47 +02:00
|
|
|
if (!shouldIgnore(errorsToIgnore, args)) {
|
2024-09-25 12:56:09 +02:00
|
|
|
consoleError(...args);
|
|
|
|
}
|
|
|
|
});
|
2024-10-17 14:02:47 +02:00
|
|
|
vi.spyOn(console, 'warn').mockImplementation((...args) => {
|
|
|
|
if (!shouldIgnore(warningsToIgnore, args)) {
|
|
|
|
consoleWarn(...args);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
vi.spyOn(console, 'log').mockImplementation((...args) => {
|
|
|
|
if (!shouldIgnore(logsToIgnore, args)) {
|
|
|
|
consoleLog(...args);
|
|
|
|
}
|
|
|
|
});
|
2024-09-25 12:56:09 +02:00
|
|
|
});
|