NYC.JS(1)

πŸ’– NAME πŸ’–

nyc.js β€” the istanbul command line interface, bestie πŸ’…

(this is the nyc.js page from the User Commands manual, section 1, in case you were wondering where we are 🫢)


πŸŽ€ DESCRIPTION πŸŽ€

okay so here's the vibe. you run it like this:

nyc.js [command] [options]
nyc.js [options] [bin-to-instrument]

that's it. that's the whole energy. ✨

πŸ¦‹ 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 ✨

so many options bestie, but like, every single one is here, no skips, we don't gatekeep πŸ’œ

  • --cwd β€” working directory used when resolving paths [string] [default: "."]
  • --nycrc-path β€” specify an explicit path to find nyc configuration
  • -t, --temp-dir β€” directory to output raw coverage information to [string] [default: "./.nyc_output"]
  • -x, --exclude β€” a list of specific files and directories that should be excluded from coverage, glob patterns are supported [string], and the default is lowkey a whole saga:
["coverage/**","packages/*/test{,s}/**","**/*.d.ts","test{,s}/**","test{,-*}.{js,cjs,mjs,ts,tsx,jsx}","**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}","**/__tests__/**","**/{ava,babel,nyc}.config.{js,cjs,mjs}","**/jest.config.{js,cjs,mjs,ts}","**/{karma,rollup,webpack}.config.js","**/.{eslint,mocha}rc.{js,cjs}"]
  • --exclude-node-modules β€” whether or not to exclude all node_module folders (i.e. **/node_modules/**) by default [boolean] [default: true]
  • -n, --include β€” a list of specific files that should be covered, glob patterns are supported [string] [default: []]
  • -e, --extension β€” a list of extensions that nyc should handle in addition to .js [string] [default: [".js",".cjs",".mjs",".ts",".tsx",".jsx"]]
  • --ignore-class-methods β€” class method names to ignore for coverage [string] [default: []]
  • --auto-wrap β€” allow return statements outside of functions [boolean] [default: true]
  • --es-modules β€” should files be treated as ES Modules [boolean] [default: true]
  • --parser-plugins β€” babel parser plugins to use when parsing the source [string], default is:
["asyncGenerators","bigInt","classProperties","classPrivateProperties","classPrivateMethods","dynamicImport","importMeta","numericSeparator","objectRestSpread","optionalCatchBinding","topLevelAwait"]
  • --compact β€” should the output be compacted? [boolean] [default: true]
  • --preserve-comments β€” should comments be preserved in the output? [boolean] [default: true]
  • --produce-source-map β€” should source maps be produced? [boolean] [default: true]
  • --source-map β€” should nyc detect and handle source maps? [boolean] [default: true]
  • -i, --require β€” a list of additional modules that nyc should attempt to require in its subprocess, e.g., @babel/register, @babel/polyfill [string] [default: []]
  • --instrument β€” should nyc handle instrumentation? [boolean] [default: true]
  • --exclude-after-remap β€” should exclude logic be performed after the source-map remaps filenames? [boolean] [default: true]
  • --branches β€” what % of branches must be covered? [number] [default: 0]
  • --functions β€” what % of functions must be covered? [number] [default: 0]
  • --lines β€” what % of lines must be covered? [number] [default: 90]
  • --statements β€” what % of statements must be covered? [number] [default: 0]
  • --per-file β€” check thresholds per file [boolean] [default: false]
  • --check-coverage β€” check whether coverage is within thresholds provided [boolean] [default: false]
  • -r, --reporter β€” coverage reporter(s) to use [string] [default: ["text"]]
  • --report-dir β€” directory to output coverage reports in [string] [default: "coverage"]
  • --show-process-tree β€” display the tree of spawned processes [boolean] [default: false]
  • --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]
  • -s, --silent β€” don't output a report after tests finish running [boolean] [default: false]
  • -a, --all β€” whether or not to instrument all files of the project (not just the ones touched by your test suite) [boolean] [default: false]
  • --eager β€” instantiate the instrumenter at startup (see https://git.io/vMKZ9) [boolean] [default: false]
  • -c, --cache β€” cache instrumentation results for improved performance [boolean] [default: true]
  • --cache-dir β€” explicitly set location for instrumentation cache [string]
  • --babel-cache β€” cache babel transpilation results for improved performance [boolean] [default: false]
  • --use-spawn-wrap β€” use spawn-wrap instead of setting process.env.NODE_OPTIONS [boolean] [default: false]
  • --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]
  • --clean β€” should the .nyc_output folder be cleaned before executing tests [boolean] [default: true]
  • -h, --help β€” Show help [boolean]
  • --version β€” Show version number [boolean]

🌈 EXAMPLES 🌈

here's the part where it gets real, bestie 🫢

  • nyc.js npm test β€” instrument your tests with coverage
  • nyc.js --require @babel/register npm test β€” instrument your tests with coverage 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 πŸ‘‘

ngl the reporters list is right there at https://git.io/vHysA β€” go look, it's giving options ✨

okay that's the whole page bestie, you ate πŸ’… this was nyc.js version 15.1.0, dated January 2022 β€” periodt, no cap, go get that coverage πŸŽ€πŸ’–πŸ¦‹

πŸ“¦ where this page comes from