Skip to main content

Using Allure

Autometa supports the Allure Reports Framework.

To enable reporting, add AllureSubscriber to the subscriber property in your autometa.config.ts or other file which calls defineConfig().

autometa.config.ts
import { defineConfig, AllureSubscriber } from "@autometa/cucumber-runner";
defineConfig({
// ....
subscribers: [AllureSubscriber]
// ...
});

One enabled, Allure will automatically generate suites, packages, tests, hooks and steps, which will be generated to .allure-reports/

Docusaurus logo

Defining Steps in tests

It's possible to define substeps within steps and hooks. To do so, add AllureStepper as a constructor argument on your App class:

@Fixture
@Persistent
export class App {
constructor(readonly allure: AllureStepper) {}
}

From here it can be accessed from a step or hook defintion function.

Given("a user wishes to log in", ({ world, allure: { step } }: App) => {
// synchronous allure step
step("configure credentials", () => {
world.credentials = {
username: process.env.USERNAME,
password: process.env.PASSWORD
};
});
});

When(
"the user logs in with their credentials",
async ({ page, world, allure: { step } }: App) => {
// asynchronous allure step
await step("Enter username", () => page.enterUsername(world.username));
await step("Enter password", () => page.enterUsername(world.password));
await step("Click login", page.clickLogin);
}
);
info

An Allure step can be asynchronous or synchronous. If it is asynchronous or returns a Promise, then the Allure step itself must be await'd.

Allure steps can also be used in some hooks.

import { dbSeeder, cleanup } from "../db";

Before("Setup Db", async ({ world, allure: { step } }: App) => {
await step(
"Add seed data to database",
async () => (world.seedData = await dbSeeder())
);
});

After("Teardown db", async ({ world, allure: { step } }: App) => {
await step("delete seeded data", () => cleanup(world.seedData));
});