.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. .TH RUN.JS "1" "December 2023" "run.js 16.3.7" "User Commands" .SH NAME run.js \- Test-Anything-Protocol module for Node.js .SH DESCRIPTION .SS "Usage:" .IP tap [options] [] .PP tap v16.3.7 \- A Test\-Anything\-Protocol library for JavaScript .PP Executes all the files and interprets their output as TAP formatted test result data. If no files are specified, then tap will search for testy\-looking files, and run those. (See '\-\-test\-regex' below.) .PP To parse TAP data from stdin, specify "\-" as a filename. .PP Short options are parsed gnu\-style, so for example '\-bCRspec' would be equivalent to '\-\-bail \fB\-\-no\-color\fR \fB\-\-reporter\fR=\fI\,spec\/\fR' .PP If the \fB\-\-check\-coverage\fR or \fB\-\-coverage\-report\fR options are provided explicitly, and no test files are specified, then a coverage report or coverage check will be run on the data from the last test run. .PP Coverage is never enabled for stdin. .PP Much more documentation available at: https://www.node\-tap.org/ .PP Basic Options: .TP \fB\-R\fR \fB\-\-reporter=\fR Use the specified reporter. Defaults to 'base' when colors are in use, or 'tap' when colors are disabled. .TP In addition to the built\-in reporters provided by the treport and tap\-mocha\-reporter modules, the reporter option can also specify a command\-line program or a module to load via require(). .TP Command\-line programs receive the raw TAP output on their stdin. .TP Modules loaded via require() must export either a writable stream class or a React.Component subclass. Writable streams are instantiated and piped into. React components are rendered using Ink, with tap={tap} as their only property. .TP Available built\-in reporters: classic doc dot dump json jsonstream landing list markdown min nyan progress silent spec tap xunit .TP \fB\-r\fR \fB\-\-reporter\-arg=\fR Args to pass to command\-line reporters. Ignored when using built\-in reporters or module reporters. Can be set multiple times .TP \fB\-F\fR \fB\-\-save\-fixture\fR Do not clean up fixtures created with t.testdir() .TP \fB\-\-no\-save\-fixture\fR switch off the \fB\-\-save\-fixture\fR flag .TP \fB\-b\fR \fB\-\-bail\fR Bail out on first failure .TP \fB\-B\fR \fB\-\-no\-bail\fR Do not bail out on first failure (default) .TP \fB\-\-comments\fR Print all tap comments to process.stderr .TP \fB\-\-no\-comments\fR switch off the \fB\-\-comments\fR flag .TP \fB\-c\fR \fB\-\-color\fR Use colors (Default for TTY) .TP \fB\-C\fR \fB\-\-no\-color\fR Do not use colors (Default for non\-TTY) .TP \fB\-S\fR \fB\-\-snapshot\fR Set to generate snapshot files for 't.matchSnapshot()' assertions. .TP \fB\-\-no\-snapshot\fR switch off the \fB\-\-snapshot\fR flag .TP \fB\-w\fR \fB\-\-watch\fR Watch for changes in the test suite or covered program. .TP Runs the suite normally one time, and from then on, re\-run just the portions of the suite that are required whenever a file changes. .TP Opens a REPL to trigger tests and perform various actions. .TP \fB\-\-no\-watch\fR switch off the \fB\-\-watch\fR flag .TP \fB\-n\fR \fB\-\-changed\fR Only run tests for files that have changed since the last run. .TP This requires coverage to be enabled, because tap uses NYC's process info tracking to monitor which file is loaded by which tests. .TP If no prior test run data exists, then all default files are run, as if \fB\-\-changed\fR was not specified. .TP \fB\-\-no\-changed\fR switch off the \fB\-\-changed\fR flag .TP \fB\-s\fR \fB\-\-save=\fR If exists, then it should be a line\- delimited list of test files to run. If is not present, then all command\-line positional arguments are run. .TP After the set of test files are run, any failed test files are written back to the save file. .TP This way, repeated runs with \fB\-s\fR will re\-run failures until all the failures are passing, and then once again run all tests. .TP Its a good idea to .gitignore the file used for this purpose, as it will churn a lot. .TP \fB\-O\fR \fB\-\-only\fR Only run tests with {only: true} option, or created with t.only(...) function. .TP \fB\-\-no\-only\fR switch off the \fB\-\-only\fR flag .TP \fB\-g\fR \fB\-\-grep=\fR Only run subtests tests matching the specified pattern. .TP Patterns are matched against top\-level subtests in each file. To filter tests at subsequent levels, specify this option multiple times. .TP To specify regular expression flags, format pattern like a JavaScript RegExp literal. For example: '/xyz/i' for case\-insensitive matching. .IP Can be set multiple times .TP \fB\-i\fR \fB\-\-invert\fR Invert the matches to \fB\-\-grep\fR patterns. (Like grep \fB\-v\fR) .TP \fB\-I\fR \fB\-\-no\-invert\fR switch off the \fB\-\-invert\fR flag .TP \fB\-t\fR \fB\-\-timeout=\fR Time out test files after seconds. Defaults to 30, or the value of the TAP_TIMEOUT environment variable. Setting to 0 allows tests to run forever. .TP When a test process calls t.setTimeout(n) on the top\-level tap object, it also updates this value for that specific process. .TP \fB\-T\fR \fB\-\-no\-timeout\fR Do not time out tests. Equivalent to \fB\-\-timeout\fR=\fI\,0\/\fR. .TP \fB\-\-files=\fR Alternative way to specify test set rather than using positional arguments. Supported as an option so that test file arguments can be specified in .taprc and package.json files. Can be set multiple times .PP Running Parallel Tests: .IP Tap can run multiple test files in parallel. This generally results in a speedier test run, but can also cause problems if your test files are not designed to be independent from one another. .IP To designate a set of files as ok to run in parallel, add them to a folder containing a file named 'tap\-parallel\-ok'. .IP To designate a set of files as not ok to run in parallel, add them to a folder containing a file named 'tap\-parallel\-not\-ok'. .IP These folders may be nested within one another, and tap will do the right thing. .TP \fB\-j\fR \fB\-\-jobs=\fR Run up to test files in parallel. .TP By default, this will be set to the number of CPUs on the system. .IP Set \fB\-\-jobs\fR=\fI\,1\/\fR to disable parallelization entirely. .TP \fB\-J\fR \fB\-\-jobs\-auto\fR Run test files in parallel (auto calculated) .TP This is the default as of v13, so this option serves little purpose except to re\-set the parallelization back to the default if an earlier option (or config file) set it differently. .TP \fB\-\-before=\fR A node program to be run before test files are executed. .TP Exiting with a non\-zero status code or a signal will fail the test run and exit the process in error. .TP \fB\-\-after=\fR A node program to be executed after tests are finished. .TP This will be run even if a test in the series fails with a bailout, but it will *not* be run if a \fB\-\-before\fR script fails. .TP Exiting with a non\-zero status code or a signal will fail the test run and exit the process in error. .PP Code Coverage Options: .IP Tap uses the nyc module internally to provide code coverage, so there is no need to invoke nyc yourself or depend on it directly unless you want to use it in other scenarios. .TP \fB\-\-100\fR Enforce full coverage, 100%. Sets branches, statements, functions, and lines to 100. .TP This is the default. To specify a lower limit (or no limit) set \fB\-\-lines\fR, \fB\-\-branches\fR, \fB\-\-functions\fR, or \fB\-\-statements\fR to a lower number than 100, or disable coverage checking with \fB\-\-no\-check\-coverage\fR, or disable coverage entirely with \fB\-\-no\-coverage\fR. .TP \fB\-M\fR \fB\-\-coverage\-map=\fR Provide a path to a node module that exports a single function. That function takes a test file as an argument, and returns an array of files to instrument with coverage when that file is run. .TP This is useful in cases where a unit test should cover a single portion of the system under test. .IP Return 'null' to not cover any files by this test. .TP Return an empty array [] to cover the set that nyc would pull in by default. Ie, returning [] is equivalent to not using a coverage map at all. .TP \fB\-\-no\-coverage\-map\fR Do not use a coverage map. Primarily useful for disabling a coverage\-map that is set in a config file. .TP \fB\-cov\fR \fB\-\-coverage\fR Capture coverage information using 'nyc' This is enabled by default. .TP If a COVERALLS_REPO_TOKEN environment variable is set, and the 'coveralls' module is installed, then coverage is sent to the coveralls.io service. .TP Note that tap does not automatically install coveralls, it must already be present in your project to use this feature. .TP \fB\-no\-cov\fR \fB\-\-no\-coverage\fR Do not capture coverage information. Note that if nyc is already loaded, then the coverage info will still be captured. .TP \fB\-\-coverage\-report=\fR Output coverage information using the specified istanbul/nyc reporter type. .TP Default is 'text' when running on the command line, or \&'text\-lcov' when piping to coveralls. .TP If 'html' is used, then the report will be opened in a web browser after running. .TP This can be run on its own at any time after a test run that included coverage. .TP Built\-in NYC reporters: clover cobertura html json json\-summary lcov lcovonly none teamcity text text\-lcov text\-summary .IP Can be set multiple times .TP \fB\-\-no\-coverage\-report\fR Do not output a coverage report, even if coverage information is generated. .TP \fB\-\-browser\fR Open a browser when an html coverage report is generated. (this is the default behavior) .TP \fB\-\-no\-browser\fR Do not open a web browser after generating an html coverage report .TP \fB\-pstree\fR \fB\-\-show\-process\-tree\fR Enable coverage and display the tree of spawned processes. .HP \fB\-\-no\-show\-process\-tree\fR switch off the \fB\-\-show\-process\-tree\fR flag .PP Coverage Enfocement Options: .IP These options enable you to specify that the test will fail if a given coverage level is not met. Setting any of the options below will trigger the \fB\-\-coverage\fR and \fB\-\-check\-coverage\fR flags. .IP The most stringent is \fB\-\-100\fR. You can find a list of projects running their tests like this at: https://www.node\-tap.org/100 .IP If you run tests in this way, please add your project to the list. .TP \fB\-\-check\-coverage\fR Check whether coverage is within thresholds provided. Setting this explicitly will default \fB\-\-coverage\fR to true. .TP This can be run on its own any time after a test run that included coverage. .TP \fB\-\-no\-check\-coverage\fR switch off the \fB\-\-check\-coverage\fR flag .TP \fB\-\-branches=\fR what % of branches must be covered? .TP \fB\-\-functions=\fR what % of functions must be covered? .TP \fB\-\-lines=\fR what % of lines must be covered? .TP \fB\-\-statements=\fR what % of statements must be covered? .PP Other Options: .TP \fB\-h\fR \fB\-\-help\fR Show this helpful output .TP \fB\-\-no\-help\fR switch off the \fB\-\-help\fR flag .TP \fB\-v\fR \fB\-\-version\fR Show the version of this program. .TP \fB\-\-no\-version\fR switch off the \fB\-\-version\fR flag .TP \fB\-\-test\-regex=\fR A regular expression pattern indicating tests to run if no positional arguments are provided. .TP By default, tap will search for all files ending in \&.ts, .tsx, .js, .jsx, .cjs, or .mjs, in a top\-level folder named test, tests, or __tests__, or any file ending in '.spec.' or '.test.' before a supported extension, or a top\-level file named \&'test.(js,jsx,...)' or 'tests.(js,jsx,...)' .TP Ie, the default value for this option is: ((\e/|^)(tests?|__tests?__)\e/.*|\e.(tests?|spec)|^\e/?test s?)\e.([mc]js|[jt]sx?)$ .TP Note that .jsx files will only be run when \fB\-\-jsx\fR is enabled, .ts files will only be run when \fB\-\-ts\fR is enabled, and .tsx files will only be run with both \fB\-\-ts\fR and \fB\-\-jsx\fR are enabled. .TP \fB\-\-test\-ignore=\fR When no positional arguments are provided, use the supplied regular expression pattern to exclude tests that would otherwise be matched by the test\-regexp. .IP Defaults to '$.', which intentionally matches nothing. .TP Note: folders named tap\-snapshots, node_modules, .git, and .hg are ALWAYS excluded from the default test file set. If you wish to run tests in these folders, then name the test files on the command line as positional arguments. .TP \fB\-\-test\-arg=\fR Pass an argument to test files spawned by the tap command line executable. This can be specified multiple times to pass multiple args to test scripts. Can be set multiple times .TP \fB\-\-test\-env=\fR]> Pass a key=value (ie, \fB\-\-test\-env\fR=\fI\,key=value\/\fR) to set an environment variable in the process where tests are run. .TP If a value is not provided, then the key is ensured to not be set in the environment. To set a key to the empty string, use \fB\-\-test\-env\fR=\fI\,key=\/\fR .IP Can be set multiple times .TP \fB\-\-nyc\-arg=\fR Pass an argument to nyc when running child processes with coverage enabled. This can be specified multiple times to pass multiple args to nyc. Can be set multiple times .TP \fB\-\-node\-arg=\fR Pass an argument to Node binary in all child processes. Run 'node \fB\-\-help\fR' to see a list of all relevant arguments. This can be specified multiple times to pass multiple args to Node. Can be set multiple times .TP \fB\-gc\fR \fB\-\-expose\-gc\fR Expose the gc() function to Node.js tests .TP \fB\-\-debug\fR Turn on debug mode .TP \fB\-\-no\-debug\fR switch off the \fB\-\-debug\fR flag .TP \fB\-\-debug\-brk\fR Run JavaScript tests with node \fB\-\-debug\-brk\fR .TP \fB\-\-harmony\fR Enable all Harmony flags in JavaScript tests .TP \fB\-\-strict\fR Run JS tests in 'use strict' mode .TP \fB\-\-flow\fR Removes flow types .TP \fB\-\-no\-flow\fR switch off the \fB\-\-flow\fR flag .TP \fB\-\-ts\fR Automatically load .ts and .tsx tests ts\-node module. Note: you must provide ts\-node as a dependency yourself, tap does not automatically bundle it. (Default: false) .TP \fB\-\-no\-ts\fR switch off the \fB\-\-ts\fR flag .TP \fB\-\-jsx\fR Automatically load .jsx tests using tap's bundled import\-jsx loader (Default: false) .TP \fB\-\-no\-jsx\fR switch off the \fB\-\-jsx\fR flag .TP \fB\-\-nyc\-help\fR Print nyc usage banner. Useful for viewing options for \fB\-\-nyc\-arg\fR. .TP \fB\-\-no\-nyc\-help\fR switch off the \fB\-\-nyc\-help\fR flag .TP \fB\-\-nyc\-version\fR Print version of nyc used by tap. .TP \fB\-\-no\-nyc\-version\fR switch off the \fB\-\-nyc\-version\fR flag .TP \fB\-\-parser\-version\fR Print the version of tap\-parser used by tap. .TP \fB\-\-no\-parser\-version\fR switch off the \fB\-\-parser\-version\fR flag .TP \fB\-\-versions\fR Print versions of tap, nyc, and tap\-parser .TP \fB\-\-no\-versions\fR switch off the \fB\-\-versions\fR flag .TP \fB\-\-dump\-config\fR Dump the config options in YAML format .TP \fB\-\-no\-dump\-config\fR switch off the \fB\-\-dump\-config\fR flag .TP \fB\-\-rcfile=\fR Load any of these configurations from a YAML\-formatted file at the path specified. Defaults to .taprc in the current working directory. .TP Run 'tap \fB\-\-dump\-config\fR' to see available options and formatting. .TP \fB\-\-libtap\-settings=\fR A module which exports an object of fields to assign onto 'libtap/settings'. These are advanced configuration options for modifying the behavior of tap's internal runtime. .TP Module path is resolved relative to the current working directory. .TP Allowed fields: rmdirRecursive, rmdirRecursiveSync, StackUtils, stackUtils, output, snapshotFile. .IP See libtap documentation for expected values and usage. .IP https://github.com/tapjs/libtap .TP \fB\-o\fR \fB\-\-output\-file=\fR Send the raw TAP output to the specified file. Reporter output will still be printed to stdout, but the file will contain the raw TAP for later replay or analysis. .TP \fB\-d\fR \fB\-\-output\-dir=\fR Send the raw TAP output to the specified directory. A separate .tap file will be created for each test file that is run. Reporter output will still be printed to stdout, but the files will contain the raw TAP for later replay or analysis. .TP Files will be created to match the folder structure and filenames of test files run, but with '.tap' appended to the filenames. .TP \fB\-\-\fR Stop parsing flags, and treat any additional command line arguments as filenames. .PP Environment Variables: .TP COVERALLS_REPO_TOKEN Set to a Coveralls token to automatically send coverage information to https://coveralls.io, if the 'coveralls' module is installed in the project. .TP TAP_CHILD_ID Test files have this value set to a numeric value when run through the test runner. It also appears on the root tap object as `tap.childId`. .TP TAP_SNAPSHOT Set to '1' to generate snapshot files for \&'t.matchSnapshot()' assertions. .TP TAP_RCFILE A yaml formatted file which can set any of the above options. Defaults to ./.taprc .TP TAP_LIBTAP_SETTINGS A path (relative to current working directory) of a file that exports fields to override the default libtap settings .TP TAP_TIMEOUT Default value for \fB\-\-timeout\fR option. .TP TAP_COLORS Set to '1' to force color output, or '0' to prevent color output. .TP TAP_BAIL Bail out on the first test failure. Used internally when '\-\-bailout' is set. .TP TAP Set to '1' to force standard TAP output, and suppress any reporters. Used when running child tests so that their output is parseable by the test harness. .TP TAP_DIAG Set to '1' to show diagnostics by default for passing tests. Set to '0' to NOT show diagnostics by default for failing tests. If not one of these two values, then diagnostics are printed by default for failing tests, and not for passing tests. .TP TAP_BUFFER Set to '1' to run subtests in buffered mode by default. .TP TAP_DEV_LONGSTACK Set to '1' to include node\-tap internals in stack traces. By default, these are included only when the current working directory is the tap project itself. Note that node internals are always excluded. .TP TAP_DEBUG Set to '1' to turn on debug mode. .TP NODE_DEBUG Include 'tap' to turn on debug mode. .TP TAP_GREP A '\en'\-delimited list of grep patterns to apply to root level test objects. (This is an implementation detail for how the '\-\-grep' option works.) .TP TAP_GREP_INVERT Set to '1' to invert the meaning of the patterns in TAP_GREP. (Implementation detail for how the '\-\-invert' flag works.) .TP TAP_ONLY Set to '1' to set the \fB\-\-only\fR flag .TP TAP_TS Set to '1' to enable automatic typescript support .TP TAP_JSX Set to '1' to enable automatic jsx support .PP Config Files: .IP You can create a yaml file with any of the options above. By default, the file at ./.taprc will be loaded, but the \fB\-\-rcfile\fR option or TAP_RCFILE environment variable can modify this. .IP Run 'tap \fB\-\-dump\-config\fR' for a listing of what can be set in that file. Each of the keys corresponds to one of the options above.