Running coverage on untested files...Failed to collect coverage from
See original GitHub issueFollowing code:
function two(one, two?) {
return 3;
}
two('herro');
Results in:
> npx jest --config jestrc.json
PASS test/unit/server.spec.ts
✓ (2 ms)
Running coverage on untested files...Failed to collect coverage from /home/karl/dev/afry/tmr-gateway/src/server.ts
ERROR: /home/karl/dev/afry/tmr-gateway/src/server.ts: Unexpected token, expected "," (1:21)
> 1 | function two(one, two?) {
| ^
2 | return 3;
3 | }
4 |
STACK: SyntaxError: /home/karl/dev/afry/tmr-gateway/src/server.ts: Unexpected token, expected "," (1:21)
> 1 | function two(one, two?) {
| ^
2 | return 3;
3 | }
4 |
at Parser._raise (/home/karl/dev/afry/tmr-gateway/node_modules/@babel/parser/lib/index.js:799:17)
at Parser.raiseWithData (/home/karl/dev/afry/tmr-gateway/node_modules/@babel/parser/lib/index.js:792:17)
at Parser.raise (/home/karl/dev/afry/tmr-gateway/node_modules/@babel/parser/lib/index.js:786:17)
at Parser.unexpected (/home/karl/dev/afry/tmr-gateway/node_modules/@babel/parser/lib/index.js:9089:16)
at Parser.expect (/home/karl/dev/afry/tmr-gateway/node_modules/@babel/parser/lib/index.js:9075:28)
at Parser.parseBindingList (/home/karl/dev/afry/tmr-gateway/node_modules/@babel/parser/lib/index.js:9473:14)
at Parser.parseFunctionParams (/home/karl/dev/afry/tmr-gateway/node_modules/@babel/parser/lib/index.js:12322:24)
at Parser.parseFunction (/home/karl/dev/afry/tmr-gateway/node_modules/@babel/parser/lib/index.js:12297:10)
at Parser.parseFunctionStatement (/home/karl/dev/afry/tmr-gateway/node_modules/@babel/parser/lib/index.js:11925:17)
at Parser.parseStatementContent (/home/karl/dev/afry/tmr-gateway/node_modules/@babel/parser/lib/index.js:11615:21)
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 100 | 100 | 0 |
argh.ts | 0 | 100 | 100 | 0 | 1
----------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.263 s
Ran all test suites.
But the following code:
function two(one) {
return 3;
}
two('herro');
Results in:
> npx jest --config jestrc.json
PASS test/unit/server.spec.ts
✓ (1 ms)
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 0 | 100 | 0 | 0 |
src | 0 | 100 | 0 | 0 |
server.ts | 0 | 100 | 0 | 0 | 2-5
test/unit | 0 | 100 | 100 | 0 |
argh.ts | 0 | 100 | 100 | 0 | 1
------------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.227 s
Ran all test suites.
package.json:
{
"name": "tmr-gateway",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"clean": "npx shx rm -rf dist coverage report",
"build": "npx shx rm -rf dist && npx tsc",
"lint:check": "npx eslint .",
"lint:fix": "npx eslint . --fix",
"style:check": "npx prettier --check .",
"style:fix": "npx prettier --write .",
"test": "npx jest --config jestrc.json"
},
"author": "",
"license": "",
"devDependencies": {
"@types/jest": "26.0.15",
"cross-env": "7.0.2",
"eslint": "7.12.1",
"jest": "26.6.1",
"jest-junit": "12.0.0",
"jsdoc": "3.6.6",
"nodemon": "2.0.6",
"prettier": "2.1.2",
"shx": "0.3.3",
"typescript": "4.0.5"
},
"dependencies": {
"express": "4.17.1"
}
}
jest config:
{
"bail": 1,
"verbose": true,
"collectCoverage": true,
"coverageReporters": ["json", "lcov", "text", "clover"],
"collectCoverageFrom": ["src/**/*.{ts,tsx}", "test/**/*.{ts,tsx}"],
"reporters": [
"default",
[
"jest-junit",
{
"outputDirectory": "report",
"outputName": "junit.xml"
}
]
]
}
Running on Linux ubuntu 16.04.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Jest finds tests but doesn't collect coverage - Stack Overflow
The quick fix I said in my comment, using --watchAll instead, eg: react-scripts test --coverage --watchAll . Just for future reference, ...
Read more >Configuring code coverage in Jest, the right way
Code coverage makes possible to spot untested paths in our code. It is an important metric for determining the health of a project....
Read more >Coverage | Code Cookbook - Michael Currin
Rather than only collecting coverage metrics for scripts and specs that run, include untested files as part of the coverage stats. A solution...
Read more >@jobber/jest-a-coverage-slip-detector - npm
Any slips in test coverage will fail out the CI command. Note that this will happen for either legacy files not meeting their...
Read more >Jest · Delightful JavaScript Testing
Tests are parallelized by running them in their own processes to maximize ... code coverage information from entire projects, including untested files.
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
This is a jest setting
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.