Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't crash when calling useFakeTimers in VM pool #3958

Merged
merged 1 commit into from Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/vitest/src/runtime/vm.ts
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
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
@@ -0,0 +1,3 @@
// @vitest-environment jsdom

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

import './fixtures/timers.suite'