Skip to main content
Version: 2.22

nodejs-test


Options for package.json script configured tests.

Your preferred test runner is configured via the package.json#scripts.test field.

The only expectation from pants is that the test script can accept a variadic number of path arguments, relative to the package.json, and that any configuration files are file dependencies to the package_json.

Simple example:

Consider a directory-layout:

├── BUILD
├── src/
│ ├── BUILD
│ ├── test/
│ │ ├── BUILD
│ │ └── index.test.js
│ └── index.js
└── package.json

where package.json contains

package.json
{
...
"scripts": {
"test": "mocha"
},
"devDependencies: {
...
}
}

Executing pants test src/test/index.test.js will cause the equivalent of mocha src/test/index.test.js to run.

Backend: pants.backend.experimental.javascript

Config section: [nodejs-test]

Basic options

skip

--[no-]nodejs-test-skip
PANTS_NODEJS_TEST_SKIP
pants.toml
[nodejs-test]
skip = <bool>
default: False

If true, don't use Node.js tests when running pants test.

Advanced options

coverage_output_dir

--nodejs-test-coverage-output-dir=<str>
PANTS_NODEJS_TEST_COVERAGE_OUTPUT_DIR
pants.toml
[nodejs-test]
coverage_output_dir = <str>
default: {distdir}/coverage/js/{target_spec}

Path to write the NodeJS coverage reports to. Must be relative to the build root.

Replacements:

  • {distdir} is replaced with the Pants distdir.

  • {target_spec} is replaced with the address of the applicable javascript_test target with / characters replaced with dots (.). Additional batch information is included in target_spec, when batching is used.

Deprecated options

None

None