Skip to content

Commit

Permalink
fix: don't crash when calling useFakeTimers in VM pool (#3958)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va authored Aug 15, 2023
1 parent 15b4fd6 commit 91fe485
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/vitest/src/runtime/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export async function run(ctx: WorkerContext) {
context.process = process
context.global = context
context.console = createCustomConsole(state)
// TODO: don't hardcode setImmediate in fake timers defaults
context.setImmediate = setImmediate
context.clearImmediate = clearImmediate

if (ctx.invalidates) {
ctx.invalidates.forEach((fsPath) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import { afterEach, describe, expect, it, vi } from 'vitest'
import { FakeTimers } from '../../../packages/vitest/src/integrations/mock/timers'
import { FakeTimers } from '../../../../packages/vitest/src/integrations/mock/timers'

class FakeDate extends Date {}

Expand Down
3 changes: 3 additions & 0 deletions test/core/test/timers-jsdom.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @vitest-environment jsdom

import './fixtures/timers.suite'
3 changes: 3 additions & 0 deletions test/core/test/timers-node.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @vitest-environment node

import './fixtures/timers.suite'

0 comments on commit 91fe485

Please sign in to comment.