Repository navigation
"c8 check-coverage --all" do not works like intended #187
Copy link
Copy link
Closed
Labels
Description
Activity
I think I see the problem. I wrote an integration test to simulate this use case that looks like this:
it.only('should allow for --all to be used with the check-coverage command (2 invocations)', () => { // generate v8 output let result = spawnSync(nodePath, [ c8Path, '--temp-directory=tmp/all-check-coverage-as-command', '--clean=false', '--check-coverage', '--lines=90', '--all=true', '--include=test/fixtures/all/vanilla/**/*.js', '--exclude=**/*.ts', // add an exclude to avoid default excludes of test/** nodePath, require.resolve('./fixtures/all/vanilla/main') ]) console.log(result.output.toString()) // invoke check-coverage as a command with --all result = spawnSync(nodePath, [ c8Path, 'check-coverage', '--lines-100', '--temp-directory=tmp/all-check-coverage-as-command', '--clean=false', '--all=true', '--include=test/fixtures/all/vanilla/**/*.js', '--exclude=**/*.ts' // add an exclude to avoid default excludes of test/** ]) console.log(result.output.toString()) })
The resulting output of this looks like:
--------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s --------------|---------|----------|---------|---------|------------------- All files | 64.29 | 66.67 | 50 | 64.29 | vanilla | 78.26 | 75 | 100 | 78.26 | loaded.js | 73.68 | 71.43 | 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.29%) does not meet global threshold (90%) ,,ERROR: Coverage for lines (78.26%) does not meet global threshold (90%)In the 2nd run it looks like we're not taking into account the unloaded files and getting a coverage for loaded files only.
Will fix.
- added a commit that references this issue
on Jan 12, 2020 Yes it works now !
Hi,
I want to both check a global coverage and a per file coverage so i need to call check-coverage separately.
If i have a file uncovered named foo.js,
calling
c8 --all --include build --check-coverageworks perfectly. It will fail telling me foo.js does not meet threshold.but calling
c8 --all --include buildand later callc8 check-coverage --all --include builddoes not works. It doesn't throw an error.