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 providednyc.js instrument <input> [output]β instruments a file or a directory tree and writes the instrumented code to the desired output locationnyc.js reportβ run coverage report for.nyc_outputnyc.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 allnode_modulefolders (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β allowreturnstatements 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 (seehttps://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 settingprocess.env.NODE_OPTIONS[boolean][default: false]--hook-requireβ should nyc wrap require?[boolean][default: true]--hook-run-in-contextβ should nyc wrapvm.runInContext?[boolean][default: false]--hook-run-in-this-contextβ should nyc wrapvm.runInThisContext?[boolean][default: false]--cleanβ should the.nyc_outputfolder 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 coveragenyc.js --require @babel/register npm testβ instrument your tests with coverage and transpile with Babelnyc.js report --reporter=text-lcovβ output lcov report after running your tests- visit
https://git.io/vHysAfor 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
- debian bookworm: node-istanbul 0.4.5+repack10+~cs97.25.57-3 Β· BSD-3-Clause
- ubuntu jammy: node-istanbul 0.4.5+repack10+~cs97.25.57-3 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms