embark/scripts/coverage-report.js
Michael Bradley, Jr ad01d1402c test: collect code coverage in the root of the monorepo
Implement scripts to collect coverage reports (JSON format) from all packages
in the monorepo that generate such reports. Reports are copied to
`<root>/.nyc_output/coverage-[pkg-dir-name].json`.

Implement scripts to generate a combined html report in `<root>/coverage`.

Adjust root `reset` and `clean` scripts to delete `<root>/.nyc_output` and
`<root>/coverage`.

Implement a script in `<root>/package.json` to generate a `text-lcov` report
and upload it to coveralls from CI builds. Remove coveralls from
`packages/embark`.

Supply `packages/embark` with an nyc configuration in its `package.json` and
have its `"test":` script generate both `json` and `html` reports.

Use nyc with `embarkjs`'s test suite: supply an nyc configuration in its
`package.json` and have its `"test":` script generate both `json` and `html`
reports.

Adjust `embarkjs`'s tests for more accurate coverage reporting.
2019-04-30 12:04:01 -04:00

16 lines
493 B
JavaScript

/* global __dirname require */
const fs = require('fs-extra');
const {execSync} = require('child_process');
const path = require('path');
const rimraf = require('util').promisify(require('rimraf'));
const reportDir = path.join(__dirname, '../coverage');
const cmd = `npx nyc report --reporter=html --report-dir=${reportDir}`;
(async () => {
await fs.mkdirp(reportDir);
await rimraf(path.join(reportDir, '*'));
execSync(cmd, {cwd: path.join(__dirname, '..'), stdio: 'inherit'});
})();