-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetupTests.ts
More file actions
23 lines (20 loc) · 867 Bytes
/
setupTests.ts
File metadata and controls
23 lines (20 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import * as matchers from '@testing-library/jest-dom/matchers'
import { cleanup } from '@testing-library/react'
import { afterEach, expect } from 'vitest'
expect.extend(matchers)
// ResizeObserver is not implemented in jsdom but required by @floating-ui (Chakra menus/popovers).
// Use a real class rather than vi.fn() so vi.restoreAllMocks() in test files cannot clear it.
if (typeof globalThis.ResizeObserver === 'undefined') {
class ResizeObserver {
// biome-ignore lint/suspicious/noExplicitAny: stub for jsdom test environment
observe(_target: any) {}
// biome-ignore lint/suspicious/noExplicitAny: stub for jsdom test environment
unobserve(_target: any) {}
disconnect() {}
}
// @ts-expect-error ResizeObserver is not in the Node/jsdom type definitions
globalThis.ResizeObserver = ResizeObserver
}
afterEach(() => {
cleanup()
})