Skip to content

GUI cover rate with istanbul

Yuqi Wu edited this page Oct 17, 2016 · 2 revisions

Client-side cover

npm install istanbul --save (or babel-istanbul if the es6 is used)

./node_modules/.bin/babel-istanbul instrument --output=_output_dir_ _source_dir_ --complete-copy --preserve-comment -x "_exclude files in regex_"

I suggest instrument code by module, not by project, in case that some special global variable is missing.

in client-side:

window.__coverage__

to parse the window.coverage


to save the coverage

npm install file-saver --save

var fs = require('file-saver');
var blob = new Blob([JSON.stringify(window.__coverage__)], {type: "text/plain;charset=utf-8"});
fs.saveAs(blob, "hello world.txt");

Clone this wiki locally