Skip to content

Commit

Permalink
add mock properties in test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
simonc56 committed Nov 25, 2024
1 parent 46401b9 commit d142db9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable class-methods-use-this */
/* eslint-disable import/no-extraneous-dependencies */
import * as matchers from '@testing-library/jest-dom/matchers';
import '@testing-library/jest-dom/vitest';
Expand All @@ -21,3 +22,24 @@ Object.defineProperty(window, 'matchMedia', {
dispatchEvent: () => {},
}),
});

// Mock IntersectionObserver and ResizeObserver
class MockObserver {
observe() {}

unobserve() {}

disconnect() {}
}

Object.defineProperty(window, 'IntersectionObserver', {
writable: true,
configurable: true,
value: MockObserver,
});

Object.defineProperty(window, 'ResizeObserver', {
writable: true,
configurable: true,
value: MockObserver,
});

0 comments on commit d142db9

Please sign in to comment.