Skip to content

feat(coverage): v8 to track node:child_process and node:worker_threads contexts#9976

Merged
sheremet-va merged 7 commits intovitest-dev:mainfrom
AriPerkkio:feat/coverage-process-thread-context
Apr 27, 2026
Merged

feat(coverage): v8 to track node:child_process and node:worker_threads contexts#9976
sheremet-va merged 7 commits intovitest-dev:mainfrom
AriPerkkio:feat/coverage-process-thread-context

Conversation

@AriPerkkio
Copy link
Copy Markdown
Member

@AriPerkkio AriPerkkio commented Mar 26, 2026

Description

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:.

Comment thread packages/coverage-v8/src/intercept-new-run-context.ts Outdated
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 26, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ffe6ed9
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69eb69e93807e300093df3ef
😎 Deploy Preview https://deploy-preview-9976--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 AriPerkkio force-pushed the feat/coverage-process-thread-context branch from 88a5c08 to fa35cd5 Compare March 26, 2026 13:49
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 26, 2026

@vitest/browser

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

@vitest/browser-playwright

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

@vitest/browser-preview

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

@vitest/browser-webdriverio

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

@vitest/coverage-istanbul

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

@vitest/coverage-v8

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

@vitest/expect

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

@vitest/mocker

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

@vitest/pretty-format

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

@vitest/runner

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

@vitest/snapshot

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

@vitest/spy

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

@vitest/ui

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

@vitest/utils

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

vitest

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

@vitest/web-worker

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

commit: cc332ea

@AriPerkkio AriPerkkio force-pushed the feat/coverage-process-thread-context branch 3 times, most recently from fef5aec to 188a95f Compare March 31, 2026 18:35
@AriPerkkio AriPerkkio force-pushed the feat/coverage-process-thread-context branch 2 times, most recently from 70f7641 to 3d1dce2 Compare April 6, 2026 14:03
Comment thread test/coverage-test/test/extended-run-context.v8.test.ts Outdated
@AriPerkkio AriPerkkio force-pushed the feat/coverage-process-thread-context branch 3 times, most recently from ed25468 to 66e52a1 Compare April 6, 2026 19:31
Comment thread packages/coverage-v8/src/index.ts Outdated
@AriPerkkio AriPerkkio force-pushed the feat/coverage-process-thread-context branch 3 times, most recently from fb7116a to c0a7985 Compare April 12, 2026 09:55
Comment thread packages/coverage-v8/src/index.ts Outdated
import { loadProvider } from './load-provider'

const session = new inspector.Session()
let session: inspector.Session | null = null
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This used to create unused new Session() on main thread too, oops.

@AriPerkkio AriPerkkio force-pushed the feat/coverage-process-thread-context branch 3 times, most recently from b97e821 to 63acca7 Compare April 13, 2026 09:31
@AriPerkkio AriPerkkio marked this pull request as ready for review April 13, 2026 10:52
@AriPerkkio AriPerkkio force-pushed the feat/coverage-process-thread-context branch from 63acca7 to 92ab430 Compare April 13, 2026 10:55
Comment thread docs/config/coverage.md Outdated

Collect coverage only for files changed since a specified commit or branch. When set to `true`, it uses staged and unstaged changes.

## coverage.trackProcessAndWorker
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Naming this option is difficult. Right now it only covers node:child_process and node:worker_threads, but in future it's likely going to be used for web workers and similar on browser. @hi-ogawa & @sheremet-va - please propose better name here. 🙏

Internally this feature also uses term extendedContextCoverage. 🙃

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think worker really fits in here, both child process and a worker thread is a worker in my opinion, at least that's how we defined it for pools, maybe trackProcessAndThreads is more accurate.

I would vote for something like includeSubprocesses/instrumentSubprocesses - subprocess can refer to anything, not just a fork/thread/service worker

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In debugging world there is also --follow-forks mode (in C), in vscode it's autoAttachChildProcesses (although it also follows workers)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

How about autoAttachChildContext? Or autoAttachWorkers and imply Worker is processes too. 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I feel like the common denominator here is subprocess, I wouldn't call any subprocess a worker, but every worker a subprocess

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's not a process in a sense of node:child_process, but it is a process in a general sense

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, it's not a process even in a general sense.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well, process is not a worker in a general sense

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Worker is already taken and it would be confusing to reuse the word within the Vitest repository. Subprocess to me sounds like the most general way to describe anything spawned by the user code

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Worker is not a term that's used in general sense 🙃. But sure let's think in NodeJS context.

Ok, let's use autoAttachSubprocess. I don't care that much.

@AriPerkkio AriPerkkio requested review from hi-ogawa and sheremet-va and removed request for sheremet-va April 13, 2026 10:57
@AriPerkkio AriPerkkio requested a review from sheremet-va April 13, 2026 10:57
@AriPerkkio AriPerkkio force-pushed the feat/coverage-process-thread-context branch from 92ab430 to c1073e1 Compare April 20, 2026 10:05
@AriPerkkio AriPerkkio force-pushed the feat/coverage-process-thread-context branch from c1073e1 to 2eb5e8d Compare April 21, 2026 05:47
Comment thread docs/config/coverage.md Outdated
Comment thread packages/coverage-v8/src/index.ts
Comment thread packages/coverage-v8/src/index.ts
@AriPerkkio AriPerkkio requested a review from hi-ogawa April 24, 2026 07:15
@sheremet-va sheremet-va merged commit 9baa5fa into vitest-dev:main Apr 27, 2026
16 of 17 checks passed
@sheremet-va
Copy link
Copy Markdown
Member

Awesome!

@AriPerkkio AriPerkkio deleted the feat/coverage-process-thread-context branch April 27, 2026 12:12
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 not collected from sub-propcesses result from child_process APIs

3 participants