Popularity
9.2
Declining
Activity
8.2
Declining
20,620
227
1,408

Description

Even though JavaScript is single-threaded, IO in Node.js can happen in parallel due to its async nature. AVA takes advantage of this and runs your tests concurrently, which is especially beneficial for IO heavy tests. In addition, test files are run in parallel as separate processes, giving you even better performance and an isolated environment for each test file. Switching from Mocha to AVA in Pageres brought the test time down from 31 sec to 11 sec. Having tests run concurrently forces you to write atomic tests, meaning tests don't depend on global state or the state of other tests, which is a great thing!

Follow the AVA Twitter account for updates.

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

Code Quality Rank: L4
Monthly Downloads: 0
Programming language: JavaScript
License: MIT License
Tags: Promises     Generators     Testing     Node.Js     Java Script     TypeScript     Observable     Await     Async     Promise     Tap     TDD     Test     Mocha     Generator     Unit     CLI     Parallel     Function     Assert     Jasmine     Observables     Yield     Futuristic     Assertion     Cli-app     Qunit     Tape     Fast     Concurrent     Ava     Runner     Snapshot     Babel     Flow     Jest     Expect     🦄    
Latest version: v3.14.0

ava alternatives and similar modules

Based on the "Testing" category.
Alternatively, view ava alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of ava or a related project?

Add another 'Testing' Module

README

SWUbanner

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](.github/CONTRIBUTING.md) if you're looking to contribute (issues / PRs / etc).

[](media/verbose-reporter.png)

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

Why AVA?

  • Minimal and fast
  • Simple test syntax
  • Runs tests concurrently
  • Enforces writing atomic tests
  • No implicit globals
  • Includes TypeScript definitions
  • Magic assert
  • [Isolated environment for each test file](./docs/01-writing-tests.md#process-isolation)
  • [Promise support](./docs/01-writing-tests.md#promise-support)
  • [Async function support](./docs/01-writing-tests.md#async-function-support)
  • [Observable support](./docs/01-writing-tests.md#observable-support)
  • [Enhanced assertion messages](./docs/03-assertions.md#enhanced-assertion-messages)
  • Automatic parallel test runs in CI
  • [TAP reporter](./docs/05-command-line.md#tap-reporter)

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

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:

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](docs/recipes/watch-mode.md):

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](docs/support-statement.md).

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.

[](media/magic-assert-combined.png)

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](./docs):

  • [Writing tests](./docs/01-writing-tests.md)
  • [Execution context](./docs/02-execution-context.md)
  • [Assertions](./docs/03-assertions.md)
  • [Snapshot testing](./docs/04-snapshot-testing.md)
  • [Command line (CLI)](./docs/05-command-line.md)
  • [Configuration](./docs/06-configuration.md)
  • [Test timeouts](./docs/07-test-timeouts.md)

Common pitfalls

We have a growing list of [common pitfalls](docs/08-common-pitfalls.md) you may experience while using AVA. If you encounter any issues you think are common, comment in this issue.

Recipes

  • [Test setup](docs/recipes/test-setup.md)
  • [TypeScript](docs/recipes/typescript.md)
  • [Shared workers](docs/recipes/shared-workers.md)
  • [Watch mode](docs/recipes/watch-mode.md)
  • [When to use t.plan()](docs/recipes/when-to-use-plan.md)
  • [Passing arguments to your test files](docs/recipes/passing-arguments-to-your-test-files.md)
  • [Splitting tests in CI](docs/recipes/splitting-tests-ci.md)
  • [Code coverage](docs/recipes/code-coverage.md)
  • [Endpoint testing](docs/recipes/endpoint-testing.md)
  • [Browser testing](docs/recipes/browser-testing.md)
  • [Testing Vue.js components](docs/recipes/vue.md)
  • [Debugging tests with Chrome DevTools](docs/recipes/debugging-with-chrome-devtools.md)
  • [Debugging tests with VSCode](docs/recipes/debugging-with-vscode.md)
  • [Debugging tests with WebStorm](docs/recipes/debugging-with-webstorm.md)
  • [Isolated MongoDB integration tests](docs/recipes/isolated-mongodb-integration-tests.md)
  • [Testing web apps using Puppeteer](docs/recipes/puppeteer.md)
  • [Testing web apps using Selenium WebDriverJS](docs/recipes/testing-with-selenium-webdriverjs.md)

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ə/](media/pronunciation.m4a?raw=true): Ay (f*ace, made) V (vie, have) A (comma, **a*go)

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