Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow rows with 100% statement, branch, and function coverage to be skipped in text report #859

Merged
merged 3 commits into from Jun 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
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
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
@@ -0,0 +1,2 @@
require('./empty')
require('./half-covered')
32 changes: 32 additions & 0 deletions test/nyc-bin.js
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