---
title: AVA
description: Learn how to integrate Allure with AVA to generate rich, interactive test reports. Follow step-by-step setup, test execution, and report generation guidance.
---

# Getting started with Allure AVA

[![Allure AVA npm latest version](https://img.shields.io/npm/v/allure-ava?style=flat "Allure AVA npm latest version")](https://www.npmjs.com/package/allure-ava)

Generate beautiful HTML reports using [Allure Report](https://allurereport.org/docs/) and your [AVA](https://avajs.dev/) tests.

## Setting up

### 1. Prepare your project

1. Make sure [Node.js](https://nodejs.org/) is installed.

   Allure AVA requires AVA 8 or later. AVA 8 requires Node.js `^22.20`, `^24.12`, or `>=26`.

1. Open a terminal and go to the project directory. For example:

   ```bash
   cd /home/user/myproject
   ```

1. Make sure Allure Report is installed. If it's not, follow the [installation instructions](/docs/v2/install/). Note that Allure Report requires Java.

1. Install the Allure AVA integration:

   **npm:**
   ```bash
   npm install --save-dev allure-ava ava
   ```

   **yarn:**
   ```bash
   yarn add --dev allure-ava ava
   ```

   **pnpm:**
   ```bash
   pnpm add -D allure-ava ava
   ```

1. Call `installAllure()` from your AVA configuration file.

   For an ESM config (`ava.config.mjs`):

   ```js
   // ava.config.mjs
   import { installAllure } from "allure-ava";

   await installAllure({
     resultsDir: "allure-results",
   });

   export default {};
   ```

   If your project does not use `"type": "module"` in its `package.json`, keep the configuration in CommonJS — name the file `ava.config.js` and export an async factory:

   ```js
   // ava.config.js
   module.exports = async () => {
     const { installAllure } = await import("allure-ava");

     await installAllure({
       resultsDir: "allure-results",
     });

     return {};
   };
   ```

   Note that AVA only reads `ava.config.js` and `ava.config.mjs`; a file named `ava.config.cjs` is silently ignored.

   Your test files themselves do not need any changes. Optionally, specify `resultsDir` and other options. See [Allure AVA configuration](/docs/ava-configuration/) for more details.

   Tip:
   If the tests run but the results directory is not created and the console prints `no test runtime is found`, AVA did not load your configuration file — check its name and location.

### 2. Run tests

Run your AVA tests the same way you would run them usually:

```bash
npx ava
```

This will save the necessary data into `allure-results` or another directory, according to the [configuration](/docs/ava-configuration/). If the directory already exists, new files will be added to the existing ones so that a future report will be based on them all.

Tests declared with `test.skip()` or `test.todo()`, as well as tests excluded by `test.skipIf()` and `test.runIf()` conditions, appear in the report with the **Skipped** status.

Tests declared with `test.failing()` follow AVA's own semantics: when such a test fails as expected, it counts as successful and appears in the report with the **Passed** status; if it unexpectedly passes, it is reported as **Broken** with AVA's "Test was expected to fail, but succeeded" error.

If an AVA worker process crashes, times out, or exits unexpectedly, the tests affected by it appear in the report with the **Broken** status.

You can still pass regular AVA CLI arguments:

```bash
npx ava test/**/*.test.js --match "signing in"
```

### 3. Generate a report

Finally, convert the test results into an HTML report. This can be done by one of two commands:

- `allure generate` processes the test results and saves an HTML report into the `allure-report` directory. To view the report, use the `allure open` command.

- `allure serve` creates the same report as `allure generate`, then automatically opens the main page of the report in a web browser.

## Writing tests

The Allure AVA integration extends the standard reporting features of AVA by providing additional capabilities for crafting more informative and structured tests. This section highlights key enhancements that can be utilized:

- **Metadata Annotation**: Enhance test reports with [descriptions, links, and other metadata](#add-metadata).
- **Test Organization**: Structure your tests into clear hierarchies for better readability and organization, see [organize tests](#organize-tests).
- **Step Division**: Break down tests into smaller [test steps](#divide-a-test-into-steps) for easier understanding and maintenance.
- **Parametrized Tests**: Clearly describe the parameters for [parametrized tests](#describe-parametrized-tests) to specify different scenarios.
- **Set labels globally**: Use [environment variables](#set-labels-globally) to set metadata and other labels.
- **Attachments**: Capture [files and other content](#attach-files) during test execution.
- **Test Selection**: Use a test plan file to [select which tests to run](#select-tests-via-a-test-plan-file), allowing for flexible test execution.
- **Environment Details**: Include comprehensive [environment information](#environment-information) to accompany the test report.

In most cases, Allure AVA provides two different ways to use a feature: the Runtime API and the Metadata API.

- **Runtime API**: use Allure's functions to add certain data to the test result during its execution. This approach allows for constructing the data dynamically.

  Note that it is recommended to call Allure's functions as close to the beginning of the test as possible. This way, the data will be added even if the test fails early.

- **Metadata API**: add a metadata tag (beginning with `@allure.`) into the test name. Allure AVA will extract it and update the test result's data accordingly. When using this approach, the data is guaranteed to be added regardless of how the test itself runs.

### Add metadata

Allure allows you to enrich your reports with a variety of [metadata](/docs/v2/readability/#description-links-and-other-metadata). This additional information provides context and details for each test, enhancing the report's usefulness. Refer to the [metadata reference section](/docs/ava-reference/#metadata) for an exhaustive list of what can be added.

**Runtime API:**
```js
import * as allure from "allure-js-commons";
import test from "ava";

test("Test Authentication", async (t) => {
  await allure.displayName("Test Authentication");
  await allure.owner("John Doe");
  await allure.tags("Web interface", "Authentication");
  await allure.severity("critical");
  // ...
  t.pass();
});
```

**Metadata API:**
```js
import test from "ava";

test(
  "Test Authentication" +
    " @allure.label.owner:JohnDoe" +
    " @allure.label.tag:WebInterface" +
    " @allure.label.tag:Authentication" +
    " @allure.label.severity:critical",
  (t) => {
    // ...
    t.pass();
  },
);
```

### Organize tests

As described in [Improving navigation in your test report](/docs/v2/navigation/), Allure supports multiple ways to organize tests into hierarchical structures.

To specify a test's location in the [behavior-based hierarchy](/docs/v2/navigation/#behavior-based-hierarchy):

**Runtime API:**
```js
import * as allure from "allure-js-commons";
import test from "ava";

test("Test Authentication", async (t) => {
  await allure.epic("Web interface");
  await allure.feature("Essential features");
  await allure.story("Authentication");
  // ...
  t.pass();
});
```

**Metadata API:**
```js
import test from "ava";

test(
  "Test Authentication" +
    " @allure.label.epic:WebInterface" +
    " @allure.label.feature:EssentialFeatures" +
    " @allure.label.story:Authentication",
  (t) => {
    // ...
    t.pass();
  },
);
```

To specify a test's location in the [suite-based hierarchy](/docs/v2/navigation/#suite-based-hierarchy):

**Runtime API:**
```js
import * as allure from "allure-js-commons";
import test from "ava";

test("Test Authentication", async (t) => {
  await allure.parentSuite("Tests for web interface");
  await allure.suite("Tests for essential features");
  await allure.subSuite("Tests for authentication");
  // ...
  t.pass();
});
```

**Metadata API:**
```js
import test from "ava";

test(
  "Test Authentication" +
    " @allure.label.parentSuite:TestsForWebInterface" +
    " @allure.label.suite:TestsForEssentialFeatures" +
    " @allure.label.subSuite:TestsForAuthentication",
  (t) => {
    // ...
    t.pass();
  },
);
```

### Divide a test into steps

To [create steps and sub-steps](/docs/steps/), you can use the `step()` function, see the [reference](/docs/ava-reference/#test-steps).

```js
import * as allure from "allure-js-commons";
import { Status } from "allure-js-commons";
import test from "ava";

test("Test Authentication", async (t) => {
  await allure.step("Step 1", async () => {
    await allure.step("Sub-step 1", async (ctx) => {
      await ctx.parameter("foo", "1");
      // ...
    });
    await allure.step("Sub-step 2", async (ctx) => {
      await ctx.parameter("foo", "2");
      // ...
    });
  });
  await allure.logStep("Step 2", Status.SKIPPED);
  t.pass();
});
```

### Describe parametrized tests

To implement the [parametrized tests](/docs/v2/readability/#parametrized-tests) pattern in AVA, write the test inside a loop and use the variable parameters in both the title and the body. Each iteration is treated as a separate test run by Allure Report.

To display a parameter value in the test report, pass it to the [`parameter()`](/docs/ava-reference/#parametrized-tests) function.

```js
import * as allure from "allure-js-commons";
import test from "ava";

for (const login of ["johndoe", "johndoe@example.com"]) {
  test(`Test Authentication as ${login}`, async (t) => {
    await allure.parameter("login", login);
    await allure.parameter("time", new Date().toUTCString(), { excluded: true });
    // ...
    t.pass();
  });
}
```

### Set labels globally

Any [labels](/docs/ava-reference/#label), including custom ones, can be set via environment variables in your operating system. Here's an example:

**MacOS/Linux:**
```bash
export ALLURE_LABEL_epic=WebInterface
npx ava
```

**Windows:**
```powershell
$Env:ALLURE_LABEL_epic = "WebInterface"
npx ava
```

### Attach files

In Allure reports, you have the ability to [attach various types of files](/docs/attachments/), which can greatly enhance the comprehensibility of the report. Additionally, any messages logged with AVA's built-in `t.log()` are automatically added to the test result (or to the corresponding fixture, when logged in a hook) as a text attachment named "AVA logs".

For detailed instructions on how to implement attachments, refer to the [attachments section in the Allure AVA reference](/docs/ava-reference/#attachments).

```js
import * as allure from "allure-js-commons";
import { ContentType } from "allure-js-commons";
import test from "ava";

test("Test Authentication", async (t) => {
  // ...

  await allure.attachment("Text file", "This is the file content.", ContentType.TEXT);

  await allure.attachmentPath("Screenshot", "/path/to/image.png", {
    contentType: ContentType.PNG,
    fileExtension: "png",
  });

  t.pass();
});
```

### Select tests via a test plan file

If the `ALLURE_TESTPLAN_PATH` environment variable is defined and points to an existing file, AVA will only run tests listed in this file.

Tests can be matched in two ways:

- **By selector** — using the `path/to/file.test.js#test title` format. The path is relative to the project root (the closest directory with a `package.json`), and the title is the test name with any `@allure.*` metadata tags stripped out.
- **By Allure ID** — using the `@allure.id:⟨VALUE⟩` metadata tag in the test name.

Here's an example of running tests according to a file named `testplan.json`:

**MacOS/Linux:**
```bash
export ALLURE_TESTPLAN_PATH=testplan.json
npx ava
```

**Windows:**
```powershell
$Env:ALLURE_TESTPLAN_PATH = "testplan.json"
npx ava
```

### Environment information

For the main page of the report, you can collect various information about the environment in which the tests were executed. To do so, edit the [`environmentInfo`](/docs/ava-configuration/#environmentinfo) object in the configuration.

For example, it is a good idea to record the OS version and the Node.js version. This may help the future reader investigate bugs that are reproducible only in some environments.

```js
// ava.config.mjs
import { installAllure } from "allure-ava";
import * as os from "node:os";

await installAllure({
  environmentInfo: {
    os_platform: os.platform(),
    os_release: os.release(),
    os_version: os.version(),
    node_version: process.version,
  },
});

export default {};
```
