Skip to content

Commit 28665e1

Browse files
hi-ogawaclaude
andauthored
test(rsc): add e2e test for custom root via CLI argument (#1134)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 98387ae commit 28665e1

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,50 @@ test.describe(() => {
4545
defineStarterTest(f)
4646
})
4747
})
48+
49+
// Test that the RSC plugin works when `root` is passed as a CLI argument
50+
// e.g. `vite dev ./app` where the app lives in a subdirectory.
51+
// This effectively tests `createServer/createBuilder({ root })`
52+
// and then loading config file from the specified root.
53+
test.describe('root-config', () => {
54+
const root = 'examples/e2e/temp/root-config'
55+
56+
test.beforeAll(async () => {
57+
await setupInlineFixture({
58+
src: 'examples/starter',
59+
dest: `${root}/app`,
60+
files: {
61+
'vite.config.base.ts': { cp: 'vite.config.ts' },
62+
'vite.config.ts': /* js */ `
63+
import baseConfig from './vite.config.base.ts'
64+
import path from "node:path";
65+
for (const e of Object.values(baseConfig.environments)) {
66+
e.build.rollupOptions.input.index = path.resolve(
67+
'app',
68+
e.build.rollupOptions.input.index,
69+
);
70+
}
71+
export default baseConfig;
72+
`,
73+
},
74+
})
75+
})
76+
77+
test.describe('dev', () => {
78+
const f = useFixture({ root, mode: 'dev', command: 'vite dev ./app' })
79+
const oldCreateEditor = f.createEditor
80+
f.createEditor = (filePath: string) =>
81+
oldCreateEditor(path.resolve(root, 'app', filePath))
82+
defineStarterTest(f)
83+
})
84+
85+
test.describe('build', () => {
86+
const f = useFixture({
87+
root,
88+
mode: 'build',
89+
buildCommand: 'vite build ./app',
90+
command: 'vite preview ./app',
91+
})
92+
defineStarterTest(f)
93+
})
94+
})

0 commit comments

Comments
 (0)