Skip to content

Conversation

@AriPerkkio
Copy link
Member

Description

Patching istanbul-lib-coverage is tricky as it's still installed by multiple packages that depend on it. I'm a bit concerned users might run into this error due to multiple istanbul-lib-coverage instances on runtime:

https://github.com/istanbuljs/istanbuljs/blob/28ffdbc314596bdcb3007e85d30a62372602b262/packages/istanbul-lib-coverage/lib/file-coverage.js#L37-L42

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Co-authored-by: Steve Zhang <huigang.zhang@gmail.com>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 17, 2026

@vitest/browser

npm i https://pkg.pr.new/@vitest/browser@9480

@vitest/browser-playwright

npm i https://pkg.pr.new/@vitest/browser-playwright@9480

@vitest/browser-preview

npm i https://pkg.pr.new/@vitest/browser-preview@9480

@vitest/browser-webdriverio

npm i https://pkg.pr.new/@vitest/browser-webdriverio@9480

@vitest/coverage-istanbul

npm i https://pkg.pr.new/@vitest/coverage-istanbul@9480

@vitest/coverage-v8

npm i https://pkg.pr.new/@vitest/coverage-v8@9480

@vitest/expect

npm i https://pkg.pr.new/@vitest/expect@9480

@vitest/mocker

npm i https://pkg.pr.new/@vitest/mocker@9480

@vitest/pretty-format

npm i https://pkg.pr.new/@vitest/pretty-format@9480

@vitest/runner

npm i https://pkg.pr.new/@vitest/runner@9480

@vitest/snapshot

npm i https://pkg.pr.new/@vitest/snapshot@9480

@vitest/spy

npm i https://pkg.pr.new/@vitest/spy@9480

@vitest/ui

npm i https://pkg.pr.new/@vitest/ui@9480

@vitest/utils

npm i https://pkg.pr.new/@vitest/utils@9480

vitest

npm i https://pkg.pr.new/vitest@9480

@vitest/web-worker

npm i https://pkg.pr.new/@vitest/web-worker@9480

@vitest/ws-client

npm i https://pkg.pr.new/@vitest/ws-client@9480

commit: f2cd51a

@netlify
Copy link

netlify bot commented Jan 17, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 5e792b8
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/696b6c3267b51e0008535be9
😎 Deploy Preview https://deploy-preview-9480--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@AriPerkkio
Copy link
Member Author

@stevez could you verify if these preview version fix the issue in your project?

#9480 (comment)

@stevez
Copy link

stevez commented Jan 18, 2026

Hi @AriPerkkio, I can verify that #9366 is getting fixed in this preview build,
repo: https://github.com/stevez/vitest-coverage-merge-bug
branch: test/verify-pr-9480-fix
in src/constants.ts: before total statements was 6 in main branch, now it is 3 in branch test/verify-pr-9480-fix

Copy link
Member Author

@AriPerkkio AriPerkkio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need test case for this to pick up regressions. I've been trying to come up with one but haven't figured out good way without relying on third party plugins.

Maybe we need to manually construct incompatible transform results and feed those via custom plugin.

Comment on lines +95 to +115
expect(fileCoverage).toMatchInlineSnapshot(`
{
"branches": "0/0 (100%)",
"functions": "2/8 (25%)",
"lines": "1/4 (25%)",
"statements": "1/4 (25%)",
}
`)

expect(Object.values(fileCoverage.fnMap).map(fn => fn.name)).toMatchInlineSnapshot(`
[
"sum",
"subtract",
"multiply",
"remainder",
"sum",
"subtract",
"multiply",
"remainder",
]
`)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevez looks like merging is still wrong. Functions of this file are shown twice due to different end.column mappings.

This is the file tests are loading:

export function sum(a: number, b: number) {
return a + b
}
export function subtract(a: number, b: number) {
return a - b
}
export function multiply(a: number, b: number) {
return a * b
}
export function remainder(a: number, b:number) {
return a % b
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me take a look tonight

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AriPerkkio, I want to confirm the test case, the test failed due to trying to merge 2 different transforms coverage result, now both have different start column as well, I want to confirm do we need to support this scenario, or I feel it is a kind of expanding the scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coverage-v8: Duplicate statements when merging coverage from multiple projects with different environments

2 participants