vscode: Running with coverage produces error
Describe the bug
TypeError: Cannot read properties of null (reading 'result')
at mergeProcessCovs (/workspaces/redacted/node_modules/.pnpm/@bcoe+v8-coverage@0.2.3/node_modules/@bcoe/v8-coverage/dist/lib/merge.js:22:44)
at file:///workspaces/redacted/node_modules/.pnpm/@vitest+coverage-v8@1.4.0_vitest@1.5.0/node_modules/@vitest/coverage-v8/dist/provider.js:266:22
at async Promise.all (index 1)
at async V8CoverageProvider.reportCoverage (file:///workspaces/redacted/node_modules/.pnpm/@vitest+coverage-v8@1.4.0_vitest@1.5.0/node_modules/@vitest/coverage-v8/dist/provider.js:263:11)
at async Vitest.reportCoverage (file:///workspaces/redacted/node_modules/.pnpm/vitest@1.5.0_@types+node@20.12.6_@vitest+ui@1.4.0_jsdom@24.0.0_less@4.1.3_stylus@0.59.0/node_modules/vitest/dist/vendor/cac.qnW6GNL2.js:12014:7)
at async file:///workspaces/redacted/node_modules/.pnpm/vitest@1.5.0_@types+node@20.12.6_@vitest+ui@1.4.0_jsdom@24.0.0_less@4.1.3_stylus@0.59.0/node_modules/vitest/dist/vendor/cac.qnW6GNL2.js:11789:7
at async Vitest.runFiles (file:///workspaces/redacted/node_modules/.pnpm/vitest@1.5.0_@types+node@20.12.6_@vitest+ui@1.4.0_jsdom@24.0.0_less@4.1.3_stylus@0.59.0/node_modules/vitest/dist/vendor/cac.qnW6GNL2.js:11795:12)
at async t.rerunTests (/root/.vscode-server/extensions/vitest.explorer-0.6.0/dist/worker.js:3:4352)
at async t.runTestFiles (/root/.vscode-server/extensions/vitest.explorer-0.6.0/dist/worker.js:3:4153)
at async t.runTests (/root/.vscode-server/extensions/vitest.explorer-0.6.0/dist/worker.js:3:3622)
Reproduction
No repro yet - hoping the stack trace is enough.
Output
[INFO 9:47:27 AM] [v0.6.0] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 9:47:27 AM] [API] Running Vitest: v1.5.0 (/workspaces/WATS/vitest.workspace.ts)
[INFO 9:47:28 AM] [API] Vitest process 22069 created
[Worker] Vitest "cache.dir" is deprecated, use Vite's "cacheDir" instead if you want to change the cache director. Note caches will be written to "cacheDir/vitest"
[Worker] Coverage reports directory is generated: /tmp/vitest-coverage-240cb5ae-b6a8-477a-b9ea-0653864416cf
[INFO 9:47:36 AM] Running all tests in WATS
[INFO 9:48:54 AM] [TEST] run-test: redacted.test.ts redacted 10.31s
[Error 9:49:23 AM] [Error TypeError] TypeError: Cannot read properties of null (reading 'result')
at mergeProcessCovs (/workspaces/redacted/node_modules/.pnpm/@bcoe+v8-coverage@0.2.3/node_modules/@bcoe/v8-coverage/dist/lib/merge.js:22:44)
at file:///workspaces/redacted/node_modules/.pnpm/@vitest+coverage-v8@1.4.0_vitest@1.5.0/node_modules/@vitest/coverage-v8/dist/provider.js:266:22
at async Promise.all (index 1)
at async V8CoverageProvider.reportCoverage (file:///workspaces/redacted/node_modules/.pnpm/@vitest+coverage-v8@1.4.0_vitest@1.5.0/node_modules/@vitest/coverage-v8/dist/provider.js:263:11)
at async Vitest.reportCoverage (file:///workspaces/redacted/node_modules/.pnpm/vitest@1.5.0_@types+node@20.12.6_@vitest+ui@1.4.0_jsdom@24.0.0_less@4.1.3_stylus@0.59.0/node_modules/vitest/dist/vendor/cac.qnW6GNL2.js:12014:7)
at async file:///workspaces/redacted/node_modules/.pnpm/vitest@1.5.0_@types+node@20.12.6_@vitest+ui@1.4.0_jsdom@24.0.0_less@4.1.3_stylus@0.59.0/node_modules/vitest/dist/vendor/cac.qnW6GNL2.js:11789:7
at async Vitest.runFiles (file:///workspaces/redacted/node_modules/.pnpm/vitest@1.5.0_@types+node@20.12.6_@vitest+ui@1.4.0_jsdom@24.0.0_less@4.1.3_stylus@0.59.0/node_modules/vitest/dist/vendor/cac.qnW6GNL2.js:11795:12)
at async t.rerunTests (/root/.vscode-server/extensions/vitest.explorer-0.6.0/dist/worker.js:3:4352)
at async t.runTestFiles (/root/.vscode-server/extensions/vitest.explorer-0.6.0/dist/worker.js:3:4153)
at async t.runTests (/root/.vscode-server/extensions/vitest.explorer-0.6.0/dist/worker.js:3:3622)
Version
v0.6.0
Validations
- Check that you are using the latest version of the extension
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Reactions: 3
- Comments: 21 (5 by maintainers)
Good point. IIUC, the
coverage
here is where the coverage file was first created after each test.coverage
here is returningnull
which explains why we gotnull
from the coverage file.Good news is that I was able to reproduce the error, which was quite unexpected. Based from the provided config files above I can deduce that the root cause of the coverage content being nullish was because of
test.coverage.enabled
was not set totrue
invite.config.ts
. I can consistently reproduce the error message and while you might not need a repro for that, you can use this repo for verification if needed.https://github.com/vitest-dev/vscode/assets/10607759/1cdc3e14-3999-40ca-8571-125c49477089
I’m not sure how to handle this. An easy approach might be to provide some hints or simply enable coverage, regardless of the value of
test.coverage.enabled
invite.config.ts
.Another possible root cause could be incorrect configuration of
vite.workspace.ts
. The workspace config confuses me and I question the need of it.@ffMathy @ludovicmnji By any chance you have multiple configs in your monorepo? When I remove all configs but only one left on the workspace root, it works perfectly
No, but at least we can then speculate and discuss theories around what the root cause could be, and dive into it together.
Is there any way where we can insert some kind of logging to help determine the cause of this?
No, unfortunately not. But as you can see, others are also having the issue, so I think maybe closing this in 3 days seems a bit rushed?