edit: a few months later I migrated over to Lab completely, it works great, including coverage. Maybe at the time I wrote this Lab didn't have a good coverage tool.
I've gotten this working before. Was working this morning. Suddenly, it's not.
Tests are in dist/test/unit.js
. 15 tests that cover 80.29% of code (based on Lab's coverage reports). But we are setup to use Istanbul with Sonar, so I need to get it working with Istanbul again. I prefer Istanbul's reports anyway.
I'm running the tests with:
./node_modules/.bin/istanbul cover ./node_modules/.bin/lab -- -l -e development -r lcov dist/test
The tests run. All pass. The screen output is a coverage report:
...
DA:801,1
DA:802,1
DA:803,1
DA:804,1
DA:805,1
DA:806,1
DA:807,1
LF:774
LH:738
end_of_record
No coverage information was collected, exit without writing coverage information
Why is this telling me that no coverage was collected? How do I get these two tools to play nicely together again?
Getting rid of -r lcov
doesn't really help. There is no output in ./coverage
(the default folder) either way. I can force it by piping but when I run that output to istanbul (report option) I get Error: Invalid report format [coverage/cover.info]
It seems like the coverage report that's being generated is invalid. How would I know?
The resolution on this one is not very satisfying. I checked out some old code and it worked, so I started with one test and skipped the rest and used this command:
./node_modules/.bin/istanbul cover ./node_modules/.bin/lab -- -l -e development ./dist/test/unit.js
Then I removed the skip from the tests one by one. In the end, the coverage report worked with all the tests. No idea what the actual issue was that was stopping Istanbul from collecting coverage information yesterday.
The only thing that I can think of was that I removed rm -rf coverage
from my npm command (it was: transpile, remove coverage, run coverage, open coverage report; in one npm command separated with semicolons). Perhaps that was blocking Istanbul from writing coverage artifacts?