shlink-web-client/config/test/setupTests.ts

21 lines
725 B
TypeScript
Raw Normal View History

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