Skip to content

test(mosaic): give each feature test its own fake FAPI host - #10183

Merged
alexcarpenter merged 1 commit into
mainfrom
carp/another-flake
Oct 9, 2026
Merged

alexcarpenter merged 1 commit into
mainfrom
carp/another-flake

Conversation

@alexcarpenter

Copy link
Copy Markdown
Member

Description

Mosaic feature tests share one MSW worker and, until now, one fake FAPI host. Each test creates a new Clerk that is never torn down, so a request a previous test's Clerk sends late (an in-flight fetch, a debounced search) can be matched by the next test's handlers. That is how organization-profile-requests.feature.test.tsx failed in this run: a holdRequests hold counted a members request left over from the previous test.

Each test now gets its own FAPI host. The setup file switches the host before every test, the publishable key is built from it, and a permanent fallback handler answers requests to any older host with a network error. A late request from a previous test fails instead of reaching the current test's handlers, and never goes to the real network. The unhandled-request check only looks at the current host.

fake-fapi-isolation.feature.test.tsx leaves a request in flight, and schedules one after the test ends, then checks the next test's handlers don't see either.

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: test infrastructure

@vercel

vercel Bot commented Oct 9, 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 9, 2026 9:00pm UTC
swingset Ready Ready Preview Oct 9, 2026 9:00pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b8fa912

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

@github-actions github-actions Bot added the mosaic label Oct 9, 2026
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: e9fa38c3-d4a6-426b-97d0-460941df7e34

📥 Commits

Reviewing files that changed from the base of the PR and between 23b1e0d and b8fa912.


📒 Files selected for processing (6)
  • .changeset/isolate-mosaic-fake-fapi.md
  • packages/mosaic/docs/testing.md
  • packages/mosaic/src/__tests__/feature/fake-fapi-isolation.feature.test.tsx
  • packages/mosaic/src/__tests__/feature/fake-fapi.ts
  • packages/mosaic/src/__tests__/feature/render.tsx
  • packages/mosaic/vitest.setup.browser.mts

🔗 Linked repositories identified

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


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



📝 Walkthrough

Walkthrough

The fake FAPI now uses a numbered host that changes before each browser test. Its worker allows requests to the current host and returns a network error for requests to other hosts. New tests cover in-flight and delayed requests crossing test boundaries. The testing documentation describes this behavior and retains the existing cleanup and failure checks.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Suggested reviewers: ephem


Merge Risk: ⚪ Minimal · up to b8fa9

No actionable merge-blocking issue is established; the change is ready for normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: assigning each Mosaic feature test its own fake FAPI host.
Description check Passed The description directly explains the test-isolation problem, the per-test host solution, the fallback handler, and the added coverage.
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.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. (2 skipped: 2 unsupported.)



  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR


  • 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 Oct 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-biometrics

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

@clerk/expo-google-signin

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/mosaic

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: b8fa912

@alexcarpenter
alexcarpenter merged commit 44b09ba into main Oct 9, 2026
50 of 52 checks passed
@alexcarpenter
alexcarpenter deleted the carp/another-flake branch October 9, 2026 21:18

This branch was successfully deployed

2 active deployments
Preview – swingset — b8fa912a Deployed Oct 9, 2026 by vercel[bot]
Preview – clerk-js-sandbox — b8fa912a Deployed Oct 9, 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