-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrstest.shared.setup.ts
More file actions
44 lines (41 loc) · 1.29 KB
/
Copy pathrstest.shared.setup.ts
File metadata and controls
44 lines (41 loc) · 1.29 KB
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
42
43
44
import { expect } from "@rstest/core";
const { default: defaultMatchers, ...namedMatchers } = await import("@testing-library/jest-dom/matchers");
expect.extend(defaultMatchers ?? namedMatchers);
class ResizeObserverMock implements ResizeObserver {
observe = (): void => {
// The simulated DOM has no layout engine.
};
unobserve = (): void => {
// The simulated DOM has no layout engine.
};
disconnect = (): void => {
// The simulated DOM has no layout engine.
};
}
globalThis.ResizeObserver ??= ResizeObserverMock;
globalThis.matchMedia = (query: string): MediaQueryList => ({
addEventListener() {
// Media-query changes are outside the simulated DOM's layout model.
},
addListener() {
// Deprecated listener retained for libraries that still call it.
},
dispatchEvent: () => false,
matches: false,
media: query,
onchange: null,
removeEventListener() {
// Media-query changes are outside the simulated DOM's layout model.
},
removeListener() {
// Deprecated listener retained for libraries that still call it.
},
});
globalThis.scrollTo = () => {
// The simulated DOM has no layout engine.
};
if (typeof Element !== "undefined") {
Element.prototype.scrollIntoView ??= function scrollIntoView() {
// The simulated DOM has no layout engine.
};
}