• Stars
    star
    20,694
  • Rank 1,209 (Top 0.03 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 10 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Node.js test runner that lets you develop with confidence 🚀

Please support our friend Vadim Demedes and the people in Ukraine.


AVA logo

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

Watch this repository and follow the Discussions 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. AVA cannot 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

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
Mark Wubben Sindre Sorhus
Former

More Repositories

1

ava-docs

Localized docs for AVA
501
star
2

awesome-ava

Awesome AVA resources
347
star
3

eslint-plugin-ava

ESLint rules for AVA
JavaScript
228
star
4

atom-ava

Snippets for AVA and run tests directly in the editor
JavaScript
103
star
5

typescript

Test TypeScript projects using AVA.
JavaScript
72
star
6

ava-codemods

Codemods for AVA
JavaScript
68
star
7

karma-ava

Karma plugin for AVA
JavaScript
63
star
8

gulp-ava

Run AVA tests
JavaScript
56
star
9

sublime-ava

Snippets for AVA
40
star
10

ava-snapshot-example

Example of snapshot testing a React component with AVA
JavaScript
36
star
11

babel-plugin-detective

Babel plugin that scans the AST for require calls and import statements
JavaScript
26
star
12

option-chain

Use fluent property chains in lieu of options objects
JavaScript
21
star
13

create-ava

Add AVA to your project
JavaScript
15
star
14

unique-temp-dir

Provides a uniquely named temp directory
JavaScript
13
star
15

babel-preset-stage-4

Efficiently applies the minimum of transforms to run stage 4 code on Node.js 6, 8 and 10
JavaScript
13
star
16

.github

12
star
17

babel

Babel provider for AVA.
JavaScript
11
star
18

get-port

Cooperative get-port implementation
TypeScript
9
star
19

ava-preact-init

Set up AVA for Preact
JavaScript
8
star
20

bucklescript

BuckleScript bindings for AVA
OCaml
8
star
21

grunt-ava

Run AVA tests
JavaScript
7
star
22

ava-files

DEPRECATED
JavaScript
7
star
23

cooperate

Plugin to enable cooperation between AVA test files
TypeScript
6
star
24

babel-plugin-ava-test-data

JavaScript
5
star
25

babel-preset-transform-test-files

Test file transforms as used by AVA
JavaScript
3
star
26

babel-plugin-throws-helper

Babel plugin for protecting against improper use of `t.throws()` in AVA
JavaScript
3
star
27

require-precompiled

Require extension that allows for caching/precompiling
JavaScript
2
star
28

ava-assert

[DEPRECATED] AVA's core assertion library
JavaScript
2
star
29

ava-colors

[DEPRECATED] A common set of colors for AVA
JavaScript
1
star
30

tap-emitter

JavaScript
1
star
31

test

A package that wraps AVA so AVA can use AVA to test AVA 🤯
JavaScript
1
star