20 lines
564 B
TypeScript
20 lines
564 B
TypeScript
import '@testing-library/jest-dom/vitest';
|
||
|
||
// jsdom lacks IntersectionObserver; Framer Motion's `whileInView` needs it.
|
||
if (typeof window !== 'undefined' && !('IntersectionObserver' in window)) {
|
||
class IntersectionObserverStub {
|
||
observe() {}
|
||
unobserve() {}
|
||
disconnect() {}
|
||
takeRecords() {
|
||
return [];
|
||
}
|
||
root = null;
|
||
rootMargin = '';
|
||
thresholds = [];
|
||
}
|
||
// @ts-expect-error – installing stub on window
|
||
window.IntersectionObserver = IntersectionObserverStub;
|
||
global.IntersectionObserver = IntersectionObserverStub;
|
||
}
|