From c9aca7a03ab2ac7a8ab382fe8258d6683dafb19b Mon Sep 17 00:00:00 2001 From: panteliselef Date: Tue, 31 Oct 2023 19:05:36 +0200 Subject: [PATCH] test(clerk-js): Clean up `act()` errors --- .changeset/pretty-mice-share.md | 5 +++++ .../__tests__/LeaveOrganizationPage.test.tsx | 11 ++++++----- .../__tests__/OrganizationMembers.test.tsx | 7 ++++--- 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 .changeset/pretty-mice-share.md diff --git a/.changeset/pretty-mice-share.md b/.changeset/pretty-mice-share.md new file mode 100644 index 0000000000..f0fad72806 --- /dev/null +++ b/.changeset/pretty-mice-share.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Internal cleanup from errors in console regarding `act()`. diff --git a/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/LeaveOrganizationPage.test.tsx b/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/LeaveOrganizationPage.test.tsx index ef4a673efa..e2bb6dba8d 100644 --- a/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/LeaveOrganizationPage.test.tsx +++ b/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/LeaveOrganizationPage.test.tsx @@ -1,7 +1,8 @@ import type { DeletedObjectResource } from '@clerk/types'; import { describe, it } from '@jest/globals'; +import { waitFor } from '@testing-library/react'; -import { act, render } from '../../../../testUtils'; +import { render } from '../../../../testUtils'; import { CardStateProvider } from '../../../elements'; import { bindCreateFixtures } from '../../../utils/test/createFixtures'; import { LeaveOrganizationPage } from '../ActionConfirmationPage'; @@ -50,11 +51,11 @@ describe('LeaveOrganizationPage', () => { { wrapper }, ); - await userEvent.type(getByLabelText(/Confirmation/i), 'Org1'); - - act(async () => { + await waitFor(async () => { + await userEvent.type(getByLabelText(/Confirmation/i), 'Org1'); await userEvent.click(getByRole('button', { name: 'Leave organization' })); - expect(fixtures.clerk.user?.leaveOrganization).toHaveBeenCalledWith('Org1'); }); + + expect(fixtures.clerk.user?.leaveOrganization).toHaveBeenCalledWith('Org1'); }); }); diff --git a/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationMembers.test.tsx b/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationMembers.test.tsx index 9769161945..7fa4064839 100644 --- a/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationMembers.test.tsx +++ b/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationMembers.test.tsx @@ -1,8 +1,9 @@ import type { OrganizationInvitationResource, OrganizationMembershipResource } from '@clerk/types'; -import { describe, it } from '@jest/globals'; -import { render, waitFor } from '@testing-library/react'; +import { describe } from '@jest/globals'; +import { act, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { render } from '../../../../testUtils'; import { bindCreateFixtures } from '../../../utils/test/createFixtures'; import { runFakeTimers } from '../../../utils/test/runFakeTimers'; import { OrganizationMembers } from '../OrganizationMembers'; @@ -353,7 +354,7 @@ describe('OrganizationMembers', () => { }), ); - const { findByText } = render(, { wrapper }); + const { findByText } = await act(() => render(, { wrapper })); await waitFor(() => expect(fixtures.clerk.organization?.getMemberships).toHaveBeenCalled()); expect(await findByText('You')).toBeInTheDocument(); });