Skip to content

Commit

Permalink
feat: allow rows with 100% statement, branch, and function coverage t…
Browse files Browse the repository at this point in the history
…o be skipped in text report (#859)
  • Loading branch information
bcoe authored Jun 8, 2018
1 parent f09cf02 commit 893345a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand Down
6 changes: 6 additions & 0 deletions lib/config-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/cli/skip-full.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require('./empty')
require('./half-covered')
32 changes: 32 additions & 0 deletions test/nyc-bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 893345a

Please sign in to comment.