From cbf5d38b4641cb196ae4747233f716966c101bd9 Mon Sep 17 00:00:00 2001 From: bcoe Date: Wed, 29 Dec 2021 22:41:22 -0500 Subject: [PATCH 1/3] fix(config): support configuration inheritance --- lib/parse-args.js | 6 +++++- test/fixtures/config/.c8rc-base.json | 4 ++++ test/fixtures/config/.c8rc.json | 3 ++- test/parse-args.js | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/config/.c8rc-base.json diff --git a/lib/parse-args.js b/lib/parse-args.js index 72eb7b7d..cf881639 100644 --- a/lib/parse-args.js +++ b/lib/parse-args.js @@ -2,6 +2,7 @@ const defaultExclude = require('@istanbuljs/schema/default-exclude') const findUp = require('find-up') const { readFileSync } = require('fs') const Yargs = require('yargs/yargs') +const { applyExtends } = require('yargs/helpers') const parser = require('yargs-parser') const { resolve } = require('path') @@ -12,7 +13,10 @@ function buildYargs (withCommands = false) { alias: 'c', config: true, describe: 'path to JSON configuration file', - configParser: (path) => JSON.parse(readFileSync(path)), + configParser: (path) => { + const config = JSON.parse(readFileSync(path)) + return applyExtends(config, process.cwd(), true) + }, default: () => findUp.sync(['.c8rc', '.c8rc.json', '.nycrc', '.nycrc.json']) }) .option('reporter', { diff --git a/test/fixtures/config/.c8rc-base.json b/test/fixtures/config/.c8rc-base.json new file mode 100644 index 00000000..d314f753 --- /dev/null +++ b/test/fixtures/config/.c8rc-base.json @@ -0,0 +1,4 @@ +{ + "extends": "./test/fixtures/config/.c8rc.json", + "branches": 55 +} diff --git a/test/fixtures/config/.c8rc.json b/test/fixtures/config/.c8rc.json index 1d481b7f..7676378b 100644 --- a/test/fixtures/config/.c8rc.json +++ b/test/fixtures/config/.c8rc.json @@ -1,4 +1,5 @@ { "temp-directory": "./foo", - "lines": 101 + "lines": 101, + "functions": 24 } diff --git a/test/parse-args.js b/test/parse-args.js index 57271a05..ab8f4d99 100644 --- a/test/parse-args.js +++ b/test/parse-args.js @@ -57,5 +57,11 @@ describe('parse-args', () => { const argv = buildYargs().parse(['node', 'c8', '--lines', '100', '--config', require.resolve('./fixtures/config/.c8rc.json')]) argv.lines.should.be.equal(100) }) + it('should allow config files to extend each other', () => { + const argv = buildYargs().parse(['node', 'c8', '--lines', '100', '--config', require.resolve('./fixtures/config/.c8rc-base.json')]) + argv.branches.should.be.equal(55) + argv.lines.should.be.equal(100) + argv.functions.should.be.equal(24) + }) }) }) From fd6742f399fe3eb554394d0ea2f0cc324b147e72 Mon Sep 17 00:00:00 2001 From: bcoe Date: Wed, 29 Dec 2021 23:21:02 -0500 Subject: [PATCH 2/3] chore: run Node 10 snapshots --- test/integration.js_10.snap | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/integration.js_10.snap b/test/integration.js_10.snap index ad3a0e01..1a665c5f 100644 --- a/test/integration.js_10.snap +++ b/test/integration.js_10.snap @@ -175,12 +175,12 @@ hey --------------------------|---------|----------|---------|---------|-------------------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s --------------------------|---------|----------|---------|---------|-------------------------------- -All files | 73.37 | 59.03 | 62.5 | 73.37 | +All files | 73.5 | 59.03 | 62.5 | 73.5 | bin | 78.84 | 60 | 66.66 | 78.84 | c8.js | 78.84 | 60 | 66.66 | 78.84 | 22,27-29,32-33,41-43,50-51 - lib | 77.88 | 54.38 | 72 | 77.88 | + lib | 78.02 | 54.38 | 72 | 78.02 | is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9 - parse-args.js | 97.1 | 58.33 | 100 | 97.1 | 148-149,170-171,184-185 + parse-args.js | 97.15 | 58.33 | 100 | 97.15 | 152-153,174-175,188-189 report.js | 75.31 | 58.33 | 78.57 | 75.31 | ...249,276-277,283-285,306-311 source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98 lib/commands | 41.28 | 66.66 | 16.66 | 41.28 | @@ -190,9 +190,9 @@ All files | 73.37 | 59.03 | 62.5 | 73.37 | async.js | 100 | 100 | 100 | 100 | normal.js | 75 | 66.66 | 33.33 | 75 | 14-16,18-20 --------------------------|---------|----------|---------|---------|-------------------------------- -,ERROR: Coverage for lines (73.37%) does not meet global threshold (101%) +,ERROR: Coverage for lines (73.5%) does not meet global threshold (101%) ERROR: Coverage for branches (59.03%) does not meet global threshold (82%) -ERROR: Coverage for statements (73.37%) does not meet global threshold (95%) +ERROR: Coverage for statements (73.5%) does not meet global threshold (95%) " `; @@ -208,7 +208,7 @@ ERROR: Coverage for statements (80%) does not meet threshold (95%) for lib/comma 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 (97.1%) does not meet threshold (101%) for lib/parse-args.js +ERROR: Coverage for lines (97.15%) does not meet threshold (101%) for lib/parse-args.js ERROR: Coverage for branches (58.33%) does not meet threshold (82%) for lib/parse-args.js ERROR: Coverage for lines (75.31%) does not meet threshold (101%) for lib/report.js ERROR: Coverage for branches (58.33%) does not meet threshold (82%) for lib/report.js @@ -223,19 +223,19 @@ ERROR: Coverage for statements (75%) does not meet threshold (95%) for test/fixt `; exports[`c8 check-coverage check-coverage command with --100 1`] = ` -",,ERROR: Coverage for lines (77.22%) does not meet global threshold (100%) +",,ERROR: Coverage for lines (77.33%) does not meet global threshold (100%) ERROR: Coverage for functions (66.66%) does not meet global threshold (100%) ERROR: Coverage for branches (62.35%) does not meet global threshold (100%) -ERROR: Coverage for statements (77.22%) does not meet global threshold (100%) +ERROR: Coverage for statements (77.33%) does not meet global threshold (100%) " `; 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 (73.37%) does not meet global threshold (101%) +",,ERROR: Coverage for lines (73.5%) does not meet global threshold (101%) ERROR: Coverage for branches (59.03%) does not meet global threshold (82%) -ERROR: Coverage for statements (73.37%) does not meet global threshold (95%) +ERROR: Coverage for statements (73.5%) does not meet global threshold (95%) " `; @@ -318,12 +318,12 @@ exports[`c8 report generates report from existing temporary files 1`] = ` ",--------------------------|---------|----------|---------|---------|-------------------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s --------------------------|---------|----------|---------|---------|-------------------------------- -All files | 73.37 | 59.03 | 62.5 | 73.37 | +All files | 73.5 | 59.03 | 62.5 | 73.5 | bin | 78.84 | 60 | 66.66 | 78.84 | c8.js | 78.84 | 60 | 66.66 | 78.84 | 22,27-29,32-33,41-43,50-51 - lib | 77.88 | 54.38 | 72 | 77.88 | + lib | 78.02 | 54.38 | 72 | 78.02 | is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9 - parse-args.js | 97.1 | 58.33 | 100 | 97.1 | 148-149,170-171,184-185 + parse-args.js | 97.15 | 58.33 | 100 | 97.15 | 152-153,174-175,188-189 report.js | 75.31 | 58.33 | 78.57 | 75.31 | ...249,276-277,283-285,306-311 source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98 lib/commands | 41.28 | 66.66 | 16.66 | 41.28 | @@ -340,12 +340,12 @@ exports[`c8 report supports --check-coverage, when generating reports 1`] = ` ",--------------------------|---------|----------|---------|---------|-------------------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s --------------------------|---------|----------|---------|---------|-------------------------------- -All files | 73.37 | 59.03 | 62.5 | 73.37 | +All files | 73.5 | 59.03 | 62.5 | 73.5 | bin | 78.84 | 60 | 66.66 | 78.84 | c8.js | 78.84 | 60 | 66.66 | 78.84 | 22,27-29,32-33,41-43,50-51 - lib | 77.88 | 54.38 | 72 | 77.88 | + lib | 78.02 | 54.38 | 72 | 78.02 | is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9 - parse-args.js | 97.1 | 58.33 | 100 | 97.1 | 148-149,170-171,184-185 + parse-args.js | 97.15 | 58.33 | 100 | 97.15 | 152-153,174-175,188-189 report.js | 75.31 | 58.33 | 78.57 | 75.31 | ...249,276-277,283-285,306-311 source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98 lib/commands | 41.28 | 66.66 | 16.66 | 41.28 | @@ -355,9 +355,9 @@ All files | 73.37 | 59.03 | 62.5 | 73.37 | async.js | 100 | 100 | 100 | 100 | normal.js | 75 | 66.66 | 33.33 | 75 | 14-16,18-20 --------------------------|---------|----------|---------|---------|-------------------------------- -,ERROR: Coverage for lines (73.37%) does not meet global threshold (101%) +,ERROR: Coverage for lines (73.5%) does not meet global threshold (101%) ERROR: Coverage for branches (59.03%) does not meet global threshold (82%) -ERROR: Coverage for statements (73.37%) does not meet global threshold (95%) +ERROR: Coverage for statements (73.5%) does not meet global threshold (95%) " `; From d58f21222052a31086f39cdcde395a062c62e257 Mon Sep 17 00:00:00 2001 From: bcoe Date: Thu, 30 Dec 2021 00:02:45 -0500 Subject: [PATCH 3/3] chore: retake snapshot --- test/integration.js_10.snap | 599 ++++++++++++++++++++++++++++++++++++ 1 file changed, 599 insertions(+) diff --git a/test/integration.js_10.snap b/test/integration.js_10.snap index e69de29b..07c4afb0 100644 --- a/test/integration.js_10.snap +++ b/test/integration.js_10.snap @@ -0,0 +1,599 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`c8 /* c8 ignore next */ does not incorrectly mark previous branch as uncovered (see #254) 1`] = ` +",--------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +--------------|---------|----------|---------|---------|------------------- +All files | 100 | 100 | 100 | 100 | + issue-254.js | 100 | 100 | 100 | 100 | +--------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 /* c8 ignore next */ ignores lines with special comment 1`] = ` +",covered +covered +-------------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-------------------|---------|----------|---------|---------|------------------- +All files | 90.9 | 100 | 100 | 90.9 | + c8-ignore-next.js | 90.9 | 100 | 100 | 90.9 | 21-22 +-------------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 /* c8 ignore start/stop */ ignores lines with special comment 1`] = ` +",covered +covered +-------------------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-------------------------|---------|----------|---------|---------|------------------- +All files | 100 | 75 | 100 | 100 | + c8-ignore-start-stop.js | 100 | 75 | 100 | 100 | 2 +-------------------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 --all reports coverage for unloaded js files as 0 for line, branch and function 1`] = ` +",zero +positive +negative +--------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +--------------|---------|----------|---------|---------|------------------- +All files | 64.28 | 66.66 | 50 | 64.28 | + vanilla | 78.26 | 75 | 100 | 78.26 | + loaded.js | 73.68 | 71.42 | 100 | 73.68 | 4-5,16-18 + main.js | 100 | 100 | 100 | 100 | + vanilla/dir | 0 | 0 | 0 | 0 | + unloaded.js | 0 | 0 | 0 | 0 | 1-5 +--------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 --all reports coverage for unloaded transpiled ts files as 0 for line, branch and function 1`] = ` +",zero +positive +negative +-----------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-----------------|---------|----------|---------|---------|------------------- +All files | 64.28 | 57.14 | 50 | 64.28 | + ts-compiled | 78.26 | 66.66 | 100 | 78.26 | + loaded.ts | 73.68 | 66.66 | 100 | 73.68 | 4-5,16-18 + main.ts | 100 | 100 | 100 | 100 | + ts-compiled/dir | 0 | 0 | 0 | 0 | + unloaded.ts | 0 | 0 | 0 | 0 | 1-5 +-----------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 --all reports coverage for unloaded ts files as 0 for line, branch and function when using ts-node 1`] = ` +",zero +positive +negative +--------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +--------------|---------|----------|---------|---------|------------------- +All files | 75 | 77.77 | 66.66 | 75 | + ts-only | 91.3 | 87.5 | 100 | 91.3 | + loaded.ts | 89.47 | 83.33 | 100 | 89.47 | 8-9 + main.ts | 100 | 100 | 100 | 100 | + ts-only/dir | 0 | 0 | 0 | 0 | + unloaded.ts | 0 | 0 | 0 | 0 | 1-5 +--------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 --all should allow for --all to be used in conjunction with --check-coverage 1`] = ` +",zero +positive +negative +--------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +--------------|---------|----------|---------|---------|------------------- +All files | 64.28 | 66.66 | 50 | 64.28 | + vanilla | 78.26 | 75 | 100 | 78.26 | + loaded.js | 73.68 | 71.42 | 100 | 73.68 | 4-5,16-18 + main.js | 100 | 100 | 100 | 100 | + vanilla/dir | 0 | 0 | 0 | 0 | + unloaded.js | 0 | 0 | 0 | 0 | 1-5 +--------------|---------|----------|---------|---------|------------------- +,ERROR: Coverage for lines (64.28%) does not meet global threshold (100%) +ERROR: Coverage for branches (66.66%) does not meet global threshold (82%) +ERROR: Coverage for statements (64.28%) does not meet global threshold (95%) +" +`; + +exports[`c8 --all should allow for --all to be used with the check-coverage command (2 invocations) 1`] = ` +",,ERROR: Coverage for lines (64.28%) does not meet global threshold (90%) +ERROR: Coverage for branches (66.66%) does not meet global threshold (82%) +ERROR: Coverage for statements (64.28%) does not meet global threshold (95%) +" +`; + +exports[`c8 --exclude-after-remap applies exclude rules after source-maps are applied 1`] = ` +",reachable +a = true +a = false +-------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-------------|---------|----------|---------|---------|------------------- +All files | 100 | 100 | 100 | 100 | + branch-2.js | 100 | 100 | 100 | 100 | +-------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 --extension includes coverage when extensions specified 1`] = ` +",hey +i am a line of code +what +hey +what +hey +what +hey +--------------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +--------------------|---------|----------|---------|---------|------------------- +All files | 83.33 | 85.71 | 66.66 | 83.33 | + async.js | 100 | 100 | 100 | 100 | + custom-ext.special | 75 | 66.66 | 33.33 | 75 | 14-16,18-20 +--------------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 check-coverage --100 1`] = ` +",hey +i am a line of code +what +hey +what +hey +what +hey +-----------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-----------|---------|----------|---------|---------|------------------- +All files | 83.33 | 85.71 | 66.66 | 83.33 | + async.js | 100 | 100 | 100 | 100 | + normal.js | 75 | 66.66 | 33.33 | 75 | 14-16,18-20 +-----------|---------|----------|---------|---------|------------------- +,ERROR: Coverage for lines (83.33%) does not meet global threshold (100%) +ERROR: Coverage for functions (66.66%) does not meet global threshold (100%) +ERROR: Coverage for branches (85.71%) does not meet global threshold (100%) +ERROR: Coverage for statements (83.33%) does not meet global threshold (100%) +" +`; + +exports[`c8 check-coverage allows --check-coverage when executing script 1`] = ` +",hey +i am a line of code +what +hey +what +hey +what +hey +--------------------------|---------|----------|---------|---------|-------------------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +--------------------------|---------|----------|---------|---------|-------------------------------- +All files | 73.72 | 59.03 | 62.5 | 73.72 | + bin | 78.84 | 60 | 66.66 | 78.84 | + c8.js | 78.84 | 60 | 66.66 | 78.84 | 22,27-29,32-33,41-43,50-51 + lib | 78.32 | 54.38 | 72 | 78.32 | + is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9 + parse-args.js | 97.24 | 58.33 | 100 | 97.24 | 159-160,181-182,195-196 + report.js | 75.47 | 58.33 | 78.57 | 75.47 | ...251,278-279,285-287,308-313 + source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98 + lib/commands | 41.44 | 66.66 | 16.66 | 41.44 | + check-coverage.js | 18.57 | 100 | 0 | 18.57 | 9-11,14-36,39-53,55-70 + report.js | 80.48 | 62.5 | 50 | 80.48 | 9-10,15-20 + test/fixtures | 83.33 | 85.71 | 66.66 | 83.33 | + async.js | 100 | 100 | 100 | 100 | + normal.js | 75 | 66.66 | 33.33 | 75 | 14-16,18-20 +--------------------------|---------|----------|---------|---------|-------------------------------- +,ERROR: Coverage for lines (73.72%) does not meet global threshold (101%) +ERROR: Coverage for branches (59.03%) does not meet global threshold (82%) +ERROR: Coverage for statements (73.72%) does not meet global threshold (95%) +" +`; + +exports[`c8 check-coverage allows threshold to be applied on per-file basis 1`] = ` +",,ERROR: Coverage for lines (78.84%) does not meet threshold (101%) for bin/c8.js +ERROR: Coverage for branches (60%) does not meet threshold (82%) for bin/c8.js +ERROR: Coverage for statements (78.84%) does not meet threshold (95%) for bin/c8.js +ERROR: Coverage for lines (18.57%) does not meet threshold (101%) for lib/commands/check-coverage.js +ERROR: Coverage for statements (18.57%) does not meet threshold (95%) for lib/commands/check-coverage.js +ERROR: Coverage for lines (80.48%) does not meet threshold (101%) for lib/commands/report.js +ERROR: Coverage for branches (62.5%) does not meet threshold (82%) for lib/commands/report.js +ERROR: Coverage for statements (80.48%) 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 (97.24%) does not meet threshold (101%) for lib/parse-args.js +ERROR: Coverage for branches (58.33%) does not meet threshold (82%) for lib/parse-args.js +ERROR: Coverage for lines (75.47%) does not meet threshold (101%) for lib/report.js +ERROR: Coverage for branches (58.33%) does not meet threshold (82%) for lib/report.js +ERROR: Coverage for statements (75.47%) 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 +ERROR: Coverage for lines (75%) does not meet threshold (101%) for test/fixtures/normal.js +ERROR: Coverage for branches (66.66%) does not meet threshold (82%) for test/fixtures/normal.js +ERROR: Coverage for statements (75%) does not meet threshold (95%) for test/fixtures/normal.js +" +`; + +exports[`c8 check-coverage check-coverage command with --100 1`] = ` +",,ERROR: Coverage for lines (77.51%) does not meet global threshold (100%) +ERROR: Coverage for functions (66.66%) does not meet global threshold (100%) +ERROR: Coverage for branches (62.35%) does not meet global threshold (100%) +ERROR: Coverage for statements (77.51%) does not meet global threshold (100%) +" +`; + +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 (73.72%) does not meet global threshold (101%) +ERROR: Coverage for branches (59.03%) does not meet global threshold (82%) +ERROR: Coverage for statements (73.72%) does not meet global threshold (95%) +" +`; + +exports[`c8 cobertura report escapes special characters 1`] = ` +" + + + + /foo/file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +" +`; + +exports[`c8 collects coverage for script with shebang 1`] = ` +",hello world +------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +------------|---------|----------|---------|---------|------------------- +All files | 75 | 50 | 100 | 75 | + shebang.js | 75 | 50 | 100 | 75 | 7-8 +------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 merges reports from subprocesses together 1`] = ` +",first + +second + +-------------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-------------------|---------|----------|---------|---------|------------------- +All files | 100 | 100 | 100 | 100 | + multiple-spawn.js | 100 | 100 | 100 | 100 | + subprocess.js | 100 | 100 | 100 | 100 | +-------------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 report generates report from existing temporary files 1`] = ` +",--------------------------|---------|----------|---------|---------|-------------------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +--------------------------|---------|----------|---------|---------|-------------------------------- +All files | 73.72 | 59.03 | 62.5 | 73.72 | + bin | 78.84 | 60 | 66.66 | 78.84 | + c8.js | 78.84 | 60 | 66.66 | 78.84 | 22,27-29,32-33,41-43,50-51 + lib | 78.32 | 54.38 | 72 | 78.32 | + is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9 + parse-args.js | 97.24 | 58.33 | 100 | 97.24 | 159-160,181-182,195-196 + report.js | 75.47 | 58.33 | 78.57 | 75.47 | ...251,278-279,285-287,308-313 + source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98 + lib/commands | 41.44 | 66.66 | 16.66 | 41.44 | + check-coverage.js | 18.57 | 100 | 0 | 18.57 | 9-11,14-36,39-53,55-70 + report.js | 80.48 | 62.5 | 50 | 80.48 | 9-10,15-20 + test/fixtures | 83.33 | 85.71 | 66.66 | 83.33 | + async.js | 100 | 100 | 100 | 100 | + normal.js | 75 | 66.66 | 33.33 | 75 | 14-16,18-20 +--------------------------|---------|----------|---------|---------|-------------------------------- +," +`; + +exports[`c8 report supports --check-coverage, when generating reports 1`] = ` +",--------------------------|---------|----------|---------|---------|-------------------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +--------------------------|---------|----------|---------|---------|-------------------------------- +All files | 73.72 | 59.03 | 62.5 | 73.72 | + bin | 78.84 | 60 | 66.66 | 78.84 | + c8.js | 78.84 | 60 | 66.66 | 78.84 | 22,27-29,32-33,41-43,50-51 + lib | 78.32 | 54.38 | 72 | 78.32 | + is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9 + parse-args.js | 97.24 | 58.33 | 100 | 97.24 | 159-160,181-182,195-196 + report.js | 75.47 | 58.33 | 78.57 | 75.47 | ...251,278-279,285-287,308-313 + source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98 + lib/commands | 41.44 | 66.66 | 16.66 | 41.44 | + check-coverage.js | 18.57 | 100 | 0 | 18.57 | 9-11,14-36,39-53,55-70 + report.js | 80.48 | 62.5 | 50 | 80.48 | 9-10,15-20 + test/fixtures | 83.33 | 85.71 | 66.66 | 83.33 | + async.js | 100 | 100 | 100 | 100 | + normal.js | 75 | 66.66 | 33.33 | 75 | 14-16,18-20 +--------------------------|---------|----------|---------|---------|-------------------------------- +,ERROR: Coverage for lines (73.72%) does not meet global threshold (101%) +ERROR: Coverage for branches (59.03%) does not meet global threshold (82%) +ERROR: Coverage for statements (73.72%) does not meet global threshold (95%) +" +`; + +exports[`c8 report supports reporting on directories outside cwd 1`] = ` +",-----------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-----------|---------|----------|---------|---------|------------------- +All files | 0 | 0 | 0 | 0 | + multidir1 | 0 | 0 | 0 | 0 | + file1.js | 0 | 0 | 0 | 0 | 1 + multidir2 | 0 | 0 | 0 | 0 | + file2.js | 0 | 0 | 0 | 0 | 1 +-----------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 report supports reporting on single directories outside cwd 1`] = ` +",----------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +----------|---------|----------|---------|---------|------------------- +All files | 0 | 0 | 0 | 0 | + file1.js | 0 | 0 | 0 | 0 | 1 +----------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 reports coverage for script that exits normally 1`] = ` +",hey +i am a line of code +what +hey +what +hey +what +hey +-----------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-----------|---------|----------|---------|---------|------------------- +All files | 83.33 | 85.71 | 66.66 | 83.33 | + async.js | 100 | 100 | 100 | 100 | + normal.js | 75 | 66.66 | 33.33 | 75 | 14-16,18-20 +-----------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 should allow for files outside of cwd 1`] = ` +",hi +-------------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-------------------|---------|----------|---------|---------|------------------- +All files | 100 | 100 | 100 | 100 | + multidir1 | 100 | 100 | 100 | 100 | + file1.js | 100 | 100 | 100 | 100 | + report | 100 | 100 | 100 | 100 | + allowExternal.js | 100 | 100 | 100 | 100 | +-------------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 should allow for multiple overrides of src location for --all 1`] = ` +",hihi +--------------------------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +--------------------------------|---------|----------|---------|---------|------------------- +All files | 3.57 | 16.66 | 0 | 3.57 | + multidir1 | 0 | 0 | 0 | 0 | + file1.js | 0 | 0 | 0 | 0 | 1 + multidir2 | 0 | 0 | 0 | 0 | + file2.js | 0 | 0 | 0 | 0 | 1 + report | 3.84 | 25 | 0 | 3.84 | + allowExternal.js | 0 | 0 | 0 | 0 | 1 + report-multi-dir-external.js | 0 | 0 | 0 | 0 | 1-12 + report-single-dir-external.js | 0 | 0 | 0 | 0 | 1-12 + srcOverride.js | 100 | 100 | 100 | 100 | +--------------------------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 source-maps TypeScript remaps branches 1`] = ` +",reachable +a = true +a = false +------------------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +------------------------|---------|----------|---------|---------|------------------- +All files | 84 | 57.14 | 100 | 84 | + branches.typescript.ts | 84 | 57.14 | 100 | 84 | 7,11-12,18 +------------------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 source-maps TypeScript remaps classes 1`] = ` +",covered +covered +covered +covered +covered +-----------------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-----------------------|---------|----------|---------|---------|------------------- +All files | 81.81 | 85.71 | 60 | 81.81 | + classes.typescript.ts | 81.81 | 85.71 | 60 | 81.81 | 12-13,21-22,27-28 +-----------------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 source-maps UglifyJS remaps branches 1`] = ` +",reachable +a = true +a = false +-------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-------------|---------|----------|---------|---------|------------------- +All files | 80 | 50 | 100 | 80 | + branches.js | 80 | 50 | 100 | 80 | 2,5-6,13 +-------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 source-maps UglifyJS remaps classes 1`] = ` +",covered +covered +covered +covered +covered +------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +------------|---------|----------|---------|---------|------------------- +All files | 85.18 | 83.33 | 60 | 85.18 | + classes.js | 85.18 | 83.33 | 60 | 85.18 | 6-7,15,21 +------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 source-maps does not attempt to load source map URLs that aren't 1`] = ` +",--------------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +--------------------|---------|----------|---------|---------|------------------- +All files | 71.42 | 50 | 100 | 71.42 | + fake-source-map.js | 71.42 | 50 | 100 | 71.42 | 5-6 +--------------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 source-maps nyc remaps branches 1`] = ` +",reachable +a = true +a = false +-------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-------------|---------|----------|---------|---------|------------------- +All files | 80 | 40 | 100 | 80 | + branches.js | 80 | 40 | 100 | 80 | 2,6-7,13 +-------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 source-maps nyc remaps classes 1`] = ` +",covered +covered +covered +covered +covered +------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +------------|---------|----------|---------|---------|------------------- +All files | 77.77 | 83.33 | 60 | 77.77 | + classes.js | 77.77 | 83.33 | 60 | 77.77 | 7-8,15-16,21-22 +------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 source-maps rollup remaps branches 1`] = ` +",reachable +a = true +a = false +-------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-------------|---------|----------|---------|---------|------------------- +All files | 100 | 100 | 100 | 100 | + branch-1.js | 100 | 100 | 100 | 100 | + branch-2.js | 100 | 100 | 100 | 100 | +-------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 source-maps rollup remaps classes 1`] = ` +",covered +covered +covered +covered +covered +------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +------------|---------|----------|---------|---------|------------------- +All files | 78.57 | 83.33 | 60 | 78.57 | + class-1.js | 100 | 100 | 100 | 100 | + class-2.js | 73.91 | 83.33 | 60 | 73.91 | 7-8,15-16,21-22 +------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 source-maps ts-node reads source-map from cache, and applies to coverage 1`] = ` +",covered +covered +covered +covered +covered +------------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +------------------|---------|----------|---------|---------|------------------- +All files | 76.47 | 85.71 | 60 | 76.47 | + ts-node-basic.ts | 76.47 | 85.71 | 60 | 76.47 | 13-16,25-26,33-34 +------------------|---------|----------|---------|---------|------------------- +," +`; + +exports[`c8 supports exeternally set NODE_V8_COVERAGE 1`] = ` +",hey +i am a line of code +what +hey +what +hey +what +hey +-----------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +-----------|---------|----------|---------|---------|------------------- +All files | 83.33 | 85.71 | 66.66 | 83.33 | + async.js | 100 | 100 | 100 | 100 | + normal.js | 75 | 66.66 | 33.33 | 75 | 14-16,18-20 +-----------|---------|----------|---------|---------|------------------- +," +`;