jest --watch doesn't show coverage in Vue
See original GitHub issueš Bug Report
Running jest --watch in a Vue project with collectCoverage: true and collectCoverageFrom: ['src/**/*.{js,vue}'] doesnāt show coverage.
It works as expected when running just jest, but problem arises when running jest --watch
To Reproduce
Run jest & jest --watch in the reproduction repo
Expected behavior
jest works as expected, shows coverage info
> jest
PASS src/test.js
test
ā test (3ms)
------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
------------|----------|----------|----------|----------|-------------------|
All files | 57.14 | 50 | 0 | 57.14 | |
src | 0 | 100 | 100 | 0 | |
index.js | 0 | 100 | 100 | 0 | 2,3,5 |
src/App | 72.73 | 50 | 0 | 72.73 | |
index.vue | 72.73 | 50 | 0 | 72.73 | 7,8,11 |
------------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 5.748s
Ran all test suites.
jest --watch does not show any coverage
> jest --watch
PASS src/test.js
test
ā test (7ms)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 0 | 0 | 0 | 0 | |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 5.985s
Ran all test suites.
Watch Usage: Press w to show more.
Link to repl or repo (highly encouraged)
Repro: https://github.com/laggingreflex/repro-vue-jest-template
Run npx envinfo --preset jest
System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
Node: 10.15.0
npm: 6.4.1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:14
Top Results From Across the Web
Jest does not collect coverage from vue files (nuxt)
For me, there is no logical explanation why coverage is collected from JavaScript files but not from vue files.
Read more >Jest+Vue: no coverage shown for .vue files that don't include ...
According to the code, it happens when nothing executed in a file. It's possible to set a breakpoint there (in node_modules/istanbul-lib-source-maps/lib/Ā ...
Read more >No coverage for .vue files when using Jest - Get Help
I'm using vue-test-utils with Jest to test single-file Vue components. ... included in the coverage report, just the format used to display.
Read more >Configuring Jest
js"] will not exclude __tests__ because the negation is overwritten with the second pattern. In order to make the negated glob work in...
Read more >vscode-jest - Visual Studio Marketplace
Help debug jest tests in vscode. Show coverage information in files being tested. Supports monorepo, react, react-native, vue and variousĀ ...
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 Free
Top 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

at this stage, I think this is actually a feature.
āwatch is meant to run tests only on files that both:
āwatchAll runs all tests on every file change.
IMO itās just a little confusing for newbies (like myself) when using --watch and seeing no output. Perhaps this is an opportunity for clarification in the docs to make it absolutely obvious?? at this stage, i donāt think itās a bug. In fact itās actually quite smart as it wont waste time running tests on files that have not changed.
Same here in React after upgrade react-scripts 2.1.8 => 3.0.0
And I try to use create-react-app to creat an new app, copy my code and paste in new-app folder. Run āreact-scripts test --coverageā again. It works!?
Then I copy all code include ānode_modulesā in new-app folder and paste in my old object. No coverage again, always be empty
???
envinfo