{"id":12855,"library":"ava","title":"AVA Test Runner","description":"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.","status":"active","version":"7.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/avajs/ava","tags":["javascript","🦄","test","runner","testing","ava","concurrent","parallel","fast","typescript"],"install":[{"cmd":"npm install ava","lang":"bash","label":"npm"},{"cmd":"yarn add ava","lang":"bash","label":"yarn"},{"cmd":"pnpm add ava","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides enhanced TypeScript integration, including type definitions for AVA's test context and utilities.","package":"@ava/typescript","optional":true}],"imports":[{"note":"AVA's documentation assumes ES modules and `test` is the default export for defining tests. CommonJS `require` is not the recommended approach.","wrong":"const test = require('ava');","symbol":"test","correct":"import test from 'ava';"},{"note":"For TypeScript users, `TestFn` is a type definition for the test callback function. AVA ships with its own TypeScript types.","symbol":"TestFn","correct":"import type { TestFn } from 'ava';"},{"note":"For TypeScript users, `ExecutionContext` is a type definition for the `t` object passed to test functions, providing type safety for assertions and other test utilities.","symbol":"ExecutionContext","correct":"import type { ExecutionContext } from 'ava';"}],"quickstart":{"code":"import test from 'ava';\n\ntest('my synchronous test', t => {\n\tt.pass('This assertion should pass.');\n});\n\ntest('my asynchronous test', async t => {\n\tconst result = await Promise.resolve('foo');\n\tt.is(result, 'foo', 'The promise should resolve to foo.');\n});\n\ntest.serial('a test requiring serial execution', async t => {\n  // Simulate an operation that should not run concurrently\n  const tempResource = await createResource();\n  t.truthy(tempResource);\n  await cleanupResource(tempResource);\n});\n\nasync function createResource() {\n  // In a real scenario, this might be a database connection or file handle\n  console.log('Resource created.');\n  return 'resource-id-123';\n}\n\nasync function cleanupResource(id) {\n  console.log(`Resource ${id} cleaned up.`);\n}\n","lang":"typescript","description":"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."},"warnings":[{"fix":"Upgrade your Node.js environment to a supported version. Update your `engines.node` field in `package.json` accordingly.","message":"AVA v7.0.0 removed official support for Node.js 18 and 23. You must upgrade to Node.js 20.19 or newer, 22.20 or newer, or 24.12 or newer.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Review dependencies and ensure no direct reliance on `strip-ansi`. Test your application thoroughly after upgrading.","message":"In v7.0.0, the internal `strip-ansi` dependency was replaced with Node.js's built-in `node:util.stripVTControlCharacters`. If your test setup directly or indirectly relied on the specific `strip-ansi` package, this change might impact your project.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"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.","message":"Since AVA v6.1.0, test code is expected to clean up gracefully, allowing the test environment (worker thread or child process) to exit. Failure to do so will result in a 'Test timed out' error.","severity":"gotcha","affected_versions":">=6.1.0"},{"fix":"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`.","message":"AVA must be installed locally as a development dependency and cannot be run globally. Attempting to run `ava` without local installation or `npx` will result in a 'command not found' error.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"AVA's documentation assumes you are using ES modules. While CommonJS can be configured, using `type: \"module\"` in your `package.json` is the recommended and best-supported approach, especially for features like TypeScript integration.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"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`.","cause":"AVA is not installed locally or is not in the system's PATH, and `npx` is not being used.","error":"command not found: ava"},{"fix":"Ensure `import test from 'ava';` is present at the top of your test file.","cause":"The `test` function, AVA's primary test definition utility, was not imported.","error":"ReferenceError: test is not defined"},{"fix":"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.","cause":"An asynchronous operation (e.g., a Promise, Observable, or I/O) did not complete within the configured timeout, or the test environment did not exit cleanly after tests finished.","error":"Test timed out."},{"fix":"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.","cause":"Attempting to use `require()` to import an ES Module within a CommonJS context, or `ava` itself encountering a mixed module issue. AVA primarily operates with ES Modules.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module [...] not supported. Instead change the require of [...] to a dynamic import()"},{"fix":"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.","cause":"The Node.js version being used is not compatible with the installed AVA version. AVA v7.0.0, for example, dropped support for Node.js 18 and 23.","error":"Your current Node.js version (vX.Y.Z) is not supported by AVA."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null}