Skip to content

Commit

Permalink
do not use snapshot to test help output
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyfarrell committed Jun 19, 2019
1 parent fad0711 commit 1688759
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 214 deletions.
208 changes: 0 additions & 208 deletions tap-snapshots/test-nyc-integration.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,214 +743,6 @@ end_of_record
`

exports[`test/nyc-integration.js TAP nyc --help > stdout 1`] = `
nyc.js [command] [options]
nyc.js [options] [bin-to-instrument]
Commands:
nyc.js check-coverage check whether coverage is within
thresholds provided
nyc.js instrument <input> [output] instruments a file or a directory
tree and writes the instrumented
code to the desired output location
nyc.js report run coverage report for .nyc_output
nyc.js merge <input-directory> merge istanbul format coverage
[output-file] output in a given folder
Options:
--reporter, -r coverage reporter(s) to use [default: "text"]
--report-dir directory to output coverage reports in
[default: "coverage"]
--silent, -s don't output a report after tests finish running
[boolean] [default: false]
--all, -a whether or not to instrument all files of the
project (not just the ones touched by your test
suite) [boolean] [default: false]
--exclude, -x a list of specific files and directories that
should be excluded from coverage, glob patterns
are supported, node_modules is always excluded
[default:
["coverage/**","packages/*/test/**","test/**","test{,-*}.js","**/*{.,-}test.js
","**/__tests__/**","**/{ava,babel,jest,nyc,rollup,webpack}.config.js"]]
--exclude-after-remap should exclude logic be performed after the
source-map remaps filenames?
[boolean] [default: true]
--exclude-node-modules whether or not to exclude all node_module folders
(i.e. **/node_modules/**) by default
[boolean] [default: true]
--include, -n a list of specific files that should be covered,
glob patterns are supported [default: []]
--cwd working directory used when resolving paths
[default: "."]
--require, -i a list of additional modules that nyc should
attempt to require in its subprocess, e.g.,
@babel/register, @babel/polyfill [default: []]
--eager instantiate the instrumenter at startup (see
https://git.io/vMKZ9) [boolean] [default: false]
--cache, -c cache instrumentation results for improved
performance [boolean] [default: true]
--cache-dir explicitly set location for instrumentation cache
--babel-cache cache babel transpilation results for improved
performance [boolean] [default: false]
--es-modules tell the instrumenter to treat files as ES Modules
[boolean] [default: true]
--extension, -e a list of extensions that nyc should handle in
addition to .js
[default: [".cjs",".mjs",".ts",".tsx",".jsx"]]
--check-coverage check whether coverage is within thresholds
provided [boolean] [default: false]
--branches what % of branches must be covered? [default: 0]
--functions what % of functions must be covered? [default: 0]
--lines what % of lines must be covered? [default: 90]
--statements what % of statements must be covered? [default: 0]
--source-map should nyc detect and handle source maps?
[boolean] [default: true]
--per-file check thresholds per file
[boolean] [default: false]
--produce-source-map should nyc's instrumenter produce source maps?
[boolean] [default: false]
--compact should the output be compacted?
[boolean] [default: true]
--preserve-comments should comments be preserved in the output?
[boolean] [default: true]
--instrument should nyc handle instrumentation?
[boolean] [default: true]
--hook-require should nyc wrap require? [boolean] [default: true]
--hook-run-in-context should nyc wrap vm.runInContext?
[boolean] [default: false]
--hook-run-in-this-context should nyc wrap vm.runInThisContext?
[boolean] [default: false]
--show-process-tree display the tree of spawned processes
[boolean] [default: false]
--clean should the .nyc_output folder be cleaned before
executing tests [boolean] [default: true]
--nycrc-path specify a different .nycrc path[default: ".nycrc"]
--temp-dir, -t directory to output raw coverage information to
[default: "./.nyc_output"]
--skip-empty don't show empty files (no lines of code) in
report [boolean] [default: false]
--skip-full don't show files with 100% statement, branch, and
function coverage [boolean] [default: false]
-h, --help Show help [boolean]
--version Show version number [boolean]
Examples:
nyc.js npm test instrument your tests with coverage
nyc.js --require @babel/register npm instrument your tests with coverage
test and transpile with Babel
nyc.js report --reporter=text-lcov output lcov report after running
your tests
visit https://git.io/vHysA for list of available reporters
`

exports[`test/nyc-integration.js TAP nyc displays help to stderr when it doesn't know what to do > stderr 1`] = `
nyc.js [command] [options]
nyc.js [options] [bin-to-instrument]
Commands:
nyc.js check-coverage check whether coverage is within
thresholds provided
nyc.js instrument <input> [output] instruments a file or a directory
tree and writes the instrumented
code to the desired output location
nyc.js report run coverage report for .nyc_output
nyc.js merge <input-directory> merge istanbul format coverage
[output-file] output in a given folder
Options:
--reporter, -r coverage reporter(s) to use [default: "text"]
--report-dir directory to output coverage reports in
[default: "coverage"]
--silent, -s don't output a report after tests finish running
[boolean] [default: false]
--all, -a whether or not to instrument all files of the
project (not just the ones touched by your test
suite) [boolean] [default: false]
--exclude, -x a list of specific files and directories that
should be excluded from coverage, glob patterns
are supported, node_modules is always excluded
[default:
["coverage/**","packages/*/test/**","test/**","test{,-*}.js","**/*{.,-}test.js
","**/__tests__/**","**/{ava,babel,jest,nyc,rollup,webpack}.config.js"]]
--exclude-after-remap should exclude logic be performed after the
source-map remaps filenames?
[boolean] [default: true]
--exclude-node-modules whether or not to exclude all node_module folders
(i.e. **/node_modules/**) by default
[boolean] [default: true]
--include, -n a list of specific files that should be covered,
glob patterns are supported [default: []]
--cwd working directory used when resolving paths
[default: "."]
--require, -i a list of additional modules that nyc should
attempt to require in its subprocess, e.g.,
@babel/register, @babel/polyfill [default: []]
--eager instantiate the instrumenter at startup (see
https://git.io/vMKZ9) [boolean] [default: false]
--cache, -c cache instrumentation results for improved
performance [boolean] [default: true]
--cache-dir explicitly set location for instrumentation cache
--babel-cache cache babel transpilation results for improved
performance [boolean] [default: false]
--es-modules tell the instrumenter to treat files as ES Modules
[boolean] [default: true]
--extension, -e a list of extensions that nyc should handle in
addition to .js
[default: [".cjs",".mjs",".ts",".tsx",".jsx"]]
--check-coverage check whether coverage is within thresholds
provided [boolean] [default: false]
--branches what % of branches must be covered? [default: 0]
--functions what % of functions must be covered? [default: 0]
--lines what % of lines must be covered? [default: 90]
--statements what % of statements must be covered? [default: 0]
--source-map should nyc detect and handle source maps?
[boolean] [default: true]
--per-file check thresholds per file
[boolean] [default: false]
--produce-source-map should nyc's instrumenter produce source maps?
[boolean] [default: false]
--compact should the output be compacted?
[boolean] [default: true]
--preserve-comments should comments be preserved in the output?
[boolean] [default: true]
--instrument should nyc handle instrumentation?
[boolean] [default: true]
--hook-require should nyc wrap require? [boolean] [default: true]
--hook-run-in-context should nyc wrap vm.runInContext?
[boolean] [default: false]
--hook-run-in-this-context should nyc wrap vm.runInThisContext?
[boolean] [default: false]
--show-process-tree display the tree of spawned processes
[boolean] [default: false]
--clean should the .nyc_output folder be cleaned before
executing tests [boolean] [default: true]
--nycrc-path specify a different .nycrc path[default: ".nycrc"]
--temp-dir, -t directory to output raw coverage information to
[default: "./.nyc_output"]
--skip-empty don't show empty files (no lines of code) in
report [boolean] [default: false]
--skip-full don't show files with 100% statement, branch, and
function coverage [boolean] [default: false]
-h, --help Show help [boolean]
--version Show version number [boolean]
Examples:
nyc.js npm test instrument your tests with coverage
nyc.js --require @babel/register npm instrument your tests with coverage
test and transpile with Babel
nyc.js report --reporter=text-lcov output lcov report after running
your tests
visit https://git.io/vHysA for list of available reporters
`

exports[`test/nyc-integration.js TAP nyc displays help to stderr when it doesn't know what to do > stdout 1`] = `
`

exports[`test/nyc-integration.js TAP nyc instrument fails on file with \`package\` keyword when es-modules is enabled > stderr 1`] = `
Failed to instrument ./not-strict.js
Expand Down
24 changes: 18 additions & 6 deletions test/nyc-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,25 @@ t.test('nyc instrument fails on file with `package` keyword when es-modules is e
args: ['instrument', '--exit-on-error', './not-strict.js']
}))

t.test('nyc --help', t => testSuccess(t, {
args: ['--help']
}))
t.test('nyc displays help to stderr when it doesn\'t know what to do', t => {
let helpmsg

t.test('nyc displays help to stderr when it doesn\'t know what to do', t => testFailure(t, {
args: []
}))
return runNYC({
tempDir: t.tempDir,
args: ['--help']
}).then(({ status, stderr, stdout }) => {
t.is(status, 0)
t.is(stderr, '')
helpmsg = stdout
}).then(() => runNYC({
tempDir: t.tempDir,
args: []
})).then(({ status, stderr, stdout }) => {
t.equal(status, 1)
t.equal(stdout, '')
t.equal(stderr, helpmsg)
})
})

t.test('handles --clean / --no-clean properly', t => {
return testSuccess(t, {
Expand Down

0 comments on commit 1688759

Please sign in to comment.