AVA is a minimalist and fast Node.js test runner, currently at stable version 7.0.0. It distinguishes itself by running tests concurrently in isolated environments (worker threads or child processes), enforcing the writing of atomic tests, and providing a concise API without implicit globals. AVA ships with TypeScript definitions and emphasizes developer experience with "magic assert" for enhanced assertion messages, clean stack traces that remove irrelevant lines, and automatic parallel test runs in CI environments. It generally follows Node.js's release schedule for supported versions, aligning with major Node.js updates, and has a frequent release cadence, as indicated by its version history.
npm install avaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define basic synchronous and asynchronous tests with AVA, including an example of serial execution for resources that can't be tested concurrently, which is a common pattern given AVA's concurrent nature.
Upgrade your Node.js environment to a supported version. Update your `engines.node` field in `package.json` accordingly.
Review dependencies and ensure no direct reliance on `strip-ansi`. Test your application thoroughly after upgrading.
Use `t.teardown()` for asynchronous cleanup or `registerCompletionHandler()` for global cleanup logic to ensure all operations are complete and resources are freed before the test environment exits.
Always install AVA using `npm install --save-dev ava` or `yarn add ava --dev`. Run tests via `npm test` (if configured in `package.json`) or `npx ava`.
Ensure your `package.json` includes `"type": "module"`. If using CommonJS, explicit configuration might be necessary, and some features may require additional setup or not be fully compatible without transpilation.
Install AVA locally (`npm install --save-dev ava`) and run tests using `npx ava` or by defining a `"test": "ava"` script in `package.json` and running `npm test`.
Ensure `import test from 'ava';` is present at the top of your test file.
Ensure all promises are `await`ed, observables are completed, and resources are cleaned up. Use `t.teardown()` or `registerCompletionHandler()` for proper asynchronous cleanup. Adjust the timeout with `--timeout` flag if necessary.
Configure your project for ES Modules by setting `"type": "module"` in your `package.json`. If you must use CommonJS, ensure proper transpilation or dynamic `import()` calls where necessary, or structure your project to avoid mixing module systems.
Update your Node.js environment to a version officially supported by your AVA release. Check AVA's release notes or `package.json` `engines.node` field for supported versions.