toss / overlay-kit

The simplest and most intuitive way to manage overlays in React.
https://overlay-kit.slash.page
MIT License
295 stars 30 forks source link

test: add afterEach unmountAll() #45

Closed jgjgill closed 4 months ago

jgjgill commented 4 months ago

When I tried to add test code, the old test dependencies were left behind 😂.

event.test.tsx

  ... // Existing code
  // Test code to add
  it('test', () => {
    const wrapper = ({ children }: PropsWithChildren) => <OverlayProvider>{children}</OverlayProvider>;

    const Component = () => {
      const overlayData = useOverlayData();
      console.log(overlayData);

      return null;
    };

    const renderComponent = render(<Component />, { wrapper });
  });

To solve this, I added the following code

 afterEach(() => {
   overlay.unmountAll();
 });
changeset-bot[bot] commented 4 months ago

⚠️ No Changeset found

Latest commit: c47be1035efd290979165ac050b81d4f5a266b52

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/jgjgill/overlay-kit/new/test/afterEach?filename=.changeset/tender-adults-compare.md&value=---%0A%22overlay-kit%22%3A%20patch%0A---%0A%0Atest%3A%20add%20afterEach%20unmountAll()%0A)

vercel[bot] commented 4 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
overlay-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2024 10:38am