.TH "AVA" "1" "September 2023" "5.3.1" .SH "NAME" \fBAVA\fR \- Test runner for Node\.js with a concise API .P Translations: .UR https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/05-command-line.md .I Français .UE .SH SYNOPSIS .RS 2 .nf ava [\.\.\.] ava debug [\.\.\.] ava reset\-cache Commands: ava [\.\.\.] Run tests [default] ava debug [\.\.\.] Activate Node\.js inspector and run a single test file ava reset\-cache Delete any temporary files and state kept by AVA, then exit Positionals: pattern Select which test files to run\. Leave empty if you want AVA to run all test files as per your configuration\. Accepts glob patterns, directories that (recursively) contain test files, and file paths optionally suffixed with a colon and comma\-separated numbers and/or ranges identifying the 1\-based line(s) of specific tests to run [string] Options: \-\-version Show version number [boolean] \-\-color Force color output [boolean] \-\-config Specific JavaScript file for AVA to read its config from, instead of using package\.json or ava\.config\.* files \-\-help Show help [boolean] \-c, \-\-concurrency Max number of test files running at the same time (default: CPU cores) [number] \-\-fail\-fast Stop after first test failure [boolean] \-m, \-\-match Only run tests with matching title (can be repeated) [string] \-\-no\-worker\-threads Don't use worker threads [boolean] \-\-node\-arguments Additional Node\.js arguments for launching worker processes (specify as a single string) [string] \-s, \-\-serial Run tests serially [boolean] \-t, \-\-tap Generate TAP output [boolean] \-T, \-\-timeout Set global timeout (milliseconds or human\-readable, e\.g\. 10s, 2m) [string] \-u, \-\-update\-snapshots Update snapshots [boolean] \-v, \-\-verbose Enable verbose output (default) [boolean] \-w, \-\-watch Re\-run tests when files change [boolean] Examples: ava ava test\.js ava test\.js:4,7\-9 .fi .RE .SH DESCRIPTION .P AVA searches for test files using the following patterns: .RS 1 .IP \(bu 2 \fBtest\.js\fP .IP \(bu 2 \fBsrc/test\.js\fP .IP \(bu 2 \fBsource/test\.js\fP .IP \(bu 2 \fB**/test\-*\.js\fP .IP \(bu 2 \fB**/*\.spec\.js\fP .IP \(bu 2 \fB**/*\.test\.js\fP .IP \(bu 2 \fB**/test/**/*\.js\fP .IP \(bu 2 \fB**/tests/**/*\.js\fP .IP \(bu 2 \fB**/__tests__/**/*\.js\fP .RE .P Files inside \fBnode_modules\fP are \fIalways\fR ignored\. So are files starting with \fB_\fP or inside of directories that start with a single \fB_\fP\|\. Additionally, files matching these patterns are ignored by default, unless different patterns are configured: .RS 1 .IP \(bu 2 \fB**/__tests__/**/__helper__/**/*\fP .IP \(bu 2 \fB**/__tests__/**/__helpers__/**/*\fP .IP \(bu 2 \fB**/__tests__/**/__fixture__/**/*\fP .IP \(bu 2 \fB**/__tests__/**/__fixtures__/**/*\fP .IP \(bu 2 \fB**/test/**/helper/**/*\fP .IP \(bu 2 \fB**/test/**/helpers/**/*\fP .IP \(bu 2 \fB**/test/**/fixture/**/*\fP .IP \(bu 2 \fB**/test/**/fixtures/**/*\fP .IP \(bu 2 \fB**/tests/**/helper/**/*\fP .IP \(bu 2 \fB**/tests/**/helpers/**/*\fP .IP \(bu 2 \fB**/tests/**/fixture/**/*\fP .IP \(bu 2 \fB**/tests/**/fixtures/**/*\fP .RE .P When using \fBnpm test\fP, you can pass positional arguments directly \fBnpm test test2\.js\fP, but flags needs to be passed like \fBnpm test \-\- \-\-verbose\fP\|\. .SH Running tests with matching titles .P .UR https://stackblitz.com/github/avajs/ava/tree/main/examples/matching-titles?file=test.js&terminal=test&view=editor .I ![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg) .UE .P The \fB\-\-match\fP 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 .UR https://github.com/sindresorhus/matcher .I `matcher` .UE for more details\. .P Match titles ending with \fBfoo\fP: .RS 2 .nf npx ava \-\-match='*foo' .fi .RE .P Match titles starting with \fBfoo\fP: .RS 2 .nf npx ava \-\-match='foo*' .fi .RE .P Match titles containing \fBfoo\fP: .RS 2 .nf npx ava \-\-match='*foo*' .fi .RE .P Match titles that are \fIexactly\fR \fBfoo\fP (albeit case insensitively): .RS 2 .nf npx ava \-\-match='foo' .fi .RE .P Match titles not containing \fBfoo\fP: .RS 2 .nf npx ava \-\-match='!*foo*' .fi .RE .P Match titles starting with \fBfoo\fP and ending with \fBbar\fP: .RS 2 .nf npx ava \-\-match='foo*bar' .fi .RE .P Match titles starting with \fBfoo\fP or ending with \fBbar\fP: .RS 2 .nf npx ava \-\-match='foo*' \-\-match='*bar' .fi .RE .P Note that a match pattern takes precedence over the \fB\|\.only\fP 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 \fB\-\-match\fP is used\. .P Here's what happens when you run AVA with a match pattern of \fB*oo*\fP and the following tests: .RS 2 .nf test('foo will run', t => { t\.pass(); }); test('moo will also run', t => { t\.pass(); }); test\.only('boo will run but not exclusively', t => { t\.pass(); }); // Won't run, no title test(function (t) { t\.fail(); }); // Won't run, no explicit title test(function foo(t) { t\.fail(); }); .fi .RE .SH Running tests at specific line numbers .P .UR https://stackblitz.com/github/avajs/ava/tree/main/examples/specific-line-numbers?file=test.js&terminal=test&view=editor .I ![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg) .UE .P AVA lets you run tests exclusively by referring to their line numbers\. Target a single line, a range of lines or both\. You can select any line number of a test\. .P The format is a comma\-separated list of \fB[X|Y\-Z]\fP where \fBX\fP, \fBY\fP and \fBZ\fP are integers between \fB1\fP and the last line number of the file\. .P This feature is only available from the command line\. .SS Running a single test .P To only run a particular test in a file, append the line number of the test to the path or pattern passed to AVA\. .P Given the following test file: .P \fBtest\.js\fP .RS 2 .nf 1: test('unicorn', t => { 2: t\.pass(); 3: }); 4: 5: test('rainbow', t => { 6: t\.fail(); 7: }); .fi .RE .P Running \fBnpx ava test\.js:2\fP for would run the \fBunicorn\fP test\. In fact you could use any line number between \fB1\fP and \fB3\fP\|\. .SS Running multiple tests .P To run multiple tests, either target them one by one or select a range of line numbers\. As line numbers are given per file, you can run multiple files with different line numbers for each file\. If the same file is provided multiple times, line numbers are merged and only run once\. .SS Examples .P Single line numbers: .RS 2 .nf npx ava test\.js:2,9 .fi .RE .P Range: .RS 2 .nf npx ava test\.js:4\-7 .fi .RE .P Mix of single line number and range: .RS 2 .nf npx ava test\.js:4,9\-12 .fi .RE .P Different files: .RS 2 .nf npx ava test\.js:3 test2\.js:4,7\-9 .fi .RE .P When running a file with and without line numbers, line numbers take precedence\. .SH Resetting AVA's cache .P AVA maintains some temporary state\. You can clear this state by running: .RS 2 .nf npx ava reset\-cache .fi .RE .P This deletes all files in the \fBnode_modules/\.cache/ava\fP directory\. .SH Reporters .P AVA uses a human readable reporter by default: .SS TAP reporter .P .UR https://stackblitz.com/github/avajs/ava/tree/main/examples/tap-reporter?file=test.js&terminal=test&view=editor .I ![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg) .UE .P AVA supports the TAP format and thus is compatible with .UR https://github.com/sindresorhus/awesome-tap#reporters .I any TAP reporter .UE . Use the \fB\-\-tap\fP flag to enable TAP output\. .RS 2 .nf $ npx ava \-\-tap | npx tap\-nyan .fi .RE .P Please note that the TAP reporter is unavailable when using .UR ./recipes/watch-mode.md .I watch mode .UE . .SH Node arguments .P The \fB\-\-node\-arguments\fP argument may be used to specify additional arguments for launching worker processes\. These are combined with the \fBnodeArguments\fP configuration and any arguments passed to the \fBnode\fP binary when starting AVA\. .P \fBOnly pass trusted values\.\fR .P Specify the arguments as a single string: .RS 2 .nf npx ava \-\-node\-arguments="\-\-throw\-deprecation \-\-zero\-fill\-buffers" .fi .RE .P \fBOnly pass trusted values\.\fR