2023-05-27 12:36:18 +03:00
|
|
|
import 'vitest-canvas-mock';
|
|
|
|
import 'chart.js/auto';
|
2023-05-27 13:29:03 +03:00
|
|
|
import type { TestingLibraryMatchers } from '@testing-library/jest-dom/matchers';
|
2023-05-27 12:36:18 +03:00
|
|
|
import matchers from '@testing-library/jest-dom/matchers';
|
|
|
|
import { cleanup } from '@testing-library/react';
|
|
|
|
import ResizeObserver from 'resize-observer-polyfill';
|
|
|
|
import { afterEach, expect } from 'vitest';
|
|
|
|
|
2023-05-27 13:29:03 +03:00
|
|
|
// Workaround for TypeScript error: https://github.com/testing-library/jest-dom/issues/439#issuecomment-1536524120
|
|
|
|
declare module 'vitest' {
|
|
|
|
interface Assertion<T = any> extends jest.Matchers<void, T>, TestingLibraryMatchers<T, void> {}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Extends Vitest's expect method with methods from react-testing-library
|
2023-05-27 12:36:18 +03:00
|
|
|
expect.extend(matchers);
|
|
|
|
|
|
|
|
afterEach(() => {
|
2023-05-27 13:29:03 +03:00
|
|
|
// Clears all mocks after every test
|
|
|
|
vi.clearAllMocks();
|
|
|
|
// runs a cleanup after each test case (e.g. clearing jsdom)
|
2023-05-27 12:36:18 +03:00
|
|
|
cleanup();
|
|
|
|
});
|
|
|
|
|
|
|
|
(global as any).ResizeObserver = ResizeObserver;
|
|
|
|
(global as any).scrollTo = () => {};
|
|
|
|
(global as any).prompt = () => {};
|
|
|
|
(global as any).matchMedia = (media: string) => ({ matches: false, media });
|