istanbul
istanbul copied to clipboard
Empty coverage directory, no errors
Running istanbul -v cover test/test-foo.js
shows several Module load hook: transform
messages (one for each of my files in ./lib
) and it creates a ./coverage
directory, but it's empty when the process exits. There are no other messages after the transform messages.
I'm not using any special test runner like mocha, test/test-foo.js
just executes various test cases against/using files from ./lib
.
I'm also executing istanbul on Windows if that makes any difference.
Are you loading your test cases in a subprocess?
I am also having the same issue.. i run istanbul against a folder which has jasmine unit test cases written.. all the test cases are executed and an empty coverage folder is generated.
May i know the solution on how to fix this?
@mscdex any fix did you get for the above??
@gotwarlost Any suggesstion?
@gotwarlost Can you please help in resolving the same?
There is too little information for me to guess as to what is going on. Some things that can interfere with coverage are:
- running tests in subprocesses
- an exit handler for the process being set which somehow stops the istanbul exit handler from writing the reports
I've got the same behaviour, I'm running
istanbul cover _mocha
and I get
No coverage information was collected, exit without writing coverage information
and an empty coverage directory.
On the contrary, if I cd
to the default test
directory and run the following command
istanbul cover _mocha -- .
I get the summary and coverage file in place in the root directory.
I'm having the same issue and it can be fixed, as @cacplate states, by cd'ing into the test directory and running from there:
istanbul cover _mocha -- ./
To recreate...
- create a default express app
- place unit test in
test/lib/test.api.js
- place module in
lib/api.js
From project root:
$ istanbul cover _mocha -- ./tests/*
[TypeError: Cannot read property 'Kerberos' of undefined]
API
no error
✓ get tasks
User
no error
username: test-12345
✓ find a user by username
2 passing (130ms)
No coverage information was collected, exit without writing coverage information
From inside the tests directory:
$ istanbul cover _mocha -- ./*
[TypeError: Cannot read property 'Kerberos' of undefined]
API
no error
✓ get tasks
User
no error
username: test-12345
✓ find a user by username
2 passing (155ms)
=============================================================================
Writing coverage object [/path/to/projects/tests/coverage/coverage.json]
Writing coverage reports at [/path/to/projects/tests/coverage]
=============================================================================
=============================== Coverage summary ===============================
Statements : 95% ( 38/40 )
Branches : 50% ( 2/4 )
Functions : 100% ( 15/15 )
Lines : 100% ( 38/38 )
================================================================================
Stack details:
- node v5.5.0
- npm 2.11.3
- mocha 2.4.5
- istanbul 0.4.2
- mocha-istanbul 0.2.0
- should 8.2.1
If running istanbul
inside test
directory works, then
istanbul cover --root test _mocha
in parent directory should probably work.
I am also having the same issue. I am using istanbul with mocha.
By the way, my coverage reports were creating before.
But now not creating. I'm using below command.
$ npm run cover
There is below my package.json:
"scripts": { "test": "node_modules/.bin/mocha --reporter spec", "cover": "node node_modules/istanbul/lib/cli.js cover node_modules/mocha/bin/_mocha -R" },
Tests are run successful. But coverage directory is empty.
Edit: I solved my problem. Problem is a infinite loop in my test code. Thanks...
The problem is, Mocha is not exiting after its execution. So coverage report is unable to printout as the execution id hold by mocha. In Script of package.json mention --exit after mocha. EX- nyc --reporter=html --reporter=text mocha --exit
The problem is, Mocha is not exiting after its execution. So coverage report is unable to printout as the execution id hold by mocha. In Script of package.json mention --exit after mocha. EX- nyc --reporter=html --reporter=text mocha --exit
it solved. thanks