The title says it all really. Despite trawling the internet I haven't found a single example of a solution to this problem.
Here are some near misses
- https://github.com/amitayd/grunt-browserify-jasmine-node-example - grunt, browserify and jasmine
- https://github.com/gotwarlost/istanbul/issues/59#issuecomment-18799734 - browserify and istanbul
Here is my in-progress code https://github.com/wheresrhys/on-guard/tree/browserify (note it's the 'browserify' branch - Gruntfile.js is a bit of a mess but will tidy it up shortly). My initial investigations using console.log indicate that somehow bundle.src.js is being loaded in the page but when the tests are run (and passed!) the code in bundle.src.js isn't being run, so I have a feeling it might be an aliasing problem... though one that's limited to phantomjs as when I open the specrunner in chrome the code is getting run.
I'm using
grunt-browserify+browserify-istanbul+grunt-contrib-jasmine+grunt-template-jasmine-istanbulas solution. This solution has also excluded third party libraries when building source files usingbrowserify.Show the code first, I'll explain later,
The steps of generating istanbul coverage report can be concluded into three:
In our solution, we use
browerify-istanbulin step 1,grunt-contrib-jasmineandrunt-template-jasmine-istanbulin step 2 and 3.browserify-istanbulwill let you instrument code in browserify building step, in this way, we can easily ignore third party libs. But thegrunt-template-jasmine-istanbulwill instrument code again. To avoid this, you can setreplacetofalsein the options.Refs:
replaceoption