question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What does reloadTasks do with regard to __coverage__?

See original GitHub issue

I’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:open
  • Created 10 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
robertgrohcommented, Jan 25, 2016

@reefath, no reloadTasks is need for normal test coverage - it is only used to test grunt-istanbul itself.

As I stated above (quoting myself: https://github.com/taichi/grunt-istanbul/issues/16#issuecomment-48204815), either:

  • your test don’t use the instrumented files during the coverage run, or
  • your tests are run by a other process as the grunt tasks

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 task storeCoverage. And with the makeReport 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.

For further help please provide your gruntfile (as a new issue with more details).

@wheresrhys & @taichi: I think this issue can & should be closed.

1reaction
robertgrohcommented, Jul 7, 2014

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:

  • your test don’t use the instrumented files in build/instrument/src/
  • your tests are run by a other process as the grunt tasks

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 task storeCoverage. And with the makeReport 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:

testem: {
        env: {
            src: [
                'src/**/*.js',

use another grunt task target to specify the instrumented files:

testem: {
        env: { ... },
        coverage: {
            src: [
                'build/instrument/src/**/*.js',
                'test/**/*.js'
             ],
             ...
         }
}

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 the makeReport tasks.

I hope this helps. For further support, you have to tell us more about your project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

System alerts - Qlik | Help
System alerts check the status of reload tasks in Qlik Sense and provide early warning when things are not working as intended (failed...
Read more >
Review Pinning/Load Balancing - Qlik Sense Admin Playbook
This guide will cover two specific scenarios (2 and 3) from above and link ... the vantage of end users, the same principles...
Read more >
getting grunt-istanbul error: No coverage information was ...
I was able to get this working using the Gruntfile.js from the grunt-istanbul project. Their documentation indicates that the reloadTasks is ...
Read more >
Start Qlik Sense reload tasks using MQTT or Butler's REST API
Your browser can 't play this video. Learn more. Switch camera.
Read more >
Grunt tool window | DataSpell Documentation - JetBrains
Choose this menu item to open the Gruntfile.js file for which the current tree is built. Reload tasks. Choose this menu item to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found