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 { 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);
|
|
|
|
|
2023-08-14 13:15:57 +03:00
|
|
|
// Clear all mocks and cleanup DOM after every test
|
2023-05-27 12:36:18 +03:00
|
|
|
afterEach(() => {
|
2023-05-27 13:29:03 +03:00
|
|
|
vi.clearAllMocks();
|
2023-05-27 12:36:18 +03:00
|
|
|
cleanup();
|
|
|
|
});
|
|
|
|
|
|
|
|
(global as any).scrollTo = () => {};
|