Skip to content

Commit

Permalink
fix(coverage): preserve moduleExecutionInfo in non-isolated runs (#7486)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio authored Feb 13, 2025
1 parent 5a45a7c commit f31a07b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/vitest/src/runtime/workers/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { provideWorkerState } from '../utils'
let _viteNode: VitestExecutor

const moduleCache = new ModuleCacheMap()
const moduleExecutionInfo = new Map()

async function startViteNode(options: ContextExecutorOptions) {
if (_viteNode) {
Expand All @@ -21,6 +22,7 @@ export async function runBaseTests(method: 'run' | 'collect', state: WorkerGloba
const { ctx } = state
// state has new context, but we want to reuse existing ones
state.moduleCache = moduleCache
state.moduleExecutionInfo = moduleExecutionInfo

provideWorkerState(globalThis, state)

Expand Down
5 changes: 2 additions & 3 deletions test/coverage-test/test/isolation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ for (const isolate of [true, false]) {
if (isV8Provider()) {
expect(summary).toStrictEqual({
'<process-cwd>/fixtures/src/branch.ts': {
// FIXME: this should specify exact numbers
branches: expect.any(String),
functions: expect.any(String),
branches: '3/3 (100%)',
functions: '1/1 (100%)',
lines: '6/6 (100%)',
statements: '6/6 (100%)',
},
Expand Down

0 comments on commit f31a07b

Please sign in to comment.