From ddf1a26179007a31df7ccc942ef308efb4c535da Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Wed, 19 Aug 2026 00:34:42 -0700 Subject: [PATCH 1/2] test(expo): wait for native bootstrap before asserting 401 recovery --- .changeset/soft-poems-repeat.md | 2 ++ .../__tests__/ClerkProvider.nativeClientSync.test.tsx | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/soft-poems-repeat.md diff --git a/.changeset/soft-poems-repeat.md b/.changeset/soft-poems-repeat.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/soft-poems-repeat.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/expo/src/provider/__tests__/ClerkProvider.nativeClientSync.test.tsx b/packages/expo/src/provider/__tests__/ClerkProvider.nativeClientSync.test.tsx index 3289e535f5c..0a8aa253e55 100644 --- a/packages/expo/src/provider/__tests__/ClerkProvider.nativeClientSync.test.tsx +++ b/packages/expo/src/provider/__tests__/ClerkProvider.nativeClientSync.test.tsx @@ -1564,6 +1564,11 @@ describe('ClerkProvider native client sync', () => { expect(mocks.clerkInstance.handleUnauthenticated).not.toBe(originalHandleUnauthenticated); }); + // Bootstrap's suppressed device token write would swallow the rotation below. + await act(async () => { + await waitForPendingJsToNativeSync(); + }); + // Drop the client fetches the bootstrap already made; only the 401 handling matters here. fetchClient.mockClear(); @@ -1618,6 +1623,11 @@ describe('ClerkProvider native client sync', () => { expect(mocks.clerkInstance.handleUnauthenticated).not.toBe(originalHandleUnauthenticated); }); + // Bootstrap fetches the client too, and that fetch fails here, so drain its retries first. + await act(async () => { + await waitForPendingJsToNativeSync().catch(() => undefined); + }); + fetchClient.mockClear(); await act(async () => { From 83fca4aa957e009f6f7d178c850f37564b15c831 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Wed, 19 Aug 2026 09:14:12 -0700 Subject: [PATCH 2/2] test(expo): assert the expected bootstrap sync rejection --- .../provider/__tests__/ClerkProvider.nativeClientSync.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/expo/src/provider/__tests__/ClerkProvider.nativeClientSync.test.tsx b/packages/expo/src/provider/__tests__/ClerkProvider.nativeClientSync.test.tsx index 0a8aa253e55..ee2ff2a4d60 100644 --- a/packages/expo/src/provider/__tests__/ClerkProvider.nativeClientSync.test.tsx +++ b/packages/expo/src/provider/__tests__/ClerkProvider.nativeClientSync.test.tsx @@ -1625,7 +1625,7 @@ describe('ClerkProvider native client sync', () => { // Bootstrap fetches the client too, and that fetch fails here, so drain its retries first. await act(async () => { - await waitForPendingJsToNativeSync().catch(() => undefined); + await expect(waitForPendingJsToNativeSync()).rejects.toThrow('stale session 401'); }); fetchClient.mockClear();