Skip to content

test: add React Server Component test support via vitest-plugin-rsc - #8813

Open
tay1orjones wants to merge 3 commits into
mainfrom
rsc-tests-8451
Open

tay1orjones wants to merge 3 commits into
mainfrom
rsc-tests-8451

Conversation

@tay1orjones

Copy link
Copy Markdown
Contributor

Fixes #8451

Adds React Server Component test support to packages/react using vitest-plugin-rsc, with two example tests.

Note: the plugin renders the server and client environments inside the test's browser tab, so it cannot run in the Node project next to ssr.test.tsx. It lives in its own Vitest project instead (@primer/react (rsc)), and *.rsc.test.tsx is excluded from the existing Chromium project, which is otherwise unchanged. The plugin's non-Next mode is used, so no next config is needed. The next/@next/routing peers are only auto-installed by npm.

Changelog

New

  • vitest.config.rsc.mts Vitest project, setup file, and src/__tests__/components.rsc.test.tsx (components render inside a Server Component; client components behind the 'use client' entry hydrate and respond to interaction)
  • Docs section in contributor-docs/testing.md

Changed

  • Root vitest.config.mts registers the new project; browser project excludes *.rsc.test.tsx

Removed

N/A

Rollout strategy

  • No rollout required

Testing & Reviewing

Server Components need React 19, and the repo installs React 18 by default. The rsc project therefore has no tests on React 18 and runs in the existing React 19 CI job. Verified locally with node script/setup-react-19.mts then npx vitest run --project '@primer/react (rsc)' (2 passed), and the full npx vitest run on React 18 (no new failures; @primer/mcp and @primer/styled-react fail only because packages aren't built here).

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@tay1orjones
tay1orjones requested a review from a team as a code owner November 20, 2026 17:30
@tay1orjones
tay1orjones requested review from joshblack and a balanced review from Copilot November 20, 2026 17:30
@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3f7cbe6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

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

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@tay1orjones tay1orjones added the skip changeset This change does not need a changelog label Nov 20, 2026
@github-actions github-actions Bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new RSC suite fails CI’s className coverage check, and its checkbox assertions can pass even when React’s client-side interaction handling is broken.

2 open issues
What changed in this PR

Adds React Server Component testing to Primer React through vitest-plugin-rsc, using a separate browser-based Vitest project enabled on React 19.

Changes:

  • Registers the RSC project and excludes its tests from the existing browser suite.
  • Adds setup hooks and examples for server rendering and client interaction.
  • Documents the test environment and adds the required development dependency.
File Description
vitest.config.mts Registers RSC test projects.
packages/​react/​vitest.config.rsc.mts Configures React 19-gated RSC tests in Chromium.
packages/​react/​vitest.config.browser.mts Excludes RSC tests from the standard browser suite.
packages/​react/​tsconfig.json Includes the RSC configuration in type checking.
packages/​react/​src/​__tests__/​components.rsc.test.tsx Adds rendering and interaction examples.
packages/​react/​package.json Adds vitest-plugin-rsc as a development dependency.
packages/​react/​config/​vitest/​rsc/​setup.ts Initializes and cleans up the RSC test environment.
package-lock.json Records the plugin and dependency updates.
contributor-docs/​testing.md Documents RSC tests and the React 19 requirement.

Review effort: Balanced

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8813 November 20, 2026 17:43 Inactive
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

@joshblack joshblack 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.

Woo! So cool 🥳

@tay1orjones tay1orjones added the integration-tests: skipped manually Changes in this PR do not require an integration test label Nov 20, 2026

This branch was successfully deployed

2 active deployments
storybook-preview-8813 — 3f7cbe66 Deployed Nov 20, 2026 by github-actions[bot]
github-pages — 3f7cbe66 Deployed Nov 20, 2026 by tay1orjones via deploy-preview #34483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm integration-tests: skipped manually Changes in this PR do not require an integration test skip changeset This change does not need a changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for RSC tests to packages/react

3 participants