Skip to content

Commit

Permalink
test: tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 18, 2024
1 parent c2f7d75 commit 96f123a
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions packages/vite/src/node/ssr/runtime/__tests__/server-runtime.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,27 +234,32 @@ describe('module runner initialization', async () => {
})

it.for([
['/fixtures/cyclic2/test1/index.js', true],
['/fixtures/cyclic2/test2/index.js', true],
['/fixtures/cyclic2/test3/index.js', true],
['/fixtures/cyclic2/test4/index.js', true],
['/fixtures/cyclic2/test5/index.js', false],
] as const)(`cyclic %s`, async ([entry, ok], { runner }) => {
if (ok) {
const mod = await runner.import(entry)
expect({ ...mod }).toEqual({
dep1: {
ok: true,
},
dep2: {
ok: true,
},
})
} else {
await expect(() => runner.import(entry)).rejects.toMatchObject({
name: 'ReferenceError',
})
}
'/fixtures/cyclic2/test1/index.js',
'/fixtures/cyclic2/test2/index.js',
'/fixtures/cyclic2/test3/index.js',
'/fixtures/cyclic2/test4/index.js',
] as const)(`cyclic %s`, async (entry, { runner }) => {
const mod = await runner.import(entry)
expect({ ...mod }).toEqual({
dep1: {
ok: true,
},
dep2: {
ok: true,
},
})
})

it(`cyclic invalid`, async ({ runner }) => {
// Node also fails but with a different message
// $ node packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test5/index.js
// ReferenceError: Cannot access 'dep1' before initialization
await expect(() =>
runner.import('/fixtures/cyclic2/test5/index.js'),
).rejects.toMatchObject({
name: 'ReferenceError',
message: `Cannot access '__vite_ssr_import_1__' before initialization`,
})
})
})

Expand Down

0 comments on commit 96f123a

Please sign in to comment.