DOKK / manpages / debian 12 / node-tap / tap.1.en
RUN.JS(1) User Commands RUN.JS(1)

run.js - Test-Anything-Protocol module for Node.js

tap [options] [<files>]

tap v16.3.2 - A Test-Anything-Protocol library for JavaScript

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.)

To parse TAP data from stdin, specify "-" as a filename.

Short options are parsed gnu-style, so for example '-bCRspec' would be equivalent to '--bail --no-color --reporter=spec'

If the --check-coverage or --coverage-report 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.

Coverage is never enabled for stdin.

Much more documentation available at: https://www.node-tap.org/

Basic Options:

Use the specified reporter. Defaults to 'base' when colors are in use, or 'tap' when colors are disabled.
treport and tap-mocha-reporter modules, the reporter option can also specify a command-line program or a module to load via require().
their stdin.
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.
jsonstream landing list markdown min nyan progress silent spec tap xunit
Args to pass to command-line reporters. Ignored when using built-in reporters or module reporters. Can be set multiple times
Do not clean up fixtures created with t.testdir()
switch off the --save-fixture flag
Bail out on first failure
Do not bail out on first failure (default)
Print all tap comments to process.stderr
switch off the --comments flag
Use colors (Default for TTY)
Do not use colors (Default for non-TTY)
Set to generate snapshot files for 't.matchSnapshot()' assertions.
switch off the --snapshot flag
Watch for changes in the test suite or covered program.
re-run just the portions of the suite that are required whenever a file changes.
actions.
switch off the --watch flag
Only run tests for files that have changed since the last run.
NYC's process info tracking to monitor which file is loaded by which tests.
files are run, as if --changed was not specified.
switch off the --changed flag
list of test files to run. If <file> is not present, then all command-line positional arguments are run.
files are written back to the save file.
failures until all the failures are passing, and then once again run all tests.
purpose, as it will churn a lot.
Only run tests with {only: true} option, or created with t.only(...) function.
switch off the --only flag
Only run subtests tests matching the specified pattern.
file. To filter tests at subsequent levels, specify this option multiple times.
like a JavaScript RegExp literal. For example: '/xyz/i' for case-insensitive matching.
Can be set multiple times
Invert the matches to --grep patterns. (Like grep -v)
switch off the --invert flag
Time out test files after <n> seconds. Defaults to 30, or the value of the TAP_TIMEOUT environment variable. Setting to 0 allows tests to run forever.
top-level tap object, it also updates this value for that specific process.
Do not time out tests. Equivalent to --timeout=0.
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

Running Parallel Tests:

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.
To designate a set of files as ok to run in parallel, add them to a folder containing a file named 'tap-parallel-ok'.
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'.
These folders may be nested within one another, and tap will do the right thing.
Run up to <n> test files in parallel.
the system.
Set --jobs=1 to disable parallelization entirely.
Run test files in parallel (auto calculated)
little purpose except to re-set the parallelization back to the default if an earlier option (or config file) set it differently.
A node program to be run before test files are executed.
fail the test run and exit the process in error.
A node program to be executed after tests are finished.
with a bailout, but it will *not* be run if a --before script fails.
fail the test run and exit the process in error.

Code Coverage Options:

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.
--100
Enforce full coverage, 100%. Sets branches, statements, functions, and lines to 100.
limit) set --lines, --branches, --functions, or --statements to a lower number than 100, or disable coverage checking with --no-check-coverage, or disable coverage entirely with --no-coverage.
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.
a single portion of the system under test.
Return 'null' to not cover any files by this test.
would pull in by default. Ie, returning [] is equivalent to not using a coverage map at all.
Do not use a coverage map. Primarily useful for disabling a coverage-map that is set in a config file.
Capture coverage information using 'nyc' This is enabled by default.
and the 'coveralls' module is installed, then coverage is sent to the coveralls.io service.
it must already be present in your project to use this feature.
Do not capture coverage information. Note that if nyc is already loaded, then the coverage info will still be captured.
Output coverage information using the specified istanbul/nyc reporter type.
'text-lcov' when piping to coveralls.
web browser after running.
that included coverage.
json-summary lcov lcovonly none teamcity text text-lcov text-summary
Can be set multiple times
Do not output a coverage report, even if coverage information is generated.
Open a browser when an html coverage report is generated. (this is the default behavior)
Do not open a web browser after generating an html coverage report
Enable coverage and display the tree of spawned processes.

--no-show-process-tree switch off the --show-process-tree flag

Coverage Enfocement Options:

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 --coverage and --check-coverage flags.
The most stringent is --100. You can find a list of projects running their tests like this at: https://www.node-tap.org/100
If you run tests in this way, please add your project to the list.
Check whether coverage is within thresholds provided. Setting this explicitly will default --coverage to true.
that included coverage.
switch off the --check-coverage flag
what % of branches must be covered?
what % of functions must be covered?
what % of lines must be covered?
what % of statements must be covered?

Other Options:

Show this helpful output
switch off the --help flag
Show the version of this program.
switch off the --version flag
no positional arguments are provided.
.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,...)'
((\/|^)(tests?|__tests?__)\/.*|\.(tests?|spec)|^\/?test s?)\.([mc]js|[jt]sx?)$
enabled, .ts files will only be run when --ts is enabled, and .tsx files will only be run with both --ts and --jsx are enabled.
When no positional arguments are provided, use the supplied regular expression pattern to exclude tests that would otherwise be matched by the test-regexp.
Defaults to '$.', which intentionally matches nothing.
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.
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
Pass a key=value (ie, --test-env=key=value) to set an environment variable in the process where tests are run.
not be set in the environment. To set a key to the empty string, use --test-env=key=
Can be set multiple times
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
Pass an argument to Node binary in all child processes. Run 'node --help' 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
Expose the gc() function to Node.js tests
Turn on debug mode
switch off the --debug flag
Run JavaScript tests with node --debug-brk
Enable all Harmony flags in JavaScript tests
Run JS tests in 'use strict' mode
Removes flow types
switch off the --flow flag
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)
switch off the --ts flag
Automatically load .jsx tests using tap's bundled import-jsx loader (Default: false)
switch off the --jsx flag
Print nyc usage banner. Useful for viewing options for --nyc-arg.
switch off the --nyc-help flag
Print version of nyc used by tap.
switch off the --nyc-version flag
Print the version of tap-parser used by tap.
switch off the --parser-version flag
Print versions of tap, nyc, and tap-parser
switch off the --versions flag
Dump the config options in YAML format
switch off the --dump-config flag
Load any of these configurations from a YAML-formatted file at the path specified. Defaults to .taprc in the current working directory.
formatting.
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.
directory.
StackUtils, stackUtils, output, snapshotFile.
See libtap documentation for expected values and usage.
https://github.com/tapjs/libtap
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.
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.
filenames of test files run, but with '.tap' appended to the filenames.
--
Stop parsing flags, and treat any additional command line arguments as filenames.

Environment Variables:

Set to a Coveralls token to automatically send coverage information to https://coveralls.io, if the 'coveralls' module is installed in the project.
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`.
Set to '1' to generate snapshot files for 't.matchSnapshot()' assertions.
A yaml formatted file which can set any of the above options. Defaults to ./.taprc
A path (relative to current working directory) of a file that exports fields to override the default libtap settings
Default value for --timeout option.
Set to '1' to force color output, or '0' to prevent color output.
Bail out on the first test failure. Used internally when '--bailout' is set.
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.
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.
Set to '1' to run subtests in buffered mode by default.
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.
Set to '1' to turn on debug mode.
Include 'tap' to turn on debug mode.
A '\n'-delimited list of grep patterns to apply to root level test objects. (This is an implementation detail for how the '--grep' option works.)
Set to '1' to invert the meaning of the patterns in TAP_GREP. (Implementation detail for how the '--invert' flag works.)
Set to '1' to set the --only flag
Set to '1' to enable automatic typescript support
Set to '1' to enable automatic jsx support

Config Files:

You can create a yaml file with any of the options above. By default, the file at ./.taprc will be loaded, but the --rcfile option or TAP_RCFILE environment variable can modify this.
Run 'tap --dump-config' for a listing of what can be set in that file. Each of the keys corresponds to one of the options above.
November 2022 run.js 16.3.2