feat(coverage): v8 to track node:child_process and node:worker_threads contexts#9976
feat(coverage): v8 to track node:child_process and node:worker_threads contexts#9976AriPerkkio wants to merge 3 commits intovitest-dev:mainfrom
node:child_process and node:worker_threads contexts#9976Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
88a5c08 to
fa35cd5
Compare
@vitest/browser
@vitest/browser-playwright
@vitest/browser-preview
@vitest/browser-webdriverio
@vitest/coverage-istanbul
@vitest/coverage-v8
@vitest/expect
@vitest/mocker
@vitest/pretty-format
@vitest/runner
@vitest/snapshot
@vitest/spy
@vitest/ui
@vitest/utils
vitest
@vitest/web-worker
@vitest/ws-client
commit: |
fef5aec to
188a95f
Compare
70f7641 to
3d1dce2
Compare
ed25468 to
66e52a1
Compare
fb7116a to
c0a7985
Compare
| import { loadProvider } from './load-provider' | ||
|
|
||
| const session = new inspector.Session() | ||
| let session: inspector.Session | null = null |
There was a problem hiding this comment.
This used to create unused new Session() on main thread too, oops.
b97e821 to
63acca7
Compare
63acca7 to
92ab430
Compare
|
|
||
| Collect coverage only for files changed since a specified commit or branch. When set to `true`, it uses staged and unstaged changes. | ||
|
|
||
| ## coverage.trackProcessAndWorker |
There was a problem hiding this comment.
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. 🙃
There was a problem hiding this comment.
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
There was a problem hiding this comment.
In debugging world there is also --follow-forks mode (in C), in vscode it's autoAttachChildProcesses (although it also follows workers)
There was a problem hiding this comment.
How about autoAttachChildContext? Or autoAttachWorkers and imply Worker is processes too. 🤔
92ab430 to
c1073e1
Compare
c1073e1 to
2eb5e8d
Compare
| } | ||
|
|
||
| if (this.extendedContextCoverageDir) { | ||
| const filenames = await readdir(this.extendedContextCoverageDir) |
There was a problem hiding this comment.
This directory doesn't exist when there are no children spawned and this happens:
$ pnpm -C examples/basic test --coverage --coverage.autoAttachWorkers
> @vitest/example-test@ test /home/hiroshi/code/others/vitest-wt1/examples/basic
> vitest --coverage --coverage.autoAttachWorkers
DEV v4.1.4 /home/hiroshi/code/others/vitest-wt1/examples/basic
Coverage enabled with v8
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Vitest caught 2 unhandled errors during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Test Run Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: ENOENT: no such file or directory, scandir '/home/hiroshi/code/others/vitest-wt1/examples/basic/coverage/tmp/af48afe8-e4b0-4810-b7b2-e6dbea470389'
❯ readdir node:internal/fs/promises:956:18
❯ Object.takeCoverage ../../packages/coverage-v8/dist/index.js:50:22
❯ TestRunner.testRunner.onAfterRunFiles ../../packages/vitest/dist/chunks/index.DtMvdosS.js:173:20
❯ startTests ../../packages/runner/dist/chunk-artifact.js:3281:3
❯ ../../packages/vitest/dist/chunks/base.DuCI8aBZ.js:90:5
❯ run ../../packages/vitest/dist/chunks/base.DuCI8aBZ.js:81:2
❯ runBaseTests ../../packages/vitest/dist/chunks/base.DuCI8aBZ.js:200:2
❯ executeTests ../../packages/vitest/dist/chunks/init-forks.UV3ZQGQH.js:29:4
❯ execute ../../packages/vitest/dist/chunks/init.D98-gwRW.js:158:3
❯ process.onMessage ../../packages/vitest/dist/chunks/init.D98-gwRW.js:287:14| } | ||
|
|
||
| if (this.extendedContextCoverageDir) { | ||
| const filenames = await readdir(this.extendedContextCoverageDir) |
There was a problem hiding this comment.
Also does this ensure the coverage json emitted by children to be collected only once? Looks like multiple takeCoverage calls (maybe isolate false) can read the same json and sent as coverage.
Description
@vitest/web-workererror when using browser environment #4899Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.