Closed jeantil closed 4 years ago
I have same issue but I can see the coverage for a few moment but it disappear as soon as I switch to another file
I have the exact same issue, both on windows and mac
The root cause for this issue is not in vscode-jest, but in Jest itself. Jest deletes the content of lcov.info when in watch mode and therefore code coverage doesn't work. There are multiple issues reported about this (for example; https://github.com/facebook/jest/issues/7331).
There is a workaround to restore the functionality in vscode-jest;
Add this to VS Code settings.json;
{
"jest.pathToJest": "npm run jest:watchAll --",
"jest.runAllTestsFirst": false,
"jest.showCoverageOnLoad": true
}
Add this to package.json
"scripts": {
"jest:watchAll": "jest --watchAll",
}
(if you don't have the coverage parameters in the Jest configuration file, then you need to add them to the CLI command; https://jestjs.io/docs/en/cli.html)
I haven't found this to be the case, I am able to see the content of Icov.info with every configuration I tried, but without being able to enable the coverage overlay consistently.
Changing --watch
to --watchAll
solved my problem.
On my machine I couldn't see the code lens, only after I tried the workaround I could see the code lens, but still no coverage overlay. I used the repro steps described in this issue.
PS I'm using WSL2 on Windows, distro: Ubuntu 18.04.2 LTS
PSS I can see the icov files and if I use another extension, I can see the coverage from it.
I still dont't reliably get coverage (either lens or overlay) over typescript code in my project.
As I was playing around with the commands i noticed an error popup saying 'invalid arguments' , using the debug mode I got:
Error: Invalid arguments
at new f (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:345)
at new f (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:343)
at t.b.(/usr/lib/code/out/vs/code/electron-browser/workbench/anonymous function).forEach (/home/jean/.vscode-oss/extensions/orta.vscode-jest-3.0.2/out/extension.js:129:58318)
at Array.forEach (<anonymous>)
at Object.keys.forEach.e (/home/jean/.vscode-oss/extensions/orta.vscode-jest-3.0.2/out/extension.js:129)
at Array.forEach (<anonymous>)
at t.DefaultFormatter.formatBranches (/home/jean/.vscode-oss/extensions/orta.vscode-jest-3.0.2/out/extension.js:129)
at t.DefaultFormatter.format (/home/jean/.vscode-oss/extensions/orta.vscode-jest-3.0.2/out/extension.js:129)
at s.update (/home/jean/.vscode-oss/extensions/orta.vscode-jest-3.0.2/out/extension.js:75)
at s.updateVisibleEditors (/home/jean/.vscode-oss/extensions/orta.vscode-jest-3.0.2/out/extension.js:75)
at t.JestExt.triggerUpdateActiveEditor (/home/jean/.vscode-oss/extensions/orta.vscode-jest-3.0.2/out/extension.js:427)
at t.JestExt.updateWithData (/home/jean/.vscode-oss/extensions/orta.vscode-jest-3.0.2/out/extension.js:427)
at t.e.onJestEditorSupportEvent.e (/home/jean/.vscode-oss/extensions/orta.vscode-jest-3.0.2/out/extension.js:427)
at t.emit (events.js:182)
at t.EventEmitter.emit (/usr/lib/code/out/vs/code/electron-browser/workbench/domain.js:442)
at /home/jean/.vscode-oss/extensions/orta.vscode-jest-3.0.2/out/extension.js:129
at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53)
$onExtensionRuntimeError @ mainThreadExtensionService.ts:66
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
_protocol.onMessage.e @ rpcProtocol.ts:101
fire @ event.ts:580
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
_socketDisposables.push._socketReader.onMessage.e @ ipc.net.ts:592
fire @ event.ts:580
acceptChunk @ ipc.net.ts:239
_register._socket.onData.e @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:182
addChunk @ _stream_readable.js:283
readableAddChunk @ _stream_readable.js:264
Readable.push @ _stream_readable.js:219
onStreamRead @ internal/stream_base_commons.js:94
I'm using v3.0.1 of the extension on
Version: 1.39.2
Commit: 6ab598523be7a800d7f3eb4d92d7ab9a66069390
Date: 2019-10-18T10:58:05.878Z
Electron: 4.2.12
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Linux x64 5.3.8-3-MANJARO
@jeantil I fixed the Invalid arguments
bug in #519.
This got better, but there are still problems. In small files, the coverage works fine, but once the file starts getting better, nothing is shown.
For example, on this small file, the coverage is shown as expected:
But here, nothing is highlighted, even though there is 0% coverage:
To see this behavior please clone my repo: git clone https://github.com/sinapis/vscode-jest-499 npm i
under src folder there are two files. evaporator.ts which shows coverage as expected, and brainluck.ts which does not.
P.S. using dev tools i see the following error. @garyking, is this the same issue you already fixed?
mainThreadExtensionService.ts:66 Error: Invalid arguments
at new f (/home/amir/.vscode-server/bin/9579eda04fdb3a9bba2750f15193e5fafe16b959/out/vs/server/remoteExtensionHostProcess.js:380)
at new f (/home/amir/.vscode-server/bin/9579eda04fdb3a9bba2750f15193e5fafe16b959/out/vs/server/remoteExtensionHostProcess.js:378)
at /home/amir/.vscode-server/extensions/orta.vscode-jest-3.0.2/out/extension.js:129
at Array.forEach (
this should be addressed in v3.1.0, feel free to reopen if not...
3.10 solved the problem for me. Cheers!
Environment
node -v
: v10.16.0npm -v
: 6.9.0 /yarn -v
1.17.3npm ls jest
yarn why jest
your vscode-jest settings if customized:
Operating system: OSX Mojave 10.14.6
installed vscode extensions
Prerequisite
Test Suites: 1 passed, 1 total Tests: 5 passed, 5 total Snapshots: 0 total Time: 1.57s Ran all test suites. ✨ Done in 2.53s.
Steps to Reproduce
Relevant Debug Info
I don't see any errors in self-diagnosis output :(
Expected Behavior
overlay coverage on typescript code
Actual Behavior
No overlay appears. in some rare circumstances I can see the following code lens reporting coverage but it disapears as soon as anything changes