This is not GitHub.com

Like what you see? Install OctoLinker now!

Skip to content
Node.js test runner that lets you develop with confidence 🚀
JavaScript TypeScript
Branch: master
Clone or download

Latest commit

novemberborn Update dependencies
* Update dev dependencies

* Test with TypeScript 3.9

* Update dependencies

This includes a major update to Concordance, letting us print missing or extraneous objects in diffs with extra depth. See concordancejs/concordance#62.

* Rebuild package-lock
Latest commit 34a134a May 24, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update dependencies May 24, 2020
docs Update endpoint testing recipe to use correct options for got May 24, 2020
lib Reporter improvements May 12, 2020
media Only apply power-assert to new t.assert() assertion Mar 24, 2019
test-d Upgrade XO Mar 30, 2020
test-tap Reporter improvements May 12, 2020
test Test AVA using AVA May 5, 2020
.c8rc.json Test AVA using AVA May 5, 2020
.editorconfig Various minor tweaks May 9, 2017
.gitattributes CI updates Nov 5, 2018
.gitignore Test AVA using AVA May 5, 2020
.taprc Reorganize tests Mar 29, 2020
ava.config.js Test AVA using AVA May 5, 2020
cli.js Remove unnecessary try/catch from cli script Apr 22, 2018
eslint-plugin-helper.js Upgrade XO Mar 30, 2020
index.d.ts Add `t.teardown()` Apr 26, 2020
index.js Reorganize worker code Apr 22, 2018
license Meta tweaks Jun 26, 2017
maintaining.md Test AVA using AVA May 5, 2020
package-lock.json Update dependencies May 24, 2020
package.json Update dependencies May 24, 2020
readme.md Prep for release May 8, 2020
xo.config.js Configure import/no-unresolved linter rule May 8, 2020

readme.md

AVA logo

Build Status Coverage Status XO code style Join the community on Spectrum Mentioned in Awesome Node.js

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",
	"scripts": {
		"test": "ava"
	},
	"devDependencies": {
		"ava": "^1.0.0"
	}
}

Or if you prefer using Yarn:

yarn add ava --dev

Alternatively you can install ava manually:

npm install --save-dev ava

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:

const test = require('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

Related

Links

Team

Mark Wubben Sindre Sorhus Vadim Demedes
Mark Wubben Sindre Sorhus Vadim Demedes
Former
You can’t perform that action at this time.