fix(clerk-js): Fix act output in tests [SDK-1054]#2289
Conversation
🦋 Changeset detectedLatest commit: 3fa0fe9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
panteliselef
left a comment
There was a problem hiding this comment.
🧹 No more "act" errors 🎉
| await waitFor(() => { | ||
| expect(getByRole('tab', { name: 'Requests' })).toBeInTheDocument(); | ||
| }); | ||
| await waitForLoadingCompleted(container); |
| await waitForLoadingCompleted(container); | ||
|
|
||
| const pagination = getByText(/displaying/i).closest('p'); | ||
| expect(pagination?.textContent).toEqual('Displaying 1 – 5 of 5'); |
| }); | ||
| const { queryByRole } = await act(() => render(<OrganizationSwitcher />, { wrapper })); | ||
|
|
||
| jest.advanceTimersByTime(15000); |
There was a problem hiding this comment.
Do u remember what was the issue here ?
There was a problem hiding this comment.
I've updated this, but a lot of the issues boil down to useDelayedVisibility and its use of setTimeout.
|
|
||
| const { createFixtures } = bindCreateFixtures('OrganizationProfile'); | ||
|
|
||
| async function waitForLoadingCompleted(container: HTMLElement) { |
There was a problem hiding this comment.
❓ Is it possible that the issue is related to using getBy... instead of findBy... which is a combination of waitFor and getBy...?
I would prefer we avoid mingling the logic to wait for a loader to be removed with the usage of waitForLoadingCompleted and depend on findBy... instead.
* fix(clerk-js): Fix unhandled act errors [SDK-1054] * chore(*): Add changeset * chore(clerk-js): Add missing awaits * chore(clerk-js): Minor updates
Description
Fixes
act(and oneconsole.log) output in Jest tests forclerk-js.SDK-1054
Checklist
npm testruns as expected.npm run buildruns as expected.Type of change
Packages affected
@clerk/backend@clerk/chrome-extension@clerk/clerk-js@clerk/clerk-expo@clerk/fastifygatsby-plugin-clerk@clerk/localizations@clerk/nextjs@clerk/clerk-react@clerk/remix@clerk/clerk-sdk-node@clerk/shared@clerk/themes@clerk/typesbuild/tooling/chore