Node.js test runner that lets you develop with confidence 🚀 (Forked from https://github.com/avajs/ava)
Find a file
2023-09-24 16:19:05 +02:00
.github Expect TypeScript 5.1 (or newer) 2023-07-02 17:26:14 +02:00
docs Fix typo in common pitfalls doc 2023-09-24 16:19:05 +02:00
entrypoints Make test-types work with tsc and XO 2023-07-03 15:46:29 +02:00
examples Modernize some syntax 2023-07-02 17:26:14 +02:00
lib Allow throws / throwsAsync to work with any value, not just errors 2023-09-11 13:12:20 +02:00
media Clean up documentation in preparation for AVA 4 2022-01-03 18:42:58 +01:00
scripts Set up CI to test the new watcher 2023-07-02 15:14:36 +02:00
test Refactor error processing 2023-09-10 15:26:35 +02:00
test-tap Allow throws / throwsAsync to work with any value, not just errors 2023-09-11 13:12:20 +02:00
test-types Allow throws / throwsAsync to work with any value, not just errors 2023-09-11 13:12:20 +02:00
types Allow throws / throwsAsync to work with any value, not just errors 2023-09-11 13:12:20 +02:00
.c8rc.json Tweak c8 config 2023-07-02 17:26:14 +02:00
.editorconfig Various minor tweaks 2017-05-10 04:22:42 +08:00
.gitattributes Handle png and snap files as binary (repo only) 2022-08-08 11:12:15 +02:00
.gitignore Add StackBlitz example for macros 2021-06-30 15:26:16 +02:00
.npmrc Upgrade to npm 8 and remove backwards-compatible lockfile 2021-10-31 15:47:04 +01:00
.taprc Update dependencies 2022-03-06 16:52:21 +01:00
.xo-config.cjs Update dependencies 2022-08-26 16:59:40 +02:00
ava.config.js Set up CI to test the new watcher 2023-07-02 15:14:36 +02:00
index.d.ts Re-organize types for maximum compatibility 2022-09-25 16:31:54 +02:00
license Meta tweaks 2017-06-26 19:08:16 +02:00
maintaining.md Test AVA using AVA 2020-05-05 15:07:07 +02:00
package-lock.json Refactor error processing 2023-09-10 15:26:35 +02:00
package.json Refactor error processing 2023-09-10 15:26:35 +02:00
plugin.d.ts Re-organize types for maximum compatibility 2022-09-25 16:31:54 +02:00
readme.md State that documentation assumes ES modules 2023-01-29 20:35:53 +01:00
tsconfig.json Update dependencies; more type tweaks 2022-09-25 17:06:16 +02:00

SWUbanner

AVA logo

AVA is a test runner for Node.js with a concise API, detailed error output, embrace of new language features and process isolation that lets you develop with confidence 🚀

Follow the AVA Twitter account for updates.

Read our contributing guide if you're looking to contribute (issues / PRs / etc).

Translations: Español, Français, Italiano, 日本語, 한국어, Português, Русский, 简体中文

Why AVA?

Usage

To install and set up AVA, run:

npm init ava

Your package.json will then look like this (exact version notwithstanding):

{
	"name": "awesome-package",
	"type": "module",
	"scripts": {
		"test": "ava"
	},
	"devDependencies": {
		"ava": "^5.0.0"
	}
}

Or if you prefer using Yarn:

yarn add ava --dev

Alternatively you can install ava manually:

npm install --save-dev ava

Make sure to install AVA locally. As of AVA 4 it can no longer be run globally.

Don't forget to configure the test script in your package.json as per above.

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

Supported Node.js versions

AVA supports the latest release of any major version that is supported by Node.js itself. Read more in our support statement.

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.

Parallel runs in CI

AVA automatically detects whether your CI environment supports parallel builds. Each build will run a subset of all test files, while still making sure all tests get executed. See the ci-parallel-vars package for a list of supported CI environments.

Documentation

Please see the files in the docs directory:

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

FAQ

Why not mocha, tape, tap?

Mocha requires you to use implicit globals like describe and it with the default interface (which most people use). It's not very opinionated and executes tests serially without process isolation, making it slow.

Tape and tap are pretty good. AVA is highly inspired by their syntax. They too execute tests serially. Their default TAP output isn't very user-friendly though so you always end up using an external tap reporter.

In contrast AVA is highly opinionated and runs tests concurrently, with a separate process for each test file. Its default reporter is easy on the eyes and yet AVA still supports TAP output through a CLI flag.

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.

Support

Team

Mark Wubben Sindre Sorhus
Mark Wubben Sindre Sorhus
Former