From decc60db3c7e8ee1e52cf9989f26cfb0ae2150cd Mon Sep 17 00:00:00 2001 From: Benjamin Date: Wed, 6 Jun 2018 13:54:17 -0700 Subject: [PATCH 1/3] feat: allow rows with 100% statement, branch, and function coverage to be ignored in report --- index.js | 3 ++- lib/config-util.js | 6 ++++++ test/nyc-bin.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) 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/nyc-bin.js b/test/nyc-bin.js index c3081b258..d23264d18 100644 --- a/test/nyc-bin.js +++ b/test/nyc-bin.js @@ -998,6 +998,36 @@ 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, './instrumented/s2.min.js' + ] + + const proc = spawn(process.execPath, args, { + cwd: fixturesSourceMaps, + 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 | + ----------|----------|----------|----------|----------|-------------------| + ----------|----------|----------|----------|----------|-------------------|`) + done() + }) + }) + }) + describe('merge', () => { it('combines multiple coverage reports', (done) => { const args = [ From a69f71977f475af65b5f8584f7db56f51070a563 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Thu, 7 Jun 2018 17:39:46 -0700 Subject: [PATCH 2/3] chore: address @coreyfarrell's code review --- test/nyc-bin.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/nyc-bin.js b/test/nyc-bin.js index d23264d18..ad311a481 100644 --- a/test/nyc-bin.js +++ b/test/nyc-bin.js @@ -1003,11 +1003,11 @@ describe('the nyc cli', function () { const args = [ bin, '--skip-full', - process.execPath, './instrumented/s2.min.js' + process.execPath, './skip-full.js' ] const proc = spawn(process.execPath, args, { - cwd: fixturesSourceMaps, + cwd: fixturesCLI, env: env }) @@ -1019,10 +1019,12 @@ describe('the nyc cli', function () { proc.on('close', function (code) { code.should.equal(0) stdoutShouldEqual(stdout, ` - ----------|----------|----------|----------|----------|-------------------| - File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | - ----------|----------|----------|----------|----------|-------------------| - ----------|----------|----------|----------|----------|-------------------|`) + -----------------|----------|----------|----------|----------|-------------------| + 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() }) }) From ade97c2151df8160cda26fb6b256e270272d3394 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Thu, 7 Jun 2018 17:39:55 -0700 Subject: [PATCH 3/3] chore: address @coreyfarrell's code review --- test/fixtures/cli/skip-full.js | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 test/fixtures/cli/skip-full.js 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