Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jan 3, 2024
1 parent a063d07 commit 2ba2c00
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/vitest/src/runtime/workers/vm.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Context } from 'node:vm'
import { isContext } from 'node:vm'
import { pathToFileURL } from 'node:url'
import { resolve } from 'pathe'
Expand Down Expand Up @@ -36,7 +37,7 @@ export async function runVmTests(state: WorkerGlobalState) {
if (!vm.getVmContext)
throw new TypeError(`Environment ${environment.name} doesn't provide "getVmContext" method. It should return a context created by "vm.createContext" method.`)

const context = vm.getVmContext()
let context: Context | null = vm.getVmContext()

if (!isContext(context))
throw new TypeError(`Environment ${environment.name} doesn't provide a valid context. It should be created by "vm.createContext" method.`)
Expand Down Expand Up @@ -89,5 +90,6 @@ export async function runVmTests(state: WorkerGlobalState) {
state.environmentTeardownRun = true
context.__vitest_mocker__ = null
context.__vitest_worker__ = null
context = null
}
}

0 comments on commit 2ba2c00

Please sign in to comment.