Skip to content

Commit 3e2f5a9

Browse files
hi-ogawaclaude
andauthored
ci(rsc): test react nightly (#630)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent b077c4a commit 3e2f5a9

File tree

4 files changed

+41
-28
lines changed

4 files changed

+41
-28
lines changed

.github/workflows/ci-rsc.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ jobs:
3232
- run: pnpm -C packages/plugin-rsc test
3333

3434
test-e2e:
35-
name: test-rsc (${{ matrix.os }} / ${{ matrix.browser }}) ${{ matrix.rolldown == true && '(rolldown)' || '' }}
35+
name: test-rsc (${{ matrix.os }} / ${{ matrix.browser }}) ${{ matrix.rolldown == true && '(rolldown)' || '' }} ${{ matrix.react_version && format('(react-{0})', matrix.react_version) || '' }}
3636
runs-on: ${{ matrix.os }}
3737
strategy:
3838
matrix:
3939
os: [ubuntu-latest, macos-latest, windows-latest]
4040
browser: [chromium]
4141
rolldown: [false]
42+
react_version: [""]
4243
include:
4344
- os: ubuntu-latest
4445
browser: firefox
@@ -47,6 +48,12 @@ jobs:
4748
- os: ubuntu-latest
4849
browser: chromium
4950
rolldown: true
51+
- os: ubuntu-latest
52+
browser: chromium
53+
react_version: canary
54+
- os: ubuntu-latest
55+
browser: chromium
56+
react_version: experimental
5057
fail-fast: false
5158
steps:
5259
- uses: actions/checkout@v4
@@ -55,6 +62,13 @@ jobs:
5562
node-version: 22
5663
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
5764
- run: pnpm i
65+
- name: install react
66+
if: ${{ matrix.react_version }}
67+
run: |
68+
sed -i "/^overrides:/a\ react: \"${{ matrix.react_version }}\"" pnpm-workspace.yaml
69+
sed -i "/^overrides:/a\ react-dom: \"${{ matrix.react_version }}\"" pnpm-workspace.yaml
70+
sed -i "/^overrides:/a\ react-server-dom-webpack: \"${{ matrix.react_version }}\"" pnpm-workspace.yaml
71+
pnpm i --no-frozen-lockfile
5872
- run: pnpm build
5973
- name: install rolldown
6074
if: ${{ matrix.rolldown }}
@@ -63,11 +77,9 @@ jobs:
6377
pnpm i --no-frozen-lockfile
6478
- run: pnpm -C packages/plugin-rsc exec playwright install ${{ matrix.browser }}
6579
- run: pnpm -C packages/plugin-rsc test-e2e-ci --project=${{ matrix.browser }}
66-
env:
67-
TEST_ISOLATED: true
6880
- uses: actions/upload-artifact@v4
6981
if: always()
7082
with:
71-
name: test-results-${{ matrix.os }}-${{ matrix.browser }}${{ matrix.rolldown == true && '-rolldown' || '' }}
83+
name: test-results-${{ matrix.os }}-${{ matrix.browser }}${{ matrix.rolldown == true && '-rolldown' || '' }}${{ matrix.react_version && format('-react-{0}', matrix.react_version) || '' }}
7284
path: |
7385
packages/plugin-rsc/test-results

packages/plugin-rsc/e2e/basic.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,9 +923,7 @@ function defineTest(f: Fixture) {
923923
expect(errors).toMatchObject([
924924
{
925925
message: expect.stringContaining(
926-
f.mode === 'dev'
927-
? `Hydration failed because the server rendered HTML didn't match the client.`
928-
: `Minified React error #418`,
926+
f.mode === 'dev' ? `Hydration failed` : `Minified React error #418`,
929927
),
930928
},
931929
])

packages/plugin-rsc/e2e/fixture.ts

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,25 @@ export async function setupIsolatedFixture(options: {
158158
filter: (src) => !src.includes('node_modules'),
159159
})
160160

161-
// setup package.json overrides
162-
const packagesDir = path.join(import.meta.dirname, '..', '..')
163-
const overrides = {
164-
'@vitejs/plugin-rsc': `file:${path.join(packagesDir, 'plugin-rsc')}`,
165-
'@vitejs/plugin-react': `file:${path.join(packagesDir, 'plugin-react')}`,
166-
}
167-
editFileJson(path.join(options.dest, 'package.json'), (pkg: any) => {
168-
Object.assign(((pkg.pnpm ??= {}).overrides ??= {}), overrides)
169-
return pkg
170-
})
161+
// extract workspace overrides
162+
const rootDir = path.join(import.meta.dirname, '..', '..', '..')
163+
const workspaceYaml = fs.readFileSync(
164+
path.join(rootDir, 'pnpm-workspace.yaml'),
165+
'utf-8',
166+
)
167+
const overridesMatch = workspaceYaml.match(
168+
/overrides:\s*([\s\S]*?)(?=\n\w|\n*$)/,
169+
)
170+
const overridesSection = overridesMatch ? overridesMatch[0] : 'overrides:'
171+
const tempWorkspaceYaml = `\
172+
${overridesSection}
173+
'@vitejs/plugin-rsc': ${JSON.stringify('file:' + path.join(rootDir, 'packages/plugin-rsc'))}
174+
'@vitejs/plugin-react': ${JSON.stringify('file:' + path.join(rootDir, 'packages/plugin-react'))}
175+
`
176+
fs.writeFileSync(
177+
path.join(options.dest, 'pnpm-workspace.yaml'),
178+
tempWorkspaceYaml,
179+
)
171180

172181
// install
173182
await x('pnpm', ['i'], {
@@ -183,17 +192,6 @@ export async function setupIsolatedFixture(options: {
183192
})
184193
}
185194

186-
function editFileJson(filepath: string, edit: (s: string) => string) {
187-
fs.writeFileSync(
188-
filepath,
189-
JSON.stringify(
190-
edit(JSON.parse(fs.readFileSync(filepath, 'utf-8'))),
191-
null,
192-
2,
193-
),
194-
)
195-
}
196-
197195
// inspired by
198196
// https://github.com/remix-run/react-router/blob/433872f6ab098eaf946cc6c9cf80abf137420ad2/integration/helpers/vite.ts#L239
199197
// for syntax highlighting of /* js */, use this extension

packages/plugin-rsc/e2e/react-router.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import { expect, test } from '@playwright/test'
33
import { type Fixture, useFixture } from './fixture'
44
import { expectNoReload, testNoJs, waitForHydration } from './helper'
55
import { readFileSync } from 'node:fs'
6+
import React from 'react'
67

78
test.describe('dev-default', () => {
9+
test.skip(/canary|experimental/.test(React.version))
10+
811
const f = useFixture({ root: 'examples/react-router', mode: 'dev' })
912
defineTest(f)
1013
})
@@ -15,6 +18,8 @@ test.describe('build-default', () => {
1518
})
1619

1720
test.describe('dev-cloudflare', () => {
21+
test.skip(/canary|experimental/.test(React.version))
22+
1823
const f = useFixture({
1924
root: 'examples/react-router',
2025
mode: 'dev',

0 commit comments

Comments
 (0)