istanbul-jpm
Istanbul Instrumenter and coverage export for Firefox Add-on SDK extensions tested with JPM.
Installation
Run npm install --save-dev istanbul-jpm
in the root of your extension directory.
Usage
The index of this module exports the Instrumenter from istanbul adapted for use
with JPM. It does so by storing the coverage variable in a special object, that
gets written to the disk after all tests are done. This means, that this module
has to be packaged into the XPI file when running jpm test
to measure coverage.
Note that istanbul doesn't need to be packaged with it.
var Instrumenter = Instrumenter;
The "global" that the Instrumenter wrote to can be accessed in node like this:
const g = global;
The module reads the data from the disk and returns it in object form on the "global" property.
You might want to set the directory used to pass the coverage information from
the extension back to node using the environment variable coveragedir
. By
default, it will use node's and Firefox's idea of the system's temp directory.
It is known that those do not match up on Max OS X.
Example usage with grunt-istanbul
Also uses grunt-shell to launch jpm test
.
module { var istanbulJpm = ; // Make sure Firefox writes the coverage info to the same dir we'll read from. processenvcoveragedir = ; grunt; grunt; grunt; grunt; grunt;};