1ba31d8 Nov 5, 2018
1 contributor

Users who have contributed to this file

138 lines (94 sloc) 4.13 KB


$ npx ava --help

    ava [<file|directory|glob> ...]

    --watch, -w             Re-run tests when tests and source files change
    --match, -m             Only run tests with matching title (Can be repeated)
    --update-snapshots, -u  Update snapshots
    --fail-fast             Stop after first test failure
    --timeout, -T           Set global timeout
    --serial, -s            Run tests serially
    --concurrency, -c       Max number of test files running at the same time (Default: CPU cores)
    --verbose, -v           Enable verbose output
    --tap, -t               Generate TAP output
    --color                 Force color output
    --no-color              Disable color output
    --reset-cache           Reset AVA's compilation cache and exit

    ava test.js test2.js
    ava test-*.js
    ava test

  Default patterns when no arguments:
  test.js test-*.js test/**/*.js **/__tests__/**/*.js **/*.test.js

Note that the CLI will use your local install of AVA when available, even when run globally.

Directories are recursed, with all *.js files being treated as test files. Directories named fixtures, helpers and node_modules are always ignored. So are files starting with _ which allows you to place helpers in the same directory as your test files.

When using npm test, you can pass positional arguments directly npm test test2.js, but flags needs to be passed like npm test -- --verbose.

Running tests with matching titles

The --match flag allows you to run just the tests that have a matching title. This is achieved with simple wildcard patterns. Patterns are case insensitive. See matcher for more details.

Match titles ending with foo:

npx ava --match='*foo'

Match titles starting with foo:

npx ava --match='foo*'

Match titles containing foo:

npx ava --match='*foo*'

Match titles that are exactly foo (albeit case insensitively):

npx ava --match='foo'

Match titles not containing foo:

npx ava --match='!*foo*'

Match titles starting with foo and ending with bar:

npx ava --match='foo*bar'

Match titles starting with foo or ending with bar:

npx ava --match='foo*' --match='*bar'

Note that a match pattern takes precedence over the .only modifier. Only tests with an explicit title are matched. Tests without titles or whose title is derived from the implementation function will be skipped when --match is used.

Here's what happens when you run AVA with a match pattern of *oo* and the following tests:

test('foo will run', t => {

test('moo will also run', t => {

test.only('boo will run but not exclusively', t => {

// Won't run, no title
test(function (t) {;

// Won't run, no explicit title
test(function foo(t) {;

Resetting AVA's cache

AVA caches the compiled test and helper files. It automatically recompiles these files when you change them. AVA tries its best to detect changes to your Babel configuration files, plugins and presets. If it seems like your latest Babel configuration isn't being applied, however, you can run AVA with the --reset-cache flag to reset AVA's cache. If set, all files in the node_modules/.cache/ava directory are deleted. Run AVA as normal to apply your new Babel configuration.


By default AVA uses a minimal reporter:

Use the --verbose flag to enable the verbose reporter. This is always used in CI environments unless the TAP reporter is enabled.

TAP reporter

AVA supports the TAP format and thus is compatible with any TAP reporter. Use the --tap flag to enable TAP output.

$ npx ava --tap | npx tap-nyan

Please note that the TAP reporter is unavailable when using watch mode.