Skip to content

Commit

Permalink
test: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
TrickyPi committed Mar 7, 2022
1 parent 458c4c5 commit 2a8bca2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts
@@ -1,5 +1,5 @@
import { createServer } from '../../index'
import { resolve } from 'path'
import { createServer } from '../../index'

const badjs = resolve(__dirname, './fixtures/ssrModuleLoader-bad.js')
const THROW_MESSAGE = 'it is an expected error'
Expand All @@ -18,10 +18,12 @@ test('always throw error when evaluating an wrong SSR module', async () => {
await viteServer.close()
expect(expectedErrors).toHaveLength(2)
expect(expectedErrors[0]).toBe(expectedErrors[1])
expect(spy).toBeCalledTimes(2)
spy.mock.calls.forEach(([info]) => {
expect(info).toContain('Error when evaluating SSR module')
expect(info).toContain(THROW_MESSAGE)
expectedErrors.forEach((error) => {
expect(error?.message).toContain(THROW_MESSAGE)
})
expect(spy).toBeCalledTimes(1)
const [firstParameter] = spy.mock.calls[0]
expect(firstParameter).toContain('Error when evaluating SSR module')
expect(firstParameter).toContain(THROW_MESSAGE)
spy.mockClear()
})

0 comments on commit 2a8bca2

Please sign in to comment.