# AVA — Confident Node.js Testing with Concurrent Execution > Futuristic Node.js test runner that runs tests concurrently for maximum speed and developer confidence. ## Install Save in your project root: # AVA — Confident Node.js Testing with Concurrent Execution ## Quick Use ```bash # Install npm init ava # Run tests npx ava # Run in watch mode npx ava --watch ``` ## Introduction AVA is a Node.js test runner that executes tests concurrently, taking advantage of the asynchronous nature of JavaScript to run faster than traditional sequential runners. It enforces atomic tests by running each test file in its own worker process, preventing shared state from leaking between tests. The result is a minimal, fast framework that encourages writing focused, isolated test cases. ## What AVA Does - Runs test files concurrently in isolated worker processes for true parallelism - Provides built-in support for async functions, observables, and promises - Includes a built-in assertion library with clear, readable output - Supports TypeScript out of the box with minimal configuration - Offers watch mode that re-runs only affected tests on file changes ## Architecture Overview AVA spawns a separate Node.js worker process for every test file, which means tests cannot accidentally share global state. The main process coordinates scheduling, collects results via IPC, and renders output. This process-per-file model guarantees isolation while enabling true concurrent execution across CPU cores. AVA uses its own assertion library internally to produce clean, diff-friendly error messages. ## Self-Hosting & Configuration - Add AVA via `npm init ava` which updates package.json automatically - Configure in `package.json` under the `"ava"` key or in a standalone `ava.config.mjs` - Set `concurrency` to limit how many test files run in parallel - Enable TypeScript by adding `"typescript": { "rewritePaths": { "src/": "build/" } }` - Use `files` array to specify custom test file glob patterns ## Key Features - Process isolation prevents test pollution and flaky shared-state bugs - Simple API — `test()`, `test.before()`, `test.after()` with no implicit globals - Magic assert powered by power-assert for detailed failure messages - Built-in watch mode with intelligent file tracking - Snapshot testing for serializable values without extra plugins ## Comparison with Similar Tools - **Jest** — batteries-included with built-in mocking; AVA is leaner and faster for I/O-heavy tests - **Mocha** — flexible but sequential by default; AVA runs concurrently out of the box - **Vitest** — Vite-native and very fast; AVA focuses on Node.js without bundler coupling - **Node.js built-in test runner** — zero-dependency but less mature assertion and reporting features - **Tape** — minimal and TAP-based; AVA adds concurrency, watch mode, and richer assertions ## FAQ **Q: Can AVA run tests sequentially?** A: Yes. Use `test.serial()` for tests that must run one at a time, or pass `--serial` to run everything sequentially. **Q: Does AVA support browser testing?** A: No. AVA is designed for Node.js. For browser tests, pair it with tools like Playwright or Puppeteer. **Q: How does AVA handle test setup and teardown?** A: Use `test.before()` and `test.after()` for per-file hooks, or `test.beforeEach()` and `test.afterEach()` for per-test hooks. **Q: Is AVA compatible with code coverage tools?** A: Yes. Use c8 or nyc with AVA — run `c8 ava` to collect coverage across all worker processes. ## Sources - https://github.com/avajs/ava - https://github.com/avajs/ava/blob/main/docs/01-writing-tests.md --- Source: https://tokrepo.com/en/workflows/fa7f2219-41ae-11f1-9bc6-00163e2b0d79 Author: AI Open Source