Coverage not shown on typescript
See original GitHub issueEnvironment
-
node -v
: v10.16.0 -
npm -v
: 6.9.0 /yarn -v
1.17.3 -
npm ls jest
npm ls jest 180@1.0.0 /Users/jean/dev/startups/yupwego/src/vscode-jest-499 └── jest@24.9.0
-
yarn why jest
yarn why jest yarn why v1.17.3 [1/4] 🤔 Why do we have the module "jest"...? [2/4] 🚚 Initialising dependency graph... [3/4] 🔍 Finding dependency... [4/4] 🚡 Calculating file sizes... => Found "jest@24.9.0" info Has been hoisted to "jest" info This module exists because it's specified in "devDependencies". info Disk size without dependencies: "48KB" info Disk size with unique dependencies: "276KB" info Disk size with transitive dependencies: "51.21MB" info Number of shared dependencies: 43 ✨ Done in 0.57s.
-
your vscode-jest settings if customized:
- “jest.showCoverageOnLoad”: true
-
Operating system: OSX Mojave 10.14.6
-
installed vscode extensions
code --list-extensions
AndrewRazumovsky.vscode-styled-jsx-languageserver
andys8.jest-snippets
Arjun.swagger-viewer
blanu.vscode-styled-jsx
christian-kohler.npm-intellisense
dbaeumer.vscode-eslint
DotJoshJohnson.xml
eamodio.gitlens
EditorConfig.EditorConfig
eg2.vscode-npm-script
eriklynd.json-tools
esbenp.prettier-vscode
file-icons.file-icons
joaompinto.asciidoctor-vscode
lightbend.vscode-sbt-scala
mrorz.language-gettext
ms-azuretools.vscode-docker
Orta.vscode-jest
PKief.material-icon-theme
ryu1kn.partial-diff
scala-lang.scala
scalameta.metals
skyran.js-jsx-snippets
stkb.rewrap
vscode-icons-team.vscode-icons
wayou.vscode-todo-highlight
xabikos.ReactSnippets
Prerequisite
- are you able to run jest test from command line?
yarn jest yarn run v1.17.3 $ /Users/jean/dev/startups/yupwego/src/vscode-jest-499/node_modules/.bin/jest PASS src/capitalize/capitalize.test.ts capitalize ✓ should throw for null (4ms) ✓ should throw for things which aren't strings (1ms) ✓ should not change capitalized word (1ms) ✓ should capitalize the first letter of a lowercase word ✓ should lowercase the tail of an uppercase word (1ms) ----------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ----------|----------|----------|----------|----------|-------------------| All files | 100 | 100 | 100 | 100 | | index.ts | 100 | 100 | 100 | 100 | | ----------|----------|----------|----------|----------|-------------------| 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
git clone https://github.com/jeantil/vscode-jest-499.git
cd vscode-jest-499
yarn install
yarn jest
code .
Relevant Debug Info
I don’t see any errors in self-diagnosis output 😦
[Extension Host] spawning process with command=/Users/jean/dev/startups/yupwego/src/vscode-jest-499/node_modules/.bin/jest, args=--testLocationInResults,--json,--useStderr,--outputFile,/var/folders/gt/c0_8ryzj2m7fwmf07t68z0940000gn/T/jest_runner_vscode_jest_181.json,--watch,--no-color
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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Code coverage is not showing on Sonarqube for Typescript
While I run the unit tests with jest, they are all passing and code coverage was about 80%. On Sonarqube it is still...
Read more >Javascript/Typescript test coverage - SonarQube Documentation
SonarQube supports the reporting of test coverage information as part of the analysis of your JS/TS project. However, SonarQube does not generate the...
Read more >coverage for some .ts files shown as zero coverage - SonarQube
This explain why you see 0% on some test files. Once these files will be correctly considered as test files, no coverage data...
Read more >typescript-coverage-report - npm
Node command tool to generate TypeScript coverage report.. Latest version: 0.7.0, last published: a month ago.
Read more >Configuring Code Coverage for TypeScript Files in Jest
The second one is going to be not with the exclamation points source/**/*.d.ts. We're telling it to collect coverage from all your typescript...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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;
Add this to package.json
(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)
Changing
--watch
to--watchAll
solved my problem.