-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathsetupTests.ts
41 lines (35 loc) · 1.37 KB
/
setupTests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// (C) 2023-2024 GoodData Corporation
import { cleanup } from "@testing-library/react";
import { afterEach, expect, vi } from "vitest";
/**
* In order to be able to use extended matchers like "toBeInDocument", we use vitest-dom instead of testing-library/jest-dom.
* The reason for that is that there were type conflicts between vitest and types/jest as dependency of testing-library/jest-dom.
*/
// eslint-disable-next-line import/no-extraneous-dependencies
import * as matchers from "vitest-dom/dist/matchers.js";
// eslint-disable-next-line import/no-extraneous-dependencies
import { TestingLibraryMatchers } from "vitest-dom/dist/matchers.js";
/**
* Exports of types and matchers of vitest-dom is currently broken we need export matchers from dist and define types manually
*/
declare module "vitest" {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface Assertion<T = any> extends TestingLibraryMatchers<typeof expect.stringContaining, T> {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface AsymmetricMatchersContaining extends TestingLibraryMatchers<unknown, unknown> {}
}
global.ResizeObserver = class ResizeObserver {
observe() {
return null;
}
unobserve() {
return null;
}
disconnect() {
return null;
}
};
expect.extend(matchers);
afterEach(() => {
cleanup();
});