Skip to content

Commit a1f4b46

Browse files
authoredDec 23, 2024··
test(ssr): test virtual module with query (#19044)
1 parent ac32968 commit a1f4b46

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎packages/vite/src/node/ssr/runtime/__tests__/server-runtime.spec.ts

+13
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ describe('module runner initialization', async () => {
2828
it('can load virtual modules as an entry point', async ({ runner }) => {
2929
const mod = await runner.import('virtual:test')
3030
expect(mod.msg).toBe('virtual')
31+
32+
// virtual module query is not supported out of the box
33+
// (`?t=...` was working on Vite 5 ssrLoadModule as `transformRequest` strips off timestamp query)
34+
await expect(() =>
35+
runner.import(`virtual:test?t=${Date.now()}`),
36+
).rejects.toMatchObject({
37+
message: expect.stringContaining('cannot find entry point module'),
38+
})
39+
await expect(() =>
40+
runner.import('virtual:test?abcd=1234'),
41+
).rejects.toMatchObject({
42+
message: expect.stringContaining('cannot find entry point module'),
43+
})
3144
})
3245

3346
it('css is loaded correctly', async ({ runner }) => {

0 commit comments

Comments
 (0)
Please sign in to comment.