Skip to content

Commit

Permalink
test(clerk-js): Clean up act() errors
Browse files Browse the repository at this point in the history
  • Loading branch information
panteliselef committed Oct 31, 2023
1 parent d37d44a commit c9aca7a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-mice-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Internal cleanup from errors in console regarding `act()`.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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');
});
});
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -353,7 +354,7 @@ describe('OrganizationMembers', () => {
}),
);

const { findByText } = render(<OrganizationMembers />, { wrapper });
const { findByText } = await act(() => render(<OrganizationMembers />, { wrapper }));
await waitFor(() => expect(fixtures.clerk.organization?.getMemberships).toHaveBeenCalled());
expect(await findByText('You')).toBeInTheDocument();
});
Expand Down

0 comments on commit c9aca7a

Please sign in to comment.