Skip to content

Commit

Permalink
fix(vm): handle disableConsoleIntercept config (#5074)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Jan 30, 2024
1 parent 35675bd commit a55adac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/vitest/src/runtime/workers/vm.ts
Expand Up @@ -48,7 +48,7 @@ export async function runVmTests(state: WorkerGlobalState) {
// because browser doesn't provide these globals
context.process = process
context.global = context
context.console = createCustomConsole(state)
context.console = state.config.disableConsoleIntercept ? console : createCustomConsole(state)
// TODO: don't hardcode setImmediate in fake timers defaults
context.setImmediate = setImmediate
context.clearImmediate = clearImmediate
Expand Down
3 changes: 2 additions & 1 deletion test/config/test/console.test.ts
Expand Up @@ -8,10 +8,11 @@ test('default intercept', async () => {
expect(stderr).toBe('stderr | basic.test.ts > basic\n__test_console__\n\n')
})

test('disable intercept', async () => {
test.each(['threads', 'vmThreads'] as const)(`disable intercept pool=%s`, async (pool) => {
const { stderr } = await runVitest({
root: './fixtures/console',
disableConsoleIntercept: true,
pool,
})
expect(stderr).toBe('__test_console__\n')
})

0 comments on commit a55adac

Please sign in to comment.