From 05d6ce060518216b304b0f3605858aa0cc1e056d Mon Sep 17 00:00:00 2001 From: Jesse Ditson Date: Tue, 22 Nov 2016 17:46:52 -0800 Subject: [PATCH] add include option to add additional coverage to the report --- README.md | 2 ++ lib/attach-middleware.js | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 68b72b2e..3c75821f 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,8 @@ Configuration is optional. It should be put in a file at `config/coverage.js`. - `excludes`: Defaults to `['*/mirage/**/*']`. An array of globs to exclude from instrumentation. Useful to exclude files from coverage statistics. +- `include`: Array of coverage json files to include in the final report generated by istanbul. These files are the output of a separate `istanbul` or `nyc` report, e.g. if you run server tests in a postBuild hook. + - `coverageFolder`: Defaults to `coverage`. A folder relative to the root of your project to store coverage results. - `useBabelInstrumenter`: Defaults to `false`. Whether or not to use Babel instrumenter instead of default instrumenter. The Babel instrumenter is useful when you are using features of ESNext as it uses your Babel configuration defined in `ember-cli-build.js`. diff --git a/lib/attach-middleware.js b/lib/attach-middleware.js index b3134497..448d06ef 100644 --- a/lib/attach-middleware.js +++ b/lib/attach-middleware.js @@ -22,6 +22,12 @@ module.exports = function(app, options) { collector.add(req.body); + if (_config.include) { + _config.include.forEach(function(file) { + collector.add(fs.readJSONSync(path.join(options.root, file))); + }); + } + if (_config.reporters.indexOf('json-summary') === -1) { _config.reporters.push('json-summary'); }