-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a 'check-coverage' script so we can track towards completion
We are targetting 100% test coverage for npm v7 GA. Using a coverage-map, we require that any of the newly created tests fully cover the module that they are testing. However, this has the side effect of _always_ hitting 100% coverage when running 'npm test', even though not all modules are being tested. This adds a new 'load-all' test which, in 'check-coverage' mode, tells nyc to include every file in the project. This also removes the double-run of our tests in CI, where we run once and then immediately run the same exact thing again for Coveralls, and sends the 'check-coverage' output to Coveralls instead. PR-URL: #1820 Credit: @isaacs Close: #1820 Reviewed-by: @ruyadorno
- Loading branch information
Showing
4 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const t = require('tap') | ||
const glob = require('glob') | ||
const { resolve } = require('path') | ||
|
||
const full = process.env.npm_lifecycle_event === 'check-coverage' | ||
|
||
if (!full) { | ||
t.pass('nothing to do here, not checking for full coverage') | ||
} else { | ||
// some files do config.get() on load, so have to load npm first | ||
const npm = require('../../lib/npm.js') | ||
t.test('load npm first', t => npm.load(t.end)) | ||
|
||
t.test('load all the files', t => { | ||
// just load all the files so we measure coverage for the missing tests | ||
const dir = resolve(__dirname, '../../lib') | ||
for (const f of glob.sync(`${dir}/**/*.js`)) { | ||
require(f) | ||
t.pass('loaded ' + f) | ||
} | ||
t.pass('loaded all files') | ||
t.end() | ||
}) | ||
|
||
t.test('call the error handle so we dont freak out', t => { | ||
const errorHandler = require('../../lib/utils/error-handler.js') | ||
errorHandler() | ||
t.end() | ||
}) | ||
} |