Skip to content

Commit

Permalink
fix: clear observers after each test run (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
thebuilder authored Nov 19, 2021
1 parent f1e123b commit bc55d20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/observe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ObserverInstanceCallback } from './index';

const ObserverMap = new Map<
export const ObserverMap = new Map<
string,
{
id: string;
Expand Down
2 changes: 2 additions & 0 deletions src/test-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { act } from 'react-dom/test-utils';
import { ObserverMap } from './observe';

type Item = {
callback: IntersectionObserverCallback;
Expand Down Expand Up @@ -48,6 +49,7 @@ afterEach(() => {
// @ts-ignore
global.IntersectionObserver.mockClear();
observers.clear();
ObserverMap.clear();
});

function triggerIntersection(
Expand Down

1 comment on commit bc55d20

@vercel
Copy link

@vercel vercel bot commented on bc55d20 Nov 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.