UNPKG

29 kBMarkdownView Raw
1# ![AVA](media/header.png)
2
3> Futuristic test runner
4
5[![Build Status: Linux](https://travis-ci.org/sindresorhus/ava.svg?branch=master)](https://travis-ci.org/sindresorhus/ava) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/igogxrcmhhm085co/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/ava/branch/master) [![Coverage Status](https://coveralls.io/repos/sindresorhus/ava/badge.svg?branch=master&service=github)](https://coveralls.io/github/sindresorhus/ava?branch=master) [![Gitter](https://badges.gitter.im/join chat.svg)](https://gitter.im/sindresorhus/ava)
6
7Even though JavaScript is single-threaded, IO in Node.js can happen in parallel due to its async nature. AVA takes advantage of this and runs your tests concurrently, which is especially beneficial for IO heavy tests. In addition, test files are run in parallel as separate processes, giving you even better performance and an isolated environment for each test file. [Switching](https://github.com/sindresorhus/pageres/commit/663be15acb3dd2eb0f71b1956ef28c2cd3fdeed0) from Mocha to AVA in Pageres brought the test time down from 31 sec to 11 sec. Having tests run concurrently forces you to write atomic tests, meaning tests don't depend on global state or the state of other tests, which is a great thing!
8
9*Read our [contributing guide](contributing.md) if you're looking to contribute (issues/PRs/etc).*
10
11Follow the [AVA Twitter account](https://twitter.com/ava__js) for updates.
12
13Translations: [Español](https://github.com/sindresorhus/ava-docs/blob/master/es_ES/readme.md), [Français](https://github.com/sindresorhus/ava-docs/blob/master/fr_FR/readme.md), [日本語](https://github.com/sindresorhus/ava-docs/blob/master/ja_JP/readme.md), [Português](https://github.com/sindresorhus/ava-docs/blob/master/pt_BR/readme.md), [Русский](https://github.com/sindresorhus/ava-docs/blob/master/ru_RU/readme.md)
14
15## Table of Contents
16
17- [Usage](#usage)
18- [CLI Usage](#cli)
19- [Configuration](#configuration)
20- [Documentation](#documentation)
21- [API](#api)
22- [Assertions](#assertions)
23- [Tips](#tips)
24- [FAQ](#faq)
25- [Recipes](#recipes)
26- [Support](#support)
27- [Related](#related)
28- [Links](#links)
29- [Team](#team)
30
31## Why AVA?
32
33- Minimal and fast
34- Simple test syntax
35- Runs tests concurrently
36- Enforces writing atomic tests
37- No implicit globals
38- [Isolated environment for each test file](#process-isolation)
39- [Write your tests in ES2015](#es2015-support)
40- [Promise support](#promise-support)
41- [Generator function support](#generator-function-support)
42- [Async function support](#async-function-support)
43- [Observable support](#observable-support)
44- [Enhanced assertion messages](#enhanced-assertion-messages)
45- [Optional TAP output](#optional-tap-output)
46- [Clean stack traces](#clean-stack-traces)
47
48## Test syntax
49
50```js
51import test from 'ava';
52
53test(t => {
54 t.same([1, 2], [1, 2]);
55});
56```
57
58## Usage
59
60### Add AVA to your project
61
62Install AVA globally run with `--init` to add AVA to your `package.json`:
63
64```console
65$ npm install --global ava
66$ ava --init
67```
68
69```json
70{
71 "name": "awesome-package",
72 "scripts": {
73 "test": "ava"
74 },
75 "devDependencies": {
76 "ava": "^0.11.0"
77 }
78}
79```
80
81Any arguments passed after `--init` are added in the `package.json`.
82
83#### Manual installation
84
85You can also install AVA directly:
86
87```console
88$ npm install --save-dev ava
89```
90
91You'll have to configure the `test` script in your `package.json` to use `ava`
92(see above).
93
94### Create your test file
95
96Create a file named `test.js` in the project root directory:
97
98```js
99import test from 'ava';
100
101test('foo', t => {
102 t.pass();
103});
104
105test('bar', async t => {
106 const bar = Promise.resolve('bar');
107
108 t.is(await bar, 'bar');
109});
110```
111
112<img src="screenshot.png" width="150" align="right">
113
114### Run it
115
116```console
117$ npm test
118```
119
120### Watch it
121
122```console
123$ npm test -- --watch
124```
125
126AVA comes with an intelligent watch mode. [Learn more in its recipe](docs/recipes/watch-mode.md).
127
128## CLI
129
130![](screenshot-mini-reporter.gif)
131
132```console
133$ ava --help
134
135 Usage
136 ava [<file|directory|glob> ...]
137
138 Options
139 --init Add AVA to your project
140 --fail-fast Stop after first test failure
141 --serial, -s Run tests serially
142 --require, -r Module to preload (Can be repeated)
143 --tap, -t Generate TAP output
144 --verbose, -v Enable verbose output
145 --no-cache Disable the transpiler cache
146 --match, -m Only run tests with matching title (Can be repeated)',
147 --watch, -w Re-run tests when tests and source files change
148 --source, -S Pattern to match source files so tests can be re-run (Can be repeated)
149
150 Examples
151 ava
152 ava test.js test2.js
153 ava test-*.js
154 ava test
155 ava --init
156 ava --init foo.js
157
158 Default patterns when no arguments:
159 test.js test-*.js test/**/*.js
160```
161
162*Note that the CLI will use your local install of AVA when available, even when run globally.*
163
164Directories 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.
165
166When using `npm test`, you can pass positional arguments directly `npm test test2.js`, but flags needs to be passed like `npm test -- --verbose`.
167
168## Configuration
169
170All of the CLI options can be configured in the `ava` section of your `package.json`. This allows you to modify the default behavior of the `ava` command, so you don't have to repeatedly type the same options on the command prompt.
171
172```json
173{
174 "ava": {
175 "files": [
176 "my-test-folder/*.js",
177 "!**/not-this-file.js"
178 ],
179 "source": [
180 "**/*.{js,jsx}",
181 "!dist/**/*"
182 ],
183 "match": [
184 "*oo",
185 "!foo"
186 ],
187 "failFast": true,
188 "tap": true,
189 "require": [
190 "babel-register"
191 ],
192 "babel": "inherit"
193 }
194}
195```
196
197Arguments passed to the CLI will always take precedence over the configuration in `package.json`.
198
199See the [ES2015 support](#es2015-support) section for details on the `babel` option.
200
201## Documentation
202
203Tests are run concurrently. You can specify synchronous and asynchronous tests. Tests are considered synchronous unless you return a promise or [observable](https://github.com/zenparsing/zen-observable)).
204
205We *highly* recommend the use of [async functions](#async-function-support). They make asynchronous code concise and readable, and they implicitly return a promise so you don't have to.
206
207If you're unable to use promises or observables, you may enable "callback mode" by defining your test with `test.cb([title], fn)`. Tests declared this way **must** be manually ended with `t.end()`. This mode is mainly intended for testing callback-style APIs.
208
209You must define all tests synchronously. They can't be defined inside `setTimeout`, `setImmediate`, etc.
210
211Test files are run from their current directory, so [`process.cwd()`](https://nodejs.org/api/process.html#process_process_cwd) is always the same as [`__dirname`](https://nodejs.org/api/globals.html#globals_dirname). You can just use relative paths instead of doing `path.join(__dirname, 'relative/path')`.
212
213### Creating tests
214
215To create a test you call the `test` function you imported from AVA. Provide the optional title and callback function. The function will be called when your test is run. It's passed an [execution object](#t) as its first and only argument. By convention this argument is named `t`.
216
217```js
218import test from 'ava';
219
220test('my passing test', t => {
221 t.pass();
222});
223```
224
225#### Titles
226
227Titles are optional, meaning you can do:
228
229```js
230test(t => {
231 t.pass();
232});
233```
234
235It's recommended to provide test titles if you have more than one test.
236
237If you haven't provided a test title, but the callback is a named function, that name will be used as the test title:
238
239```js
240test(function name(t) {
241 t.pass();
242});
243```
244
245### Assertion planning
246
247Assertion plans ensure tests only pass when a specific number of assertions have been executed. They'll help you catch cases where tests exit too early. They'll also cause tests to fail if too many assertions are executed, which can be useful if you have assertions inside callbacks or loops.
248
249Note that, unlike [`tap`](https://www.npmjs.com/package/tap) and [`tape`](https://www.npmjs.com/package/tape), AVA does *not* automatically end a test when the planned assertion count is reached.
250
251These examples will result in a passed test:
252
253```js
254test(t => {
255 t.plan(1);
256
257 return Promise.resolve(3).then(n => {
258 t.is(n, 3);
259 });
260});
261
262test.cb(t => {
263 t.plan(1);
264
265 someAsyncFunction(() => {
266 t.pass();
267 t.end();
268 });
269});
270```
271
272These won't:
273
274```js
275test(t => {
276 t.plan(2);
277
278 for (let i = 0; i < 3; i++) {
279 t.true(i < 3);
280 }
281}); // fails, 3 assertions are executed which is too many
282
283test(t => {
284 t.plan(1);
285
286 someAsyncFunction(() => {
287 t.pass();
288 });
289}); // fails, the test ends synchronously before the assertion is executed
290```
291
292### Running tests serially
293
294By default tests are run concurrently, which is awesome. Sometimes though you have to write tests that cannot run concurrently.
295
296In these rare cases you can use the `.serial` modifier. It'll force those tests to run serially *before* the concurrent ones.
297
298```js
299test.serial(t => {
300 t.pass();
301});
302```
303
304Note that this only applies to tests within a particular test file. AVA will still run multiple tests files at the same time unless you pass the [`--serial` CLI flag](#cli).
305
306### Running specific tests
307
308During development it can be helpful to only run a few specific tests. This can be accomplished using the `.only` modifier:
309
310```js
311test('will not be run', t => {
312 t.fail();
313});
314
315test.only('will be run', t => {
316 t.pass();
317});
318```
319
320`.only` applies across all test files, so if you use it in one file, no tests from the other file will run.
321
322### Running tests with matching titles
323
324The `--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`](https://github.com/sindresorhus/matcher) for more details.
325
326Match titles ending with `foo`:
327
328```console
329$ ava --match='*foo'
330```
331
332Match titles starting with `foo`:
333
334```console
335$ ava --match='foo*'
336```
337
338Match titles containing `foo`:
339
340```console
341$ ava --match='*foo*'
342```
343
344Match titles that are *exactly* `foo` (albeit case insensitively):
345
346```console
347$ ava --match='foo'
348```
349
350Watch titles not containing `foo`:
351
352```console
353$ ava --match='!*foo*'
354```
355
356Match titles starting with `foo` and ending with `bar`:
357
358```console
359$ ava --match='foo*bar'
360```
361
362Match titles starting with `foo` or ending with `bar`:
363
364```console
365$ ava --match='foo*' --match='*bar'
366```
367
368Note 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 callback function will be skipped when `--match` is used.
369
370Here's what happens when you run AVA with a match pattern of `*oo*` and the following tests:
371
372```js
373test('foo will run', t => {
374 t.pass();
375});
376
377test('moo will also run', t => {
378 t.pass();
379});
380
381test.only('boo will run but not exclusively', t => {
382 t.pass();
383});
384
385// won't run, no title
386test(function (t) {
387 t.fail();
388});
389
390// won't run, no explicit title
391test(function foo(t) {
392 t.fail();
393});
394```
395
396### Skipping tests
397
398Sometimes failing tests can be hard to fix. You can tell AVA to skip these tests using the `.skip` modifier. They'll still be shown in the output (as having been skipped) but are never run.
399
400```js
401test.skip('will not be run', t => {
402 t.fail();
403});
404```
405
406You must specify the callback function.
407
408### Test placeholders ("todo")
409
410You can use the `.todo` modifier when you're planning to write a test. Like skipped tests these placeholders are shown in the output. They only require a title; you cannot specify the callback function.
411
412```js
413test.todo('will think about writing this later');
414```
415
416### Before & after hooks
417
418AVA lets you register hooks that are run before and after your tests. This allows you to run setup and/or teardown code.
419
420`test.before()` registers a hook to be run before the first test in your test file. Similarly `test.after()` registers a hook to be run after the last test.
421
422`test.beforeEach()` registers a hook to be run before each test in your test file. Similarly `test.afterEach()` a hook to be run after each test.
423
424Like `test()` these methods take an optional title and a callback function. The title is shown if your hook fails to execute. The callback is called with an [execution object](#t).
425
426`before` hooks execute before `beforeEach` hooks. `afterEach` hooks execute before `after` hooks. Within their category the hooks execute in the order they were defined.
427
428```js
429test.before(t => {
430 // this runs before all tests
431});
432
433test.before(t => {
434 // this runs after the above, but before tests
435});
436
437test.after('cleanup', t => {
438 // this runs after all tests
439});
440
441test.beforeEach(t => {
442 // this runs before each test
443});
444
445test.afterEach(t => {
446 // this runs after each test
447});
448
449test(t => {
450 // regular test
451});
452```
453
454Hooks can be synchronous or asynchronous, just like tests. To make a hook asynchronous return a promise or observable, use an async function, or enable callback mode via `test.cb.before()`, `test.cb.beforeEach()` etc.
455
456```js
457test.before(async t => {
458 await promiseFn();
459});
460
461test.after(t => {
462 return new Promise(/* ... */);
463});
464
465test.cb.beforeEach(t => {
466 setTimeout(t.end);
467});
468
469test.afterEach.cb(t => {
470 setTimeout(t.end);
471});
472```
473
474Keep in mind that the `beforeEach` and `afterEach` hooks run just before and after a test is run, and that by default tests run concurrently. If you need to set up global state for each test (like spying on `console.log` [for example](https://github.com/sindresorhus/ava/issues/560)), you'll need to make sure the tests are [run serially](#running-tests-serially).
475
476Remember that AVA runs each test file in its own process. You may not have to clean up global state in a `after`-hook since that's only called right before the process exits.
477
478The `beforeEach` & `afterEach` hooks can share context with the test:
479
480```js
481test.beforeEach(t => {
482 t.context.data = generateUniqueData();
483});
484
485test(t => {
486 t.is(t.context.data + 'bar', 'foobar');
487});
488```
489
490By default `t.context` is an object but you can reassign it:
491
492```js
493test.beforeEach(t => {
494 t.context = 'unicorn';
495});
496
497test(t => {
498 t.is(t.context, 'unicorn');
499});
500```
501
502Context sharing is *not* available to `before` and `after` hooks.
503
504### Chaining test modifiers
505
506You can use the `.serial`, `.only` and `.skip` modifiers in any order, with `test`, `before`, `after`, `beforeEach` and `afterEach`. For example:
507
508```js
509test.before.skip(...);
510test.skip.after(...);
511test.serial.only(...);
512test.only.serial(...);
513```
514
515This means you can temporarily add `.skip` or `.only` at the end of a test or hook definition without having to make any other changes.
516
517### Custom assertions
518
519You can use any assertion library instead of or in addition to the built-in one, provided it throws exceptions when the assertion fails.
520
521This won't give you as nice an experience as you'd get with the [built-in assertions](#assertions) though, and you won't be able to use the [assertion planning](#assertion-planning) ([see #25](https://github.com/sindresorhus/ava/issues/25)).
522
523```js
524import assert from 'assert';
525
526test(t => {
527 assert(true);
528});
529```
530
531### ES2015 support
532
533AVA comes with built-in support for ES2015 through [Babel 6](https://babeljs.io). Just write your tests in ES2015. No extra setup needed. You can use any Babel version in your project. We use our own bundled Babel with the [`es2015`](https://babeljs.io/docs/plugins/preset-es2015/) and [`stage-2`](https://babeljs.io/docs/plugins/preset-stage-2/) presets, as well as the [`espower`](https://github.com/power-assert-js/babel-plugin-espower) and [`transform-runtime`](https://babeljs.io/docs/plugins/transform-runtime/) plugins.
534
535The corresponding Babel config for AVA's setup is as follows:
536
537```json
538{
539 "presets": [
540 "es2015",
541 "stage-0",
542 ],
543 "plugins": [
544 "espower",
545 "transform-runtime"
546 ]
547}
548```
549
550You can customize how AVA transpiles the test files through the `babel` option in AVA's [`package.json` configuration](#configuration). For example to override the presets you can use:
551
552```json
553{
554 "ava": {
555 "babel": {
556 "presets": [
557 "es2015",
558 "stage-0",
559 "react"
560 ]
561 }
562 },
563}
564```
565
566You can also use the special `"inherit"` keyword. This makes AVA defer to the Babel config in your [`.babelrc` or `package.json` file](https://babeljs.io/docs/usage/babelrc/). This way your test files will be transpiled using the same config as your source files without having to repeat it just for AVA:
567
568 ```json
569{
570 "babel": {
571 "presets": [
572 "es2015",
573 "stage-0",
574 "react"
575 ]
576 },
577 "ava": {
578 "babel": "inherit",
579 },
580}
581```
582
583Note that AVA will *always* apply the [`espower`](https://github.com/power-assert-js/babel-plugin-espower) and [`transform-runtime`](https://babeljs.io/docs/plugins/transform-runtime/) plugins.
584
585### TypeScript support
586
587AVA includes typings for TypeScript. You have to set up transpilation yourself. When you set `module` to `commonjs` in your `tsconfig.json` file, TypeScript will automatically find the type definitions for AVA. You should set `target` to `es2015` to use promises and async functions.
588
589### Transpiling imported modules
590
591AVA currently only transpiles the tests you ask it to run. *It will not transpile modules you `import` from outside of the test.* This may be unexpected but there are workarounds.
592
593If you use Babel you can use its [require hook](https://babeljs.io/docs/usage/require/) to transpile imported modules on-the-fly. Run AVA with `--require babel-register` (see [CLI](#cli)) or [configure it in your `package.json`](#configuration).
594
595You can also transpile your modules in a separate process and refer to the transpiled files rather than the sources from your tests.
596
597### Promise support
598
599If you return a promise in the test you don't need to explicitly end the test as it will end when the promise resolves.
600
601```js
602test(t => {
603 return somePromise().then(result => {
604 t.is(result, 'unicorn');
605 });
606});
607```
608
609### Generator function support
610
611AVA comes with built-in support for [generator functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*).
612
613```js
614test(function * (t) {
615 const value = yield generatorFn();
616 t.true(value);
617});
618```
619
620### Async function support
621
622AVA comes with built-in support for [async functions](https://tc39.github.io/ecmascript-asyncawait/) *(async/await)*.
623
624```js
625test(async function (t) {
626 const value = await promiseFn();
627 t.true(value);
628});
629
630// async arrow function
631test(async t => {
632 const value = await promiseFn();
633 t.true(value);
634});
635```
636
637### Observable support
638
639AVA comes with built-in support for [observables](https://github.com/zenparsing/es-observable). If you return an observable from a test, AVA will automatically consume it to completion before ending the test.
640
641*You do not need to use "callback mode" or call `t.end()`.*
642
643```js
644test(t => {
645 t.plan(3);
646 return Observable.of(1, 2, 3, 4, 5, 6)
647 .filter(n => {
648 // only even numbers
649 return n % 2 === 0;
650 })
651 .map(() => t.pass());
652});
653```
654
655### Callback support
656
657AVA supports using `t.end` as the final callback when using node-style error-first callback APIs. AVA will consider any truthy value passed as the first argument to `t.end` to be an error. Note that `t.end` requires "callback mode", which can be enabled by using the `test.cb` chain.
658
659```js
660test.cb(t => {
661 // t.end automatically checks for error as first argument
662 fs.readFile('data.txt', t.end);
663});
664```
665
666### Optional TAP output
667
668AVA can generate TAP output via `--tap` option for use with any [TAP reporter](https://github.com/sindresorhus/awesome-tap#reporters).
669
670```console
671$ ava --tap | tap-nyan
672```
673
674<img src="media/tap-output.png" width="398">
675
676### Clean stack traces
677
678AVA automatically removes unrelated lines in stack traces, allowing you to find the source of an error much faster.
679
680<img src="media/stack-traces.png" width="300">
681
682## API
683
684### `test([title], callback)`
685### `test.serial([title], callback)`
686### `test.cb([title], callback)`
687### `test.only([title], callback)`
688### `test.skip([title], callback)`
689### `test.todo(title)`
690### `test.before([title], callback)`
691### `test.after([title], callback)`
692### `test.beforeEach([title], callback)`
693### `test.afterEach([title], callback)`
694
695#### `title`
696
697Type: `string`
698
699Test title.
700
701#### `callback(t)`
702
703Type: `function`
704
705Should contain the actual test.
706
707##### `t`
708
709Type: `object`
710
711The execution object of a particular test. Each test callback receives a different object. Contains the [assertions](#assertions) as well as `.plan(count)` and `.end()` methods. `t.context` can contain shared state from `beforeEach` hooks.
712
713###### `t.plan(count)`
714
715Plan how many assertion there are in the test. The test will fail if the actual assertion count doesn't match the number of planned assertions. See [assertion planning](#assertion-planning).
716
717###### `t.end()`
718
719End the test. Only works with `test.cb()`.
720
721## Assertions
722
723Assertions are mixed into the [execution object](#t) provided to each test callback:
724
725```js
726test(t => {
727 t.ok('unicorn'); // assertion
728});
729```
730
731If multiple assertion failures are encountered within a single test, AVA will only display the *first* one.
732
733### `.pass([message])`
734
735Passing assertion.
736
737### `.fail([message])`
738
739Failing assertion.
740
741### `.ok(value, [message])`
742
743Assert that `value` is truthy.
744
745### `.notOk(value, [message])`
746
747Assert that `value` is falsy.
748
749### `.true(value, [message])`
750
751Assert that `value` is `true`.
752
753### `.false(value, [message])`
754
755Assert that `value` is `false`.
756
757### `.is(value, expected, [message])`
758
759Assert that `value` is equal to `expected`.
760
761### `.not(value, expected, [message])`
762
763Assert that `value` is not equal to `expected`.
764
765### `.same(value, expected, [message])`
766
767Assert that `value` is deep equal to `expected`.
768
769### `.notSame(value, expected, [message])`
770
771Assert that `value` is not deep equal to `expected`.
772
773### `.throws(function|promise, [error, [message]])`
774
775Assert that `function` throws an error, or `promise` rejects with an error.
776
777`error` can be a constructor, regex, error message or validation function.
778
779Returns the error thrown by `function` or the rejection reason of `promise`.
780
781### `.notThrows(function|promise, [message])`
782
783Assert that `function` doesn't throw an `error` or `promise` resolves.
784
785### `.regex(contents, regex, [message])`
786
787Assert that `contents` matches `regex`.
788
789### `.ifError(error, [message])`
790
791Assert that `error` is falsy.
792
793### Skipping assertions
794
795Any assertion can be skipped using the `skip` modifier. Skipped assertions are still counted, so there is no need to change your planned assertion count.
796
797```js
798test(t => {
799 t.plan(2);
800 t.skip.is(foo(), 5); // no need to change your plan count when skipping
801 t.is(1, 1);
802});
803```
804
805### Enhanced assertion messages
806
807AVA comes with [`power-assert`](https://github.com/power-assert-js/power-assert) built-in, giving you more descriptive assertion messages. It reads your test and tries to infer more information from the code.
808
809Let's take this example, using Node's standard [`assert` library](https://nodejs.org/api/assert.html):
810
811```js
812const a = /foo/;
813const b = 'bar';
814const c = 'baz';
815require('assert').ok(a.test(b) || b === c);
816```
817
818If you paste that into a Node REPL it'l return:
819
820```
821AssertionError: false == true
822```
823
824In AVA however, this test:
825
826```js
827test(t => {
828 const a = /foo/;
829 const b = 'bar';
830 const c = 'baz';
831 t.ok(a.test(b) || b === c);
832});
833```
834
835Will output:
836
837```
838t.ok(a.test(b) || b === c)
839 | | | |
840 | "bar" "bar" "baz"
841 false
842```
843
844## Process isolation
845
846Each test file is run in a separate Node.js process. This allows you to change the global state or overriding a built-in in one test file, without affecting another. It's also great for performance on modern multi-core processors, allowing multiple test files to execute in parallel.
847
848## Tips
849
850### Temp files
851
852Running tests concurrently comes with some challenges, doing file IO is one.
853
854Usually, serial tests create temp directories in the current test directory and clean them up at the end. This won't work when you run tests concurrently as tests will conflict with each other. The correct way to do it is to use a new temp directory for each test. The [`tempfile`](https://github.com/sindresorhus/tempfile) and [`temp-write`](https://github.com/sindresorhus/temp-write) modules can be helpful.
855
856### Debugging
857
858AVA runs tests concurrently by default, which is suboptimal when you need to debug something. Instead, run tests serially with the `--serial` option:
859
860```console
861$ ava --serial
862```
863
864### Code coverage
865
866You can't use [`istanbul`](https://github.com/gotwarlost/istanbul) for code coverage as AVA [spawns the test files](#process-isolation). You can use [`nyc`](https://github.com/bcoe/nyc) instead, which is basically `istanbul` with support for subprocesses.
867
868As of version `5.0.0` it uses source maps to report coverage for your actual code, regardless of transpilation. Make sure that the code you're testing includes an inline source map or references a source map file. If you use `babel-register` you can set the `sourceMaps` option in your Babel config to `inline`.
869
870## FAQ
871
872### Why not `mocha`, `tape`, `tap`?
873
874Mocha requires you to use implicit globals like `describe` and `it` with the default interface (which most people use). It's not very opinionated and executes tests serially without process isolation, making it slow.
875
876Tape and tap are pretty good. AVA is highly inspired by their syntax. They too execute tests serially. Their default [TAP](https://testanything.org) output isn't very user-friendly though so you always end up using an external tap reporter.
877
878In contrast AVA is highly opinionated and runs tests concurrently, with a separate processes for each test file. Its default reporter is easy on the eyes and yet AVA still supports TAP output through a CLI flag.
879
880### How can I use custom reporters?
881
882AVA supports the TAP format and thus is compatible with any [TAP reporter](https://github.com/sindresorhus/awesome-tap#reporters). Use the [`--tap` flag](#optional-tap-output) to enable TAP output.
883
884### How is the name written and pronounced?
885
886AVA, not Ava or ava. Pronounced [`/ˈeɪvə/` ay-və](media/pronunciation.m4a?raw=true).
887
888### What is the header background?
889
890It's the [Andromeda galaxy](https://simple.wikipedia.org/wiki/Andromeda_galaxy).
891
892### What is the difference between concurrency and parallelism?
893
894[Concurrency is not parallelism. It enables parallelism.](https://stackoverflow.com/q/1050222)
895
896## Recipes
897
898- [Code coverage](docs/recipes/code-coverage.md)
899- [Watch mode](docs/recipes/watch-mode.md)
900- [Endpoint testing](docs/recipes/endpoint-testing.md)
901- [When to use `t.plan()`](docs/recipes/when-to-use-plan.md)
902- [Browser testing](docs/recipes/browser-testing.md)
903- [TypeScript](docs/recipes/typescript.md)
904
905## Support
906
907- [Stack Overflow](https://stackoverflow.com/questions/tagged/ava)
908- [Gitter chat](https://gitter.im/sindresorhus/ava)
909- [Twitter](https://twitter.com/ava__js)
910
911## Related
912
913- [sublime-ava](https://github.com/sindresorhus/sublime-ava) - Snippets for AVA tests
914- [atom-ava](https://github.com/sindresorhus/atom-ava) - Snippets for AVA tests
915- [vscode-ava](https://github.com/samverschueren/vscode-ava) - Snippets for AVA tests
916- [eslint-plugin-ava](https://github.com/sindresorhus/eslint-plugin-ava) - Lint rules for AVA tests
917- [gulp-ava](https://github.com/sindresorhus/gulp-ava) - Run tests with gulp
918- [grunt-ava](https://github.com/sindresorhus/grunt-ava) - Run tests with grunt
919- [fly-ava](https://github.com/pine613/fly-ava) - Run tests with fly
920- [start-ava](https://github.com/start-runner/ava) - Run tests with start
921
922## Links
923
924- [Buy AVA stickers](https://www.stickermule.com/user/1070705604/stickers)
925- [Awesome list](https://github.com/sindresorhus/awesome-ava)
926
927## Team
928
929[![Sindre Sorhus](https://avatars.githubusercontent.com/u/170270?s=130)](http://sindresorhus.com) | [![Vadim Demedes](https://avatars.githubusercontent.com/u/697676?s=130)](https://github.com/vdemedes) | [![James Talmage](https://avatars.githubusercontent.com/u/4082216?s=130)](https://github.com/jamestalmage) | [![Mark Wubben](https://avatars.githubusercontent.com/u/33538?s=130)](https://novemberborn.net)
930---|---|---|---|---
931[Sindre Sorhus](http://sindresorhus.com) | [Vadim Demedes](https://github.com/vdemedes) | [James Talmage](https://github.com/jamestalmage) | [Mark Wubben](https://novemberborn.net)
932
933### Former
934
935- [Kevin Mårtensson](https://github.com/kevva)
936
937<div align="center">
938 <br>
939 <br>
940 <br>
941 <img src="https://cdn.rawgit.com/sindresorhus/ava/fe1cea1ca3d2c8518c0cc39ec8be592beab90558/media/logo.svg" width="200" alt="AVA">
942 <br>
943 <br>
944</div>