Skip to content

Commit 01c9992

Browse files
authored
Merge pull request #679 from karpiuMG/main
fix: test-utils - execute mockClear method only when it exists
2 parents dceba7f + 712ae37 commit 01c9992

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/test-utils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,13 @@ export function setupIntersectionMocking(mockFn: typeof jest.fn) {
9696
* Reset the IntersectionObserver mock to its initial state, and clear all the elements being observed.
9797
*/
9898
export function resetIntersectionMocking() {
99-
// @ts-ignore
100-
if (global.IntersectionObserver) global.IntersectionObserver.mockClear();
99+
if (
100+
global.IntersectionObserver &&
101+
"mockClear" in global.IntersectionObserver &&
102+
typeof global.IntersectionObserver.mockClear === "function"
103+
) {
104+
global.IntersectionObserver.mockClear();
105+
}
101106
observers.clear();
102107
}
103108

0 commit comments

Comments
 (0)