What does reloadTasks do with regard to __coverage__?
See original GitHub issueI’m trying to implement an istanbul report on code that’s bundled using browserify, using the approach recommended here https://github.com/gotwarlost/istanbul/issues/59#issuecomment-18799734. I’ve completed every recommended step (I instrument my src, bundle it, then bundle my test files and get them to reference the instrumented src bundle), but using grunt-istanbul ,my reports are always empty.
If I run reloadTasks
on my instrumented src files (as you do in your gruntfile) then I do get a report, but it evidently doesn’t use my bundled, instrumented src as the results show no code was run even though all the tests run and pass. If I don’t run reloadTasks I get Fatal error: No coverage information was collected
when running storeCoverage
.
All the code is here https://github.com/wheresrhys/on-guard/tree/browserify (note that it’s the ‘browserify’ branch)
Issue Analytics
- State:
- Created 10 years ago
- Comments:7
@reefath, no
reloadTasks
is need for normal test coverage - it is only used to testgrunt-istanbul
itself.As I stated above (quoting myself: https://github.com/taichi/grunt-istanbul/issues/16#issuecomment-48204815), either:
For further help please provide your gruntfile (as a new issue with more details).
@wheresrhys & @taichi: I think this issue can & should be closed.
Hi Santiago,
I feel your pain, I took me a while to grok istanbul (and this grunt-plugin).
Regarding your problem, there are two case for this error:
Istanbul instruments the src files in such a way, that they write the coverage information in a global variable (default: coverage), during their execution. The value of this global variable can then be write to a
.json
file by the taskstoreCoverage
. And with themakeReport
task, you generate the coverage report in different formats (lcov, html, cobertura) out of the.json
files.Therefore the test run have to use the instrumented files instead of the normal source files (file path for
require()
statements - show us your test files). And also the step, when you want to write out the coverage information to.json
files, you have to be in the same process as the test run, to access the global variable__coverage__
.I think for your gruntfile, that both cases apply (I don’t know testem, so bear with me, if I am wrong).
You let the run against the normal src files:
use another grunt task target to specify the instrumented files:
Also it seems to me, that you try to run the tests in a browser (chrome). This will not work with the
storeCoverage
task. The process in which the task runs (grunt node.js process) is another as the testrun of your (client side?) javascript (chrome process).So you have to store the coverage information in an other way (cf. https://github.com/gotwarlost/istanbul/issues/16#issuecomment-9879731).
Some use a afterAll/tearDown method or a separate test case, which will be run at last by their testing framework, to write the content of the global
__coverage__
variable to.json
files, which can be be used by themakeReport
tasks.I hope this helps. For further support, you have to tell us more about your project.