electron-userland / electron-compilers

DEPRECATED: Compiler implementations for electron-compile
35 stars 55 forks source link

Add optional Istanbul support #65

Closed anaisbetts closed 7 years ago

anaisbetts commented 7 years ago

This allows you to set coverage: true in your TypeScript and Babel options, and get code instrumented by Istanbul. To get the coverage output, then add something like this to your test suite:

after(() => {
  if (!('__coverage__' in window)) return;
  const { Reporter, Collector } = require('istanbul');

  const coll = new Collector();
  coll.add(window.__coverage__);

  const reporter = new Reporter(null, path.join(__dirname, '..', 'coverage'));
  reporter.addAll(['text-summary', 'lcovonly']);

  return new Promise((res) => {
    reporter.write(coll, false, res);
  });
});

This has an advantage in that it works with electron-mocha as well which is v cool.