Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k
stars
785
forks
source link
Istanbul refuses to generate coverage report even after requiring other files #907
OK, what you want to do is to track coverage for the running server code when you hit it with test endpoints right?
Just be aware of what code is getting instrumented and reported on (the server-side code) and istanbul should work for you (unfortunately with an option that is somehow not documented)
What you need is this sequence (there is no need to pre-instrument the code). I'll show you how I did this manually and you can figure out how to automate it:
This runs the server under istanbul cover and instructs istanbul to handle interrupts (Control-C) and dump the coverage information + reports when the process exits.
Step 2: Run your tests, no need to run under istanbul
Step 4: Open the HTML coverage report under coverage/lcov-report/index.html
Step 5: Profit!
This solved my problem - almost.
I still see that this doesn't produce report for all files in the repo. In another post I saw that Istanbul requires files to be required explicitly to produce a report for files that are not executed. But I see that event if , in this case - server.js - has required all files that I have, Istanbul ignores them if there is not a call made to those files.
My starting point was the answer to Issue #574
This solved my problem - almost.
I still see that this doesn't produce report for all files in the repo. In another post I saw that Istanbul requires files to be required explicitly to produce a report for files that are not executed. But I see that event if , in this case - server.js - has required all files that I have, Istanbul ignores them if there is not a call made to those files.
Is there a way to get around this issue?