diff --git a/index.js b/index.js index 178006c92..4e2c990a5 100755 --- a/index.js +++ b/index.js @@ -453,7 +453,8 @@ NYC.prototype.report = function () { this.reporter.forEach((_reporter) => { tree.visit(reports.create(_reporter, { - skipEmpty: this.config.skipEmpty + skipEmpty: this.config.skipEmpty, + skipFull: this.config.skipFull }), context) }) diff --git a/lib/config-util.js b/lib/config-util.js index ff404c01d..62e1af1d0 100644 --- a/lib/config-util.js +++ b/lib/config-util.js @@ -227,6 +227,12 @@ Config.buildYargs = function (cwd) { type: 'boolean', global: false }) + .option('skip-full', { + describe: 'don\'t show files with 100% statement, branch, and function coverage', + default: false, + type: 'boolean', + global: false + }) .pkgConf('nyc', cwd) .example('$0 npm test', 'instrument your tests with coverage') .example('$0 --require babel-core/register npm test', 'instrument your tests with coverage and transpile with Babel') diff --git a/test/fixtures/cli/skip-full.js b/test/fixtures/cli/skip-full.js new file mode 100644 index 000000000..6fa00f726 --- /dev/null +++ b/test/fixtures/cli/skip-full.js @@ -0,0 +1,2 @@ +require('./empty') +require('./half-covered') \ No newline at end of file diff --git a/test/nyc-bin.js b/test/nyc-bin.js index c3081b258..ad311a481 100644 --- a/test/nyc-bin.js +++ b/test/nyc-bin.js @@ -998,6 +998,38 @@ describe('the nyc cli', function () { }) }) + describe('skip-full', () => { + it('does not display files with 100% statement, branch, and function coverage', (done) => { + const args = [ + bin, + '--skip-full', + process.execPath, './skip-full.js' + ] + + const proc = spawn(process.execPath, args, { + cwd: fixturesCLI, + env: env + }) + + var stdout = '' + proc.stdout.on('data', function (chunk) { + stdout += chunk + }) + + proc.on('close', function (code) { + code.should.equal(0) + stdoutShouldEqual(stdout, ` + -----------------|----------|----------|----------|----------|-------------------| + File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | + -----------------|----------|----------|----------|----------|-------------------| + All files | 62.5 | 50 | 100 | 62.5 | | + half-covered.js | 50 | 50 | 100 | 50 | 6,7,8 | + -----------------|----------|----------|----------|----------|-------------------|`) + done() + }) + }) + }) + describe('merge', () => { it('combines multiple coverage reports', (done) => { const args = [