Skip to content

Commit

Permalink
chore: error is not the same
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jul 11, 2023
1 parent ff727db commit c88d4b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/vitest/src/runtime/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export async function run(ctx: WorkerContext) {

process.env.VITEST_WORKER_ID = String(ctx.workerId)
process.env.VITEST_POOL_ID = String(poolId)
process.env.VITEST_VM_POOL = '1'

if (!vm.getVmContext)
throw new TypeError(`Environment ${ctx.environment.name} doesn't provide "getVmContext" method. It should return a context created by "vm.createContext" method.`)
Expand Down
4 changes: 3 additions & 1 deletion test/web-worker/test/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ it('worker with invalid url throws an error', async () => {
}
})
expect(event).toBeInstanceOf(ErrorEvent)
expect(event.error).toBeInstanceOf(Error)
// Error is in different context when running in VM. This is consistent with jest.
if (!import.meta.env.VITEST_VM_POOL)
expect(event.error).toBeInstanceOf(Error)
expect(event.error.message).toContain('Failed to load')
})

Expand Down
4 changes: 3 additions & 1 deletion test/web-worker/test/sharedWorker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ it('throws an error on invalid path', async () => {
}
})
expect(event).toBeInstanceOf(ErrorEvent)
expect(event.error).toBeInstanceOf(Error)
// Error is in different context when running in VM. This is consistent with jest.
if (!import.meta.env.VITEST_VM_POOL)
expect(event.error).toBeInstanceOf(Error)
expect(event.error.message).toContain('Failed to load')
})

Expand Down

0 comments on commit c88d4b8

Please sign in to comment.