-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.setup.ts
More file actions
29 lines (28 loc) · 909 Bytes
/
vitest.setup.ts
File metadata and controls
29 lines (28 loc) · 909 Bytes
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
/* eslint-disable @typescript-eslint/no-explicit-any */
import '@testing-library/jest-dom/vitest'
import '@formatjs/intl-datetimeformat/polyfill'
import '@formatjs/intl-datetimeformat/locale-data/en'
import '@formatjs/intl-datetimeformat/add-all-tz'
// Polyfill missing Range geometry APIs in jsdom so selection sync doesn't crash
const RangeProto: any = (global as any).Range?.prototype
if (RangeProto) {
if (!RangeProto.getClientRects) {
RangeProto.getClientRects = () => []
}
if (!RangeProto.getBoundingClientRect) {
RangeProto.getBoundingClientRect = () =>
typeof (global as any).DOMRect !== 'undefined'
? new (global as any).DOMRect(0, 0, 0, 0)
: ({
x: 0,
y: 0,
width: 0,
height: 0,
top: 0,
left: 0,
bottom: 0,
right: 0,
toJSON() {}
} as any)
}
}