| layout | page | |
|---|---|---|
| title | Command-line interface | |
| redirect_from |
|
How to use the QUnit CLI (command-line interface), after [installing it from npm](./intro.md#in-node).
Usage: qunit [options] [files]
Files should be a space-separated list of files, directories, or glob expressions.
Defaults to 'test/**/*.js'.
Options:
-V, --version output the version number
-f, --filter <filter> filter which tests run
-r, --reporter [name] specify the reporter to use
--require <module> specify a module or script include to require before running
--seed [value] specify a seed to re-order your tests
-w, --watch watch files for changes and re-run the test suite
-h, --help display help for command
This option assigns QUnit.config.filter for you.
Only tests of which the name matches the filter will run.
The filter can be a full or partial string match, or by using '/pattern/' it can be a regular expression.
By default, the TAP reporter is used.
Run qunit --reporter <name> to use a different reporter, where <name> can be the name of a built-in reporter, or an Node module that implements the js-reporters spec. The reporter will be loaded and initialised automatically.
Built-in reporters:
tap: TAP compliant reporter.console: Log the JSON object for each reporter event fromQUnit.on. Use this to explore or debug the reporter interface.
The QUnit CLI uses Node.js. You can pass Node.js CLI options via the NODE_OPTIONS environment variable. For example, to use --enable-source-maps or --inspect, invoke QUnit as follows:
NODE_OPTIONS='--enable-source-maps' qunit test/
The filter and seed options can be configured directly using command-line arguments. These, and many more options, can also be set programmatically. Either from your test suite file (if you have a single entry point), or from a bootstrap file passed to --require.
See QUnit.config for the available configuration options.