Skip to content

Commit

Permalink
Merge pull request #679 from karpiuMG/main
Browse files Browse the repository at this point in the history
fix: test-utils - execute mockClear method only when it exists
  • Loading branch information
thebuilder authored Jun 5, 2024
2 parents dceba7f + 712ae37 commit 01c9992
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ export function setupIntersectionMocking(mockFn: typeof jest.fn) {
* Reset the IntersectionObserver mock to its initial state, and clear all the elements being observed.
*/
export function resetIntersectionMocking() {
// @ts-ignore
if (global.IntersectionObserver) global.IntersectionObserver.mockClear();
if (
global.IntersectionObserver &&
"mockClear" in global.IntersectionObserver &&
typeof global.IntersectionObserver.mockClear === "function"
) {
global.IntersectionObserver.mockClear();
}
observers.clear();
}

Expand Down

0 comments on commit 01c9992

Please sign in to comment.