Skip to content

test(expo): add behavioral native client sync suite - #9954

Merged
wobsoriano merged 5 commits into
mainfrom
mike/expo-native-sync-behavior-tests
Oct 20, 2026
Merged

wobsoriano merged 5 commits into
mainfrom
mike/expo-native-sync-behavior-tests

Conversation

@mikepitre

@mikepitre mikepitre commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Second PR of the sync stack: main ← #9957 ← this PR ← #9956 ← #9962. Tests only. Adds an engine-agnostic behavioral test suite for the @clerk/expo JS <-> native client sync, so it can gate the upcoming replacement of the sync engine (native owns the device token, payload-free invalidations in both directions).

The suite lives in packages/expo/src/provider/__tests__/nativeClientSyncBehavior/ and asserts only user-observable outcomes: the JS signed-in state and active session, the native token and client view, request and refresh counts, the absence of signed-out emissions during session switches, and errors surfaced through the sync barrier. It is backed by:

  • FakeClerkServer: one Frontend API shared by both SDKs, with clients keyed by device token.
  • FakeNativeClerk: the native SDK's persisted token, its client view, and native-originated actions and change notifications.
  • FakeClerk: a stand-in for the clerk-js instance returned by getClerkInstance, using the same surface the existing ClerkProvider tests mock. It talks to the fake Frontend API through the token cache it is built with, like createClerkInstance.
  • currentEngineAdapter: renderWithNativeSync(scenario) for today's engine. It keeps today's native module contract (configure, getClientToken, syncClientStateFromJs, clerkNativeClientChanged payloads and sourceId tags) out of the tests. To run the suite against a new engine, only the export in index.ts needs to point at a new adapter.

Two behaviors the current engine does not meet yet are kept as it.fails under "known gaps in the current engine". They flip to it in #9956, which is the proof the new engine fixes them:

  • JS starting with a stale device token replaces native's signed-in token, because configure adopts the JS bearer token.
  • If JS and native rotate the device token at the same time, the two sides end up on different tokens.

The existing ClerkProvider.nativeClientSync and coordinator tests are unchanged.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other: tests

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: eae370c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

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

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

@vercel

vercel Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Oct 20, 2026 4:02am UTC
swingset Ready Ready Preview Oct 20, 2026 4:02am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository YAML (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: c7c379f7-c8e3-4ddf-9764-b3b6fc5c91ec
📥 Commits

Reviewing files that changed from the base of the PR and between 378697d and 668dc84.

📒 Files selected for processing: 1
  • packages/expo/src/provider/__tests__/nativeClientSyncBehavior/currentEngineAdapter.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 9 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

📝 Walkthrough

Adds test support for Expo native client synchronization. The in-memory server and JavaScript and native client fakes model client, session, token, and request state. The harness configures the provider and native module, then exposes synchronization and lifecycle controls. Behavior tests cover sign-in, sign-out, session changes, token rotation, startup, synchronization barriers, refresh failures, and disabled synchronization. Two expected-failure tests cover stale JavaScript tokens and concurrent token rotations.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 668dc

The test-harness change is mergeable after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the addition of a behavioral native client synchronization test suite for Expo.
Description check Passed The description directly explains the new engine-agnostic native synchronization tests, their coverage, test fakes, adapter design, and known gaps.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9954

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9954

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9954

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9954

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9954

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9954

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9954

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9954

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@9954

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9954

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@9954

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9954

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9954

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9954

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9954

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9954

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@9954

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9954

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9954

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9954

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9954

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9954

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9954

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9954

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9954

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9954

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9954

commit: eae370c

@mikepitre
mikepitre force-pushed the mike/expo-native-sync-behavior-tests branch from 544222b to 8c5d287 Compare September 27, 2026 14:50
@mikepitre
mikepitre changed the base branch from main to mike/expo-native-sync-bridge September 27, 2026 14:50
@mikepitre
mikepitre force-pushed the mike/expo-native-sync-behavior-tests branch from 8c5d287 to 44460ec Compare September 28, 2026 19:35
@mikepitre
mikepitre force-pushed the mike/expo-native-sync-behavior-tests branch from 44460ec to 9e19e6d Compare September 28, 2026 20:23
@mikepitre
mikepitre force-pushed the mike/expo-native-sync-behavior-tests branch from 9e19e6d to 93d91bd Compare September 29, 2026 22:11
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-10-20T04:03:54.724Z

Summary

Metric Count
Packages analyzed 20
Packages with changes 0
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 0

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on eae370c.

Adds an engine-agnostic behavior suite for JS <-> native client sync,
backed by a fake Frontend API, a fake native SDK, and a clerk-js
stand-in, with a thin adapter that drives today's ClerkProvider engine.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@wobsoriano
wobsoriano force-pushed the mike/expo-native-sync-behavior-tests branch from a3824af to 378697d Compare October 19, 2026 20:59
mikepitre added a commit that referenced this pull request Oct 19, 2026
…tive-sync-engine

GitHub rebased #9954 onto main after #9957 merged; its commit's content is already here.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@wobsoriano wobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧪 looks good!

pushed changes:

  • suite now runs the real createClerkInstance
  • removed the barrier tests, which covered an API with no production caller
  • fake native module configures through configureWithOptions like real binaries do

@wobsoriano
wobsoriano merged commit 56f6356 into main Oct 20, 2026
58 checks passed
@wobsoriano
wobsoriano deleted the mike/expo-native-sync-behavior-tests branch October 20, 2026 04:28

This branch was successfully deployed

2 active deployments
Preview – swingset — eae370c9 Deployed Oct 20, 2026 by vercel[bot]
Preview – clerk-js-sandbox — eae370c9 Deployed Oct 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants