-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathjest.setup.js
More file actions
42 lines (37 loc) · 966 Bytes
/
jest.setup.js
File metadata and controls
42 lines (37 loc) · 966 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
30
31
32
33
34
35
36
37
38
39
40
41
42
import '@testing-library/jest-dom'
// Mock IntersectionObserver
global.IntersectionObserver = class IntersectionObserver {
constructor() {}
disconnect() {}
observe() {}
unobserve() {}
}
// Mock ResizeObserver
global.ResizeObserver = class ResizeObserver {
constructor() {}
disconnect() {}
observe() {}
unobserve() {}
}
// Mock scrollTo for testing scroll behavior
Object.defineProperty(window, 'scrollTo', {
value: jest.fn(),
writable: true
})
// Mock HTMLElement scrollTo
Object.defineProperty(HTMLElement.prototype, 'scrollTo', {
value: jest.fn(),
writable: true
})
// Suppress console.error for known React warnings in tests
const originalError = console.error;
console.error = (...args) => {
if (
typeof args[0] === 'string' &&
(args[0].includes('Received `true` for a non-boolean attribute `fill`') ||
args[0].includes('non-boolean attribute `fill`'))
) {
return;
}
originalError.call(console, ...args);
};