SBoudrias / gulp-istanbul

Istanbul unit test coverage plugin for gulp.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Yet another "nothing covered" (with gulp-mocha 4.x)

cedx opened this issue · comments

I'm using the "gulp-mocha" plugin to run my unit tests (which are ES6 modules processed by Babel). Everything worked fine until I decided to upgrade this plugin to the latest version (v4.0.0).

Now my coverage report is always empty. It seems that this new version of "gulp-mocha" does not play well with your plugin.

Any idea how I can restore the coverage report? Do you know any alternative?
I don't wish to downgrade the "gulp-mocha" plugin.

Here is my "gulpfile.js" (see the test tasks):
https://github.com/cedx/akismet.js/blob/master/gulpfile.js

+1.

Both running istanbul from CLI or downgrading gulp-mocha to 3.x.x fixes the issue.

gulp-mocha 4 doesn't run mocha in the same process (it spawns the mocha cli on the command line). As such, istanbul.hookRequire() won't work anymore.

I'm not sure how given the new gulp-mocha workflow you'd get this setup to work at all.

You can write the covered files to disk so mocha read them, but then I'm unsure how you'd go about retrieving the coverage data who'll be local to the mocha process and unaccessible.

Running istanbul from CLI [...] fixes the issue.
...
gulp-mocha 4 [...] spawns the mocha cli on the command line

The more I use Gulp, the less I can take advantage of its streaming possibilities 😥

To be honest with you, I'm really rarely using gulp anymore. I find it easier to use tools with more built in capacity - like jest for testing, webpack for compilation, etc.

Finally fixed my issue by:

  • replacing gulp-mocha plugin by a direct call to the mocha CLI
  • replacing gulp-istanbul plugin by a direct call to nyc (aka the Istanbul CLI)

I still want to thank you @SBoudrias : your plugin has been very useful to me for a long time. Do I keep this issue open?

French PS (off-topic) : idem de mon côté Simon, je me rends compte qu'au fur et à mesure mes builds Gulp ne font plus grand'chose qu'appeler des binaires CLI... Je songe sérieusement à me contenter des scripts NPM pour lancer mes opérations de build, Gulp n'étant devenu qu'une surcouche presque inutile. Même si je ne vais vraisemblablement plus utiliser gulp-istanbul, encore une fois merci pour les efforts consacrés à ce plugin (je sais que s'investir dans l'Open Source est très chronophage, et ne rapporte pas grand'chose... à part l'estime de ses pairs).

I close this issue since the problem is not really related to this project.

commented

This issue is still referenced in the readme file, would be nice to keep it open or at least refer in the readme to the open issue in gulp-mocha module.

Why is this still an issue?

Locking conversation to prevent being spammed.

  1. gulp-istanbul cannot work with gulp-mocha@4.x.x. Architectural changes made to gulp-mocha made it stop using files inside the pipe, so it will run your tests, but doesn't work in a gulp way anymore.
  2. I do not use gulp anymore, and suggest you to drop it too. Alternative suggestions: use jest or mocha and nyc directly.
  3. If someone wants to maintains this project, you can reach out to me.