-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathjest.setup.js
More file actions
42 lines (37 loc) · 1.25 KB
/
jest.setup.js
File metadata and controls
42 lines (37 loc) · 1.25 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
// Mock canvas methods to prevent errors in tests
// This is a workaround for the fact that JSDOM does not support canvas methods like getContext.
import 'jest-canvas-mock';
// Set up the global that cc-digital-interactions expects
global.AGENTX_SERVICE = {};
// Web components used in @momentum-design imports rely on browser-only APIs like attachInternals.
// Jest (via JSDOM) doesn't support these, causing runtime errors in tests.
// We mock these methods on HTMLElement to prevent test failures.
window.HTMLElement.prototype.attachInternals = function () {
return {
setValidity: () => {},
checkValidity: () => true,
reportValidity: () => true,
setFormValue: () => {},
};
};
// Mock scrollIntoView for TabList component
window.HTMLElement.prototype.scrollIntoView = function () {};
// Mock IntersectionObserver for infinite scroll tests
global.IntersectionObserver = class IntersectionObserver {
constructor(callback, options) {
this.callback = callback;
this.options = options;
}
observe() {}
unobserve() {}
disconnect() {}
};
// Mock ResizeObserver for TabList component
global.ResizeObserver = class ResizeObserver {
constructor(callback) {
this.callback = callback;
}
observe() {}
unobserve() {}
disconnect() {}
};