-
-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathimport-asset.test.ts
More file actions
45 lines (42 loc) · 1.36 KB
/
import-asset.test.ts
File metadata and controls
45 lines (42 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { test } from '@playwright/test'
import { setupInlineFixture, useFixture } from './fixture'
import { defineStarterTest } from './starter'
test.describe('viteRsc.importAsset', () => {
const root = 'examples/e2e/temp/import-asset'
test.beforeAll(async () => {
await setupInlineFixture({
src: 'examples/starter',
dest: root,
files: {
'src/framework/entry.ssr.tsx': {
edit: (s) =>
s.replace(
`\
const bootstrapScriptContent =
await import.meta.viteRsc.loadBootstrapScriptContent('index')
`,
`\
const asset = await import.meta.viteRsc.importAsset('./entry.browser.tsx', { entry: true })
const bootstrapScriptContent = \`import(\${JSON.stringify(asset.url)})\`
`,
),
},
// Remove "index" client entry to test importAsset replacing the convention
'vite.config.base.ts': { cp: 'vite.config.ts' },
'vite.config.ts': /* js */ `
import baseConfig from './vite.config.base.ts'
delete baseConfig.environments.client.build.rollupOptions.input;
export default baseConfig;
`,
},
})
})
test.describe('dev', () => {
const f = useFixture({ root, mode: 'dev' })
defineStarterTest(f)
})
test.describe('build', () => {
const f = useFixture({ root, mode: 'build' })
defineStarterTest(f)
})
})