Skip to content

Commit 893345a

Browse files
authored
feat: allow rows with 100% statement, branch, and function coverage to be skipped in text report (#859)
1 parent f09cf02 commit 893345a

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,8 @@ NYC.prototype.report = function () {
453453

454454
this.reporter.forEach((_reporter) => {
455455
tree.visit(reports.create(_reporter, {
456-
skipEmpty: this.config.skipEmpty
456+
skipEmpty: this.config.skipEmpty,
457+
skipFull: this.config.skipFull
457458
}), context)
458459
})
459460

lib/config-util.js

+6
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ Config.buildYargs = function (cwd) {
227227
type: 'boolean',
228228
global: false
229229
})
230+
.option('skip-full', {
231+
describe: 'don\'t show files with 100% statement, branch, and function coverage',
232+
default: false,
233+
type: 'boolean',
234+
global: false
235+
})
230236
.pkgConf('nyc', cwd)
231237
.example('$0 npm test', 'instrument your tests with coverage')
232238
.example('$0 --require babel-core/register npm test', 'instrument your tests with coverage and transpile with Babel')

test/fixtures/cli/skip-full.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require('./empty')
2+
require('./half-covered')

test/nyc-bin.js

+32
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,38 @@ describe('the nyc cli', function () {
998998
})
999999
})
10001000

1001+
describe('skip-full', () => {
1002+
it('does not display files with 100% statement, branch, and function coverage', (done) => {
1003+
const args = [
1004+
bin,
1005+
'--skip-full',
1006+
process.execPath, './skip-full.js'
1007+
]
1008+
1009+
const proc = spawn(process.execPath, args, {
1010+
cwd: fixturesCLI,
1011+
env: env
1012+
})
1013+
1014+
var stdout = ''
1015+
proc.stdout.on('data', function (chunk) {
1016+
stdout += chunk
1017+
})
1018+
1019+
proc.on('close', function (code) {
1020+
code.should.equal(0)
1021+
stdoutShouldEqual(stdout, `
1022+
-----------------|----------|----------|----------|----------|-------------------|
1023+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
1024+
-----------------|----------|----------|----------|----------|-------------------|
1025+
All files | 62.5 | 50 | 100 | 62.5 | |
1026+
half-covered.js | 50 | 50 | 100 | 50 | 6,7,8 |
1027+
-----------------|----------|----------|----------|----------|-------------------|`)
1028+
done()
1029+
})
1030+
})
1031+
})
1032+
10011033
describe('merge', () => {
10021034
it('combines multiple coverage reports', (done) => {
10031035
const args = [

0 commit comments

Comments
 (0)