AVA
Concise test runner for Node.js with concurrent tests, async first-class support and rich assertions.
Official Documentation ↗ava v6.x / Node 18 LTS. Check the official docs for the latest API surface.Installation
npm install avapnpm add avayarn add avaMethods
No methods match this filter.
Overview
AVA runs tests concurrently with a minimal API built around async functions and an assertion object. Its concurrency model speeds up suites but demands isolation between tests.
Core Methods
test declares a test, and the assertion object exposes is, deepEqual, throws, snapshot and more. test.serial forces sequential execution, and hooks such as before and after manage setup.
Usage Notes
Isolate state per test, mark tests serial when they share resources, and use assertion planning sparingly. Keep each test focused on one behavior for actionable failures.
Common Pitfalls
Concurrency makes order-dependent tests flaky, so seeds of randomness and shared files must be handled carefully. Snapshot churn can hide regressions if updates are accepted without review.
FAQ
- Do AVA tests run concurrently?
- Yes, tests run concurrently by default and complete independently, which is fast but requires tests to avoid shared mutable state. Use test.serial for tests that must not overlap.
- How do I handle async tests?
- Return or await the promise, or declare the test function async. AVA waits for the returned promise and reports unhandled rejections.
- What about snapshots?
- t.snapshot records a serialized value the first time and compares on later runs. Update snapshots with the runner flag and review diffs before accepting them.
Report a problem with this API docOpens a pre-filled issue on GitHub.