diff --git a/src-ui/setup-jest.ts b/src-ui/setup-jest.ts index fbbb624db..de28ecb8b 100644 --- a/src-ui/setup-jest.ts +++ b/src-ui/setup-jest.ts @@ -119,6 +119,26 @@ Object.defineProperty(window, 'location', { value: { reload: jest.fn() }, }) +if (typeof IntersectionObserver === 'undefined') { + class MockIntersectionObserver { + constructor( + public callback: IntersectionObserverCallback, + public options?: IntersectionObserverInit + ) {} + + observe = jest.fn() + unobserve = jest.fn() + disconnect = jest.fn() + takeRecords = jest.fn() + } + + Object.defineProperty(window, 'IntersectionObserver', { + writable: true, + configurable: true, + value: MockIntersectionObserver, + }) +} + HTMLCanvasElement.prototype.getContext = < typeof HTMLCanvasElement.prototype.getContext >jest.fn()