Create your test file
Create a file named test.js
in the project root directory.
Note that AVA’s documentation assumes you’re using ES modules.
import test from 'ava';
test('foo', t => {
t.pass();
});
test('bar', async t => {
const bar = Promise.resolve('bar');
t.is(await bar, 'bar');
});
Running your tests
npm test
Or with npx
:
npx ava
Run with the --watch
flag to enable AVA’s watch mode:
npx ava --watch
Highlights
Magic assert
AVA adds code excerpts and clean diffs for actual and expected values. If values in the assertion are objects or arrays, only a diff is displayed, to remove the noise and focus on the problem. The diff is syntax-highlighted too! If you are comparing strings, both single and multi line, AVA displays a different kind of output, highlighting the added or missing characters.
Clean stack traces
AVA automatically removes unrelated lines in stack traces, allowing you to find the source of an error much faster, as seen above.
Documentation
Please see the files in the docs
directory:
- Writing tests
- Execution context
- Assertions
- Snapshot testing
- Command line (CLI)
- Configuration
- Test timeouts
Common pitfalls
We have a growing list of common pitfalls you may experience while using AVA. If you encounter any issues you think are common, comment in this issue.
Recipes
- Test setup
- TypeScript
- Shared workers
- Watch mode
- When to use
t.plan()
- Passing arguments to your test files
- Splitting tests in CI
- Code coverage
- Endpoint testing
- Browser testing
- Testing Vue.js components
- Debugging tests with Chrome DevTools
- Debugging tests with VSCode
- Debugging tests with WebStorm
- Isolated MongoDB integration tests
- Testing web apps using Puppeteer
- Testing web apps using Selenium WebDriverJS
FAQ
How is the name written and pronounced?
AVA, not Ava or ava. Pronounced /ˈeɪvə/
: Ay (face, made) V (vie, have) A (comma, ago)
What is the header background?
It’s the Andromeda galaxy.
What is the difference between concurrency and parallelism?
Concurrency is not parallelism. It enables parallelism.
Related
- eslint-plugin-ava — Lint rules for AVA tests
- @ava/typescript — Test TypeScript projects
- @ava/cooperate — Low-level primitives to enable cooperation between test files
- @ava/get-port — Reserve a port while testing
Team
![]() |
![]() |
---|---|
Mark Wubben | Sindre Sorhus |