Skip to content

Commit 96e0391

Browse files
hi-ogawaclaude
andcommitted
test: add e2e test for importAsset API
Test that importAsset can replace loadBootstrapScriptContent for loading client entry URLs in both dev and build modes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8b951af commit 96e0391

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { test } from '@playwright/test'
2+
import { setupInlineFixture, useFixture } from './fixture'
3+
import { defineStarterTest } from './starter'
4+
5+
test.describe('viteRsc.importAsset', () => {
6+
const root = 'examples/e2e/temp/import-asset'
7+
test.beforeAll(async () => {
8+
await setupInlineFixture({
9+
src: 'examples/starter',
10+
dest: root,
11+
files: {
12+
'src/framework/entry.ssr.tsx': {
13+
edit: (s) =>
14+
s.replace(
15+
`\
16+
const bootstrapScriptContent =
17+
await import.meta.viteRsc.loadBootstrapScriptContent('index')
18+
`,
19+
`\
20+
const asset = await import.meta.viteRsc.importAsset('./entry.browser.tsx', { entry: true })
21+
const bootstrapScriptContent = \`import(\${JSON.stringify(asset.url)})\`
22+
`,
23+
),
24+
},
25+
},
26+
})
27+
})
28+
29+
test.describe('dev', () => {
30+
const f = useFixture({ root, mode: 'dev' })
31+
defineStarterTest(f)
32+
})
33+
34+
test.describe('build', () => {
35+
const f = useFixture({ root, mode: 'build' })
36+
defineStarterTest(f)
37+
})
38+
})

0 commit comments

Comments
 (0)