Reputation: 7963
Hi all I am trying to get the mocha chai Unit test coverage report.
I am getting the test result passed.
Also generated the coverage as html but, it showing Unknown. Please see below image .
Package.json
added the below config in script.
"scripts": {
"test": "mocha",
"test-with-coverage": "nyc --reporter=html mocha"
},
And using the below command for run the test.
npm run test-with-coverage
Edit: When change report as text , getting the below report in terminal.
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 0 | 0 | 0 |
----------|---------|----------|---------|---------|-------------------
Upvotes: 2
Views: 2874
Reputation: 638
Please try with the below command,
nyc -x \"**/tests/**\" --reporter=cobertura --reporter=html mocha 'your test folder path'
Upvotes: 3