Skip to content

Commit a46bdf4

Browse files
authored
test(rsc): test vite 6 (#762)
1 parent af4e16d commit a46bdf4

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

packages/plugin-rsc/e2e/fixture.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export function useFixture(options: {
166166
export async function setupIsolatedFixture(options: {
167167
src: string
168168
dest: string
169+
overrides?: Record<string, string>
169170
}) {
170171
// copy fixture
171172
fs.rmSync(options.dest, { recursive: true, force: true })
@@ -184,10 +185,16 @@ export async function setupIsolatedFixture(options: {
184185
/overrides:\s*([\s\S]*?)(?=\n\w|\n*$)/,
185186
)
186187
const overridesSection = overridesMatch ? overridesMatch[0] : 'overrides:'
188+
const overrides = {
189+
'@vitejs/plugin-rsc': `file:${path.join(rootDir, 'packages/plugin-rsc')}`,
190+
'@vitejs/plugin-react': `file:${path.join(rootDir, 'packages/plugin-react')}`,
191+
...options.overrides,
192+
}
187193
const tempWorkspaceYaml = `\
188194
${overridesSection}
189-
'@vitejs/plugin-rsc': ${JSON.stringify('file:' + path.join(rootDir, 'packages/plugin-rsc'))}
190-
'@vitejs/plugin-react': ${JSON.stringify('file:' + path.join(rootDir, 'packages/plugin-react'))}
195+
${Object.entries(overrides)
196+
.map(([k, v]) => ` ${JSON.stringify(k)}: ${JSON.stringify(v)}`)
197+
.join('\n')}
191198
`
192199
fs.writeFileSync(
193200
path.join(options.dest, 'pnpm-workspace.yaml'),

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { setupIsolatedFixture, useFixture } from './fixture'
33
import { defineStarterTest } from './starter'
44
import path from 'node:path'
55
import os from 'node:os'
6+
import * as vite from 'vite'
67

78
test.describe(() => {
89
// use RUNNER_TEMP on Github Actions
@@ -25,3 +26,31 @@ test.describe(() => {
2526
defineStarterTest(f)
2627
})
2728
})
29+
30+
test.describe('vite 6', () => {
31+
test.skip(!!process.env.ECOSYSTEM_CI || 'rolldownVersion' in vite)
32+
33+
const tmpRoot = path.join(
34+
process.env['RUNNER_TEMP'] || os.tmpdir(),
35+
'test-vite-rsc-vite-6',
36+
)
37+
test.beforeAll(async () => {
38+
await setupIsolatedFixture({
39+
src: 'examples/starter',
40+
dest: tmpRoot,
41+
overrides: {
42+
vite: '^6',
43+
},
44+
})
45+
})
46+
47+
test.describe('dev', () => {
48+
const f = useFixture({ root: tmpRoot, mode: 'dev' })
49+
defineStarterTest(f)
50+
})
51+
52+
test.describe('build', () => {
53+
const f = useFixture({ root: tmpRoot, mode: 'build' })
54+
defineStarterTest(f)
55+
})
56+
})

0 commit comments

Comments
 (0)