From 8b01b63740d7af75fe83d0164c0f18021592e1a6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 17 Feb 2021 23:48:29 +0200 Subject: [PATCH] feat: add --skip-full (#287) --- lib/commands/report.js | 3 +- lib/parse-args.js | 5 ++++ lib/report.js | 10 ++++--- test/integration.js_10.snap | 58 ++++++++++++++++++------------------- 4 files changed, 42 insertions(+), 34 deletions(-) diff --git a/lib/commands/report.js b/lib/commands/report.js index 766283a3..ac750a2d 100644 --- a/lib/commands/report.js +++ b/lib/commands/report.js @@ -22,7 +22,8 @@ exports.outputReport = async function (argv) { wrapperLength: argv.wrapperLength, all: argv.all, allowExternal: argv.allowExternal, - src: argv.src + src: argv.src, + skipFull: argv.skipFull }) await report.run() if (argv.checkCoverage) await checkCoverages(argv, report) diff --git a/lib/parse-args.js b/lib/parse-args.js index 90f68439..b188b858 100644 --- a/lib/parse-args.js +++ b/lib/parse-args.js @@ -101,6 +101,11 @@ function buildYargs (withCommands = false) { describe: 'supplying --src will override cwd as the default location where --all looks for src files. --src can be ' + 'supplied multiple times and each directory will be included. This allows for workspaces spanning multiple projects' }) + .options('skip-full', { + default: false, + type: 'boolean', + describe: 'do not show files with 100% statement, branch, and function coverage' + }) .pkgConf('c8') .config(config) .demandCommand(1) diff --git a/lib/report.js b/lib/report.js index 3b95194f..a8d97219 100644 --- a/lib/report.js +++ b/lib/report.js @@ -25,7 +25,8 @@ class Report { resolve: resolvePaths, all, src, - allowExternal = false + allowExternal = false, + skipFull }) { this.reporter = reporter this.reportsDirectory = reportsDirectory @@ -42,6 +43,7 @@ class Report { this.wrapperLength = wrapperLength this.all = all this.src = this._getSrc(src) + this.skipFull = skipFull } _getSrc (src) { @@ -61,13 +63,13 @@ class Report { coverageMap: await this.getCoverageMapFromAllCoverageFiles() }) - this.reporter.forEach(function (_reporter) { + for (const _reporter of this.reporter) { reports.create(_reporter, { skipEmpty: false, - skipFull: false, + skipFull: this.skipFull, maxCols: 100 }).execute(context) - }) + } } async getCoverageMapFromAllCoverageFiles () { diff --git a/test/integration.js_10.snap b/test/integration.js_10.snap index 64cdbf15..ab8d5982 100644 --- a/test/integration.js_10.snap +++ b/test/integration.js_10.snap @@ -139,24 +139,24 @@ hey --------------------------|---------|----------|---------|---------|-------------------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s --------------------------|---------|----------|---------|---------|-------------------------------- -All files | 72.64 | 58.23 | 61.11 | 72.64 | +All files | 72.94 | 58.23 | 61.11 | 72.94 | bin | 78.85 | 60 | 66.67 | 78.85 | c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51 - lib | 75.95 | 51.85 | 71.43 | 75.95 | + lib | 76.25 | 51.85 | 71.43 | 76.25 | is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9 - parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133 - report.js | 75.35 | 58.82 | 83.33 | 75.35 | ...208,238-239,266-267,273-275 + parse-args.js | 96.25 | 45.45 | 100 | 96.25 | 114-115,123-124,137-138 + report.js | 75.52 | 58.82 | 83.33 | 75.52 | ...210,240-241,268-269,275-277 source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98 - lib/commands | 44.44 | 75 | 16.67 | 44.44 | + lib/commands | 45.05 | 75 | 16.67 | 45.05 | check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61 - report.js | 93.1 | 71.43 | 50 | 93.1 | 9-10 + report.js | 93.33 | 71.43 | 50 | 93.33 | 9-10 test/fixtures | 83.33 | 85.71 | 66.67 | 83.33 | async.js | 100 | 100 | 100 | 100 | normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20 --------------------------|---------|----------|---------|---------|-------------------------------- -,ERROR: Coverage for lines (72.64%) does not meet global threshold (101%) +,ERROR: Coverage for lines (72.94%) does not meet global threshold (101%) ERROR: Coverage for branches (58.23%) does not meet global threshold (82%) -ERROR: Coverage for statements (72.64%) does not meet global threshold (95%) +ERROR: Coverage for statements (72.94%) does not meet global threshold (95%) " `; @@ -166,17 +166,17 @@ ERROR: Coverage for branches (60%) does not meet threshold (82%) for bin/c8.js ERROR: Coverage for statements (78.85%) does not meet threshold (95%) for bin/c8.js ERROR: Coverage for lines (21.31%) does not meet threshold (101%) for lib/commands/check-coverage.js ERROR: Coverage for statements (21.31%) does not meet threshold (95%) for lib/commands/check-coverage.js -ERROR: Coverage for lines (93.1%) does not meet threshold (101%) for lib/commands/report.js +ERROR: Coverage for lines (93.33%) does not meet threshold (101%) for lib/commands/report.js ERROR: Coverage for branches (71.43%) does not meet threshold (82%) for lib/commands/report.js -ERROR: Coverage for statements (93.1%) does not meet threshold (95%) for lib/commands/report.js +ERROR: Coverage for statements (93.33%) does not meet threshold (95%) for lib/commands/report.js ERROR: Coverage for lines (90%) does not meet threshold (101%) for lib/is-cjs-esm-bridge.js ERROR: Coverage for branches (25%) does not meet threshold (82%) for lib/is-cjs-esm-bridge.js ERROR: Coverage for statements (90%) does not meet threshold (95%) for lib/is-cjs-esm-bridge.js -ERROR: Coverage for lines (96.13%) does not meet threshold (101%) for lib/parse-args.js +ERROR: Coverage for lines (96.25%) does not meet threshold (101%) for lib/parse-args.js ERROR: Coverage for branches (45.45%) does not meet threshold (82%) for lib/parse-args.js -ERROR: Coverage for lines (75.35%) does not meet threshold (101%) for lib/report.js +ERROR: Coverage for lines (75.52%) does not meet threshold (101%) for lib/report.js ERROR: Coverage for branches (58.82%) does not meet threshold (82%) for lib/report.js -ERROR: Coverage for statements (75.35%) does not meet threshold (95%) for lib/report.js +ERROR: Coverage for statements (75.52%) does not meet threshold (95%) for lib/report.js ERROR: Coverage for lines (45%) does not meet threshold (101%) for lib/source-map-from-file.js ERROR: Coverage for statements (45%) does not meet threshold (95%) for lib/source-map-from-file.js ERROR: Coverage for lines (100%) does not meet threshold (101%) for test/fixtures/async.js @@ -189,9 +189,9 @@ ERROR: Coverage for statements (75%) does not meet threshold (95%) for test/fixt exports[`c8 check-coverage exits with 0 if coverage within threshold 1`] = `",,"`; exports[`c8 check-coverage exits with 1 if coverage is below threshold 1`] = ` -",,ERROR: Coverage for lines (72.64%) does not meet global threshold (101%) +",,ERROR: Coverage for lines (72.94%) does not meet global threshold (101%) ERROR: Coverage for branches (58.23%) does not meet global threshold (82%) -ERROR: Coverage for statements (72.64%) does not meet global threshold (95%) +ERROR: Coverage for statements (72.94%) does not meet global threshold (95%) " `; @@ -274,17 +274,17 @@ exports[`c8 report generates report from existing temporary files 1`] = ` ",--------------------------|---------|----------|---------|---------|-------------------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s --------------------------|---------|----------|---------|---------|-------------------------------- -All files | 72.64 | 58.23 | 61.11 | 72.64 | +All files | 72.94 | 58.23 | 61.11 | 72.94 | bin | 78.85 | 60 | 66.67 | 78.85 | c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51 - lib | 75.95 | 51.85 | 71.43 | 75.95 | + lib | 76.25 | 51.85 | 71.43 | 76.25 | is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9 - parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133 - report.js | 75.35 | 58.82 | 83.33 | 75.35 | ...208,238-239,266-267,273-275 + parse-args.js | 96.25 | 45.45 | 100 | 96.25 | 114-115,123-124,137-138 + report.js | 75.52 | 58.82 | 83.33 | 75.52 | ...210,240-241,268-269,275-277 source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98 - lib/commands | 44.44 | 75 | 16.67 | 44.44 | + lib/commands | 45.05 | 75 | 16.67 | 45.05 | check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61 - report.js | 93.1 | 71.43 | 50 | 93.1 | 9-10 + report.js | 93.33 | 71.43 | 50 | 93.33 | 9-10 test/fixtures | 83.33 | 85.71 | 66.67 | 83.33 | async.js | 100 | 100 | 100 | 100 | normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20 @@ -296,24 +296,24 @@ exports[`c8 report supports --check-coverage, when generating reports 1`] = ` ",--------------------------|---------|----------|---------|---------|-------------------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s --------------------------|---------|----------|---------|---------|-------------------------------- -All files | 72.64 | 58.23 | 61.11 | 72.64 | +All files | 72.94 | 58.23 | 61.11 | 72.94 | bin | 78.85 | 60 | 66.67 | 78.85 | c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51 - lib | 75.95 | 51.85 | 71.43 | 75.95 | + lib | 76.25 | 51.85 | 71.43 | 76.25 | is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9 - parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133 - report.js | 75.35 | 58.82 | 83.33 | 75.35 | ...208,238-239,266-267,273-275 + parse-args.js | 96.25 | 45.45 | 100 | 96.25 | 114-115,123-124,137-138 + report.js | 75.52 | 58.82 | 83.33 | 75.52 | ...210,240-241,268-269,275-277 source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98 - lib/commands | 44.44 | 75 | 16.67 | 44.44 | + lib/commands | 45.05 | 75 | 16.67 | 45.05 | check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61 - report.js | 93.1 | 71.43 | 50 | 93.1 | 9-10 + report.js | 93.33 | 71.43 | 50 | 93.33 | 9-10 test/fixtures | 83.33 | 85.71 | 66.67 | 83.33 | async.js | 100 | 100 | 100 | 100 | normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20 --------------------------|---------|----------|---------|---------|-------------------------------- -,ERROR: Coverage for lines (72.64%) does not meet global threshold (101%) +,ERROR: Coverage for lines (72.94%) does not meet global threshold (101%) ERROR: Coverage for branches (58.23%) does not meet global threshold (82%) -ERROR: Coverage for statements (72.64%) does not meet global threshold (95%) +ERROR: Coverage for statements (72.94%) does not meet global threshold (95%) " `;