### Install allure-vitest Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-vitest/README.md Install allure-vitest as a development dependency using npm. ```shell npm install -D allure-vitest ``` -------------------------------- ### Install Allure Fetch Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-fetch/README.md Install the necessary packages for Allure Fetch and Allure JS Commons using npm. ```bash npm install -D allure-fetch allure-js-commons ``` -------------------------------- ### Install Allure Bun Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-bun/README.md Install allure-bun and allure-js-commons using npm. Ensure both packages are on the same version. ```shell npm install -D allure-bun allure-js-commons ``` -------------------------------- ### Setup Allure Cypress with Cypress Cucumber Preprocessor Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md Integrates Allure Cypress with the cypress-cucumber-preprocessor using cypress-on-fix. Ensure `cypress-on-fix` is installed and imported. ```javascript import { defineConfig } from "cypress"; import { allureCypress } from "allure-cypress/reporter"; import createBundler from "@bahmutov/cypress-esbuild-preprocessor"; import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor"; import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild"; import cypressOnFix from "cypress-on-fix"; export default defineConfig({ e2e: { setupNodeEvents = async (on, config) => { on = cypressOnFix(on); await addCucumberPreprocessorPlugin(on, config); on("file:preprocessor", createBundler({ plugins: [createEsbuildPlugin(config)], })); allureCypress(on, config); return config; }, // ... }, }); ``` -------------------------------- ### Install allure-codeceptjs Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-codeceptjs/README.md Install the allure-codeceptjs package as a development dependency using npm. ```bash npm install -D allure-codeceptjs ``` -------------------------------- ### Install Allure Chai and Allure Mocha Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-chai/README.md Install allure-chai and allure-mocha together with chai for integration. This command is used for development dependencies. ```shell npm install -D allure-chai allure-mocha chai ``` -------------------------------- ### Install Newman Allure Reporter Source: https://github.com/allure-framework/allure-js/blob/main/packages/newman-reporter-allure/README.md Install the newman-reporter-allure package using npm. This command installs it as a development dependency. ```shell npm install -D newman-reporter-allure ``` -------------------------------- ### Install allure-cypress Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md Install the allure-cypress package as a dev dependency using npm. ```shell npm install -D allure-cypress ``` -------------------------------- ### Install allure-js-commons Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-js-commons/README.md Install the package using npm. This is typically done as a development dependency. ```bash npm install -D allure-js-commons ``` -------------------------------- ### Install Allure Axios Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-axios/README.md Install the necessary packages for Allure Axios integration. This includes the core library, common utilities, and Axios itself. ```bash npm install -D allure-axios allure-js-commons axios ``` -------------------------------- ### Generate and Open Allure Report (npm package) Source: https://context7.com/allure-framework/allure-js/llms.txt Install the Allure npm package and use its commands to generate and open the HTML report. ```bash # Allure Report 3 (npm package) npm install -D allure npx allure generate ./allure-results npx allure open ./allure-report ``` -------------------------------- ### Install allure-jest Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-jest/README.md Install allure-jest as a development dependency using npm. ```shell npm install -D allure-jest ``` -------------------------------- ### Install allure-jasmine Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-jasmine/README.md Install the allure-jasmine package as a dev dependency using npm. ```bash npm install -D allure-jasmine ``` -------------------------------- ### Install allure-mocha Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-mocha/README.md Install allure-mocha as a dev dependency using npm or yarn. ```shell npm install -D allure-mocha ``` -------------------------------- ### Install for Yarn PnP users Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-vitest/README.md For Yarn PnP users, explicitly install @vitest/runner and allure-js-commons. Ensure versions are consistent. ```shell yarn add --dev @vitest/runner allure-js-commons ``` -------------------------------- ### Cypress test with Allure steps and attachments Source: https://context7.com/allure-framework/allure-js/llms.txt Example Cypress test case demonstrating Allure steps, parameters, and attachments, including task usage for user creation. ```javascript // signin.cy.js import * as allure from "allure-js-commons"; describe("signing in with a password", () => { it("should sign in with a valid password", () => { allure.description("Verifies happy-path sign-in."); allure.epic("Signing in"); allure.feature("Sign in with a password"); allure.tags("signin", "ui", "positive"); allure.owner("qa-team"); allure.parameter("browser", Cypress.browser.family); allure .step("Prepare the user", () => cy.task("createUser")) .then((user) => { allure.step("Fill sign-in form", (ctx) => { ctx.parameter("login", user.login); ctx.parameter("password", user.password, "masked"); cy.get("#login").type(user.login); cy.get("#password").type(user.password); }); allure.step("Submit", () => { cy.get("button[type=submit]").click(); allure.attachment("cookies", JSON.stringify(cy.getCookies()), { contentType: "application/json", }); }); }); }); }); ``` -------------------------------- ### Minimal Custom Reporter Example (TypeScript) Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-js-commons/README.md Demonstrates the core logic for creating a custom test reporter. It shows how to set up `ReporterRuntime`, manage test lifecycle events, and forward runtime messages. ```typescript import { Stage, Status } from "allure-js-commons"; import type { RuntimeMessage } from "allure-js-commons/sdk"; import { ReporterRuntime, createDefaultWriter } from "allure-js-commons/sdk/reporter"; import { MessageTestRuntime, setGlobalTestRuntime } from "allure-js-commons/sdk/runtime"; class MyFrameworkRuntime extends MessageTestRuntime { constructor(private readonly forward: (message: RuntimeMessage) => void) { super(); } async sendMessage(message: RuntimeMessage) { this.forward(message); } } const reporterRuntime = new ReporterRuntime({ writer: createDefaultWriter({ resultsDir: "./allure-results" }), }); let currentTestUuid: string | undefined; setGlobalTestRuntime( new MyFrameworkRuntime((message) => { if (currentTestUuid) { reporterRuntime.applyRuntimeMessages(currentTestUuid, [message]); } else { reporterRuntime.applyGlobalRuntimeMessages([message]); } }), ); export const onTestStart = (name: string, fullName: string) => { currentTestUuid = reporterRuntime.startTest({ name, fullName, stage: Stage.RUNNING, }); }; export const onTestPass = () => { if (!currentTestUuid) return; reporterRuntime.updateTest(currentTestUuid, (result) => { result.status = Status.PASSED; result.stage = Stage.FINISHED; }); reporterRuntime.stopTest(currentTestUuid); reporterRuntime.writeTest(currentTestUuid); currentTestUuid = undefined; }; export const onTestFail = (error: Error) => { if (!currentTestUuid) return; reporterRuntime.updateTest(currentTestUuid, (result) => { result.status = Status.BROKEN; result.stage = Stage.FINISHED; result.statusDetails = { message: error.message, trace: error.stack, }; }); reporterRuntime.stopTest(currentTestUuid); reporterRuntime.writeTest(currentTestUuid); currentTestUuid = undefined; }; ``` -------------------------------- ### Install allure-cucumberjs Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cucumberjs/README.md Install the allure-cucumberjs package as a dev dependency using npm. ```shell npm install -D allure-cucumberjs ``` -------------------------------- ### Install Allure Playwright Integration Source: https://github.com/allure-framework/allure-js/blob/main/README.md Install the Allure Playwright integration package as a dev dependency. This allows Allure to capture test results when using Playwright. ```bash npm install -D allure-playwright ``` -------------------------------- ### Yarn PnP Installation Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-jest/README.md For Yarn PnP users, explicitly install jest-environment-node and allure-js-commons. Ensure matching versions for all Jest packages. ```shell yarn add --dev jest-environment-node allure-js-commons ``` -------------------------------- ### Basic Allure Bun Test Example Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-bun/README.md Example of a Bun test using allure-js-commons for labels and steps. Keep your test imports unchanged and use the preload hook. ```typescript import { describe, expect, it } from "bun:test"; import { label, step } from "allure-js-commons"; describe("signing in", () => { it("works", async () => { await label("severity", "critical"); await step("submit form", async () => {}); expect(1 + 1).toBe(2); }); }); ``` -------------------------------- ### Allure Sync API Usage Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-mocha/README.md Example demonstrating the usage of the synchronous facade for the Allure API, intended for use with synchronous helpers or matcher integrations. ```APIDOC ### Sync API When your test code uses synchronous helpers or matcher integrations, you can use the sync facade from `allure-js-commons/sync`. ```js import * as allure from "allure-js-commons/sync"; allure.step("check result", () => { allure.parameter("mode", "sync"); }); ``` The sync facade is strict-sync only: `allure.step()` must finish synchronously and must not return a `Promise`. ``` -------------------------------- ### Allure Cucumber.js Step Definitions Example Source: https://context7.com/allure-framework/allure-js/llms.txt Example step definitions for Cucumber.js using Allure decorators for adding test metadata, descriptions, issues, owners, parameters, and attachments. ```javascript // steps/auth.steps.js import { Given, When, Then } from "@cucumber/cucumber"; import * as allure from "allure-js-commons"; Given("an active user", async function () { await allure.description("Verifies happy-path sign-in."); await allure.epic("Signing in"); await allure.tags("signin", "ui", "positive"); await allure.issue("https://tracker.example.com/ISSUE-1", "ISSUE-1"); await allure.owner("qa-team"); await allure.parameter("browser", "chrome"); this.user = { login: "jane@example.com", password: "s3cr3t" }; }); When("they sign in with a valid password", async function () { await allure.step("Navigate to sign-in page", async () => { // navigate... }); await allure.step("Fill the sign-in form", async (ctx) => { await ctx.parameter("login", this.user.login); await ctx.parameter("password", this.user.password, "masked"); }); await allure.step("Submit the form", async () => { const responseData = { token: "abc123" }; await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json", }); }); }); Then("they should be signed in", async function () { // assertions here }); ``` -------------------------------- ### Allure Jest Integration Example Source: https://context7.com/allure-framework/allure-js/llms.txt Example of using Allure-JS annotations within a Jest test file to add metadata, steps, and attachments. ```javascript // my.test.js import * as allure from "allure-js-commons"; describe("signing in with a password", () => { it("should sign in with a valid password", async () => { await allure.description("Verifies happy-path sign-in."); await allure.epic("Signing in"); await allure.feature("Sign in with a password"); await allure.story("As an active user, I want to sign in with a valid password"); await allure.tags("signin", "ui", "positive"); await allure.issue("https://tracker.example.com/ISSUE-4", "ISSUE-4"); await allure.owner("qa-team"); await allure.parameter("browser", "chrome"); const user = await allure.step("Prepare the user", async () => { return { login: "jane@example.com", password: "secret" }; }); await allure.step("Make a sign-in attempt", async () => { await allure.step("Fill the sign-in form", async (ctx) => { await ctx.parameter("login", user.login); await ctx.parameter("password", user.password, "masked"); }); await allure.step("Submit the form", async () => { const responseData = { status: "ok", token: "abc123" }; await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json", }); }); }); await allure.step("Assert the signed-in state", async () => { // assertions here }); }); }); ``` -------------------------------- ### Vitest test with Allure steps and attachments Source: https://context7.com/allure-framework/allure-js/llms.txt Example Vitest test case demonstrating the use of Allure steps, parameters, and attachments. ```typescript // cart.test.ts import { describe, it } from "vitest"; import * as allure from "allure-js-commons"; describe("checkout", () => { it("should complete purchase", async () => { await allure.epic("Shopping"); await allure.feature("Checkout"); await allure.tags("checkout", "payments"); await allure.parameter("currency", "USD"); await allure.step("Add item to cart", async () => { await allure.attachment("cart state", JSON.stringify({ items: ["SKU-1"] }), { contentType: "application/json", }); }); await allure.step("Complete checkout", async () => { // assertions here }); }); }); ``` -------------------------------- ### Allure API - Basic Usage Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md Example of using the Allure API to add descriptions, epics, features, stories, tags, issues, owners, parameters, and steps to test reports. ```APIDOC ## Allure API - Basic Usage ### Description Example of using the Allure API to add descriptions, epics, features, stories, tags, issues, owners, parameters, and steps to test reports. ### Method ```javascript import * as allure from "allure-js-commons"; describe("signing in with a password", () => { it("should sign in with a valid password", () => { allure.description("The test checks if an active user with a valid password can sign in to the app."); allure.epic("Signing in"); allure.feature("Sign in with a password"); allure.story("As an active user, I want to successfully sign in using a valid password"); allure.tags("signin", "ui", "positive"); allure.issue("https://github.com/allure-framework/allure-js/issues/900", "ISSUE-900"); allure.owner("eroshenkoam"); allure.parameter("browser", Cypress.browser.family); allure .step("Prepare the user", () => { return createAnActiveUserInDb(); }) .then((user) => { allure.step("Make a sign-in attempt", () => { allure.step("Navigate to the sign-in page", () => { // ... }); allure.step("Fill the sign-in form", (stepContext) => { stepContext.parameter("login", user.login); stepContext.parameter("password", user.password, "masked"); // ... }); allure.step("Submit the form", () => { // ... allure.attachment("cookies", JSON.stringify(cy.getCookies()), { contentType: "application/json" }); }); }); allure.step("Assert the signed-in state", () => { // ... }); }); }); }); ``` ``` -------------------------------- ### Setup Allure Jasmine Reporter Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-jasmine/README.md Add the AllureJasmineReporter to your Jasmine environment in a helper file. ```typescript import AllureJasmineReporter from "allure-jasmine"; jasmine.getEnv().addReporter(new AllureJasmineReporter()); ``` -------------------------------- ### Allure Mocha Test Example Source: https://context7.com/allure-framework/allure-js/llms.txt Example test case using Mocha with Allure decorators for adding test metadata like epics, features, tags, owners, parameters, and steps. ```javascript // auth.test.js import { describe, it } from "mocha"; import * as allure from "allure-js-commons"; describe("signing in with a password", () => { it("should sign in with a valid password", async () => { await allure.epic("Signing in"); await allure.feature("Sign in with a password"); await allure.tags("signin", "regression"); await allure.owner("qa-team"); await allure.parameter("browser", "chrome"); const user = await allure.step("Prepare the user", async () => ({ login: "jane@example.com", password: "s3cr3t", })); await allure.step("Sign in", async () => { await allure.step("Fill form", async (ctx) => { await ctx.parameter("login", user.login); await ctx.parameter("password", user.password, "masked"); }); await allure.step("Submit", async () => { const responseData = { status: "ok" }; await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json", }); }); }); }); }); ``` -------------------------------- ### Allure Runtime API Usage Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-mocha/README.md Example demonstrating how to use the Allure runtime API within Mocha tests to add descriptions, steps, attachments, and other metadata to the Allure report. ```APIDOC ## Allure Runtime API ### Description The Allure runtime API allows you to enrich your test reports with detailed information such as descriptions, steps, attachments, metadata, and more. This example showcases how to import and use various Allure API functions within a Mocha test. ### Example Usage ```js import { describe, it } from "mocha"; import * as allure from "allure-js-commons"; describe("signing in with a password", () => { it("should sign in with a valid password", async () => { await allure.description("The test checks if an active user with a valid password can sign in to the app."); await allure.epic("Signing in"); await allure.feature("Sign in with a password"); await allure.story("As an active user, I want to successfully sign in using a valid password"); await allure.tags("signin", "ui", "positive"); await allure.issue("https://github.com/allure-framework/allure-js/issues/1", "ISSUE-1"); await allure.owner("eroshenkoam"); await allure.parameter("browser", "chrome"); const user = await allure.step("Prepare the user", async () => { return await createAnActiveUserInDb(); }); await allure.step("Make a sign-in attempt", async () => { await allure.step("Navigate to the sign in page", async () => { // ... }); await allure.step("Fill the sign-in form", async (stepContext) => { await stepContext.parameter("login", user.login); await stepContext.parameter("password", user.password, "masked"); // ... }); await allure.step("Submit the form", async () => { // ... // const responseData = ... await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" }); }); }); await allure.step("Assert the signed-in state", async () => { // ... }); }); }); ``` More details about the API are available at [https://allurereport.org/docs/mocha-reference/](https://allurereport.org/docs/mocha-reference/). ``` -------------------------------- ### Allure Integration with CodeceptJS Source: https://context7.com/allure-framework/allure-js/llms.txt Enable Allure reporting in CodeceptJS by installing and configuring the `allure-codeceptjs` plugin. ```bash npm install -D allure-codeceptjs ``` ```javascript // codecept.config.js module.exports.config = { plugins: { allure: { enabled: true, require: "allure-codeceptjs", }, }, }; ``` ```javascript // auth_test.js import * as allure from "allure-js-commons"; Feature("Signing in with a password"); Scenario("Signing in with a correct password", async () => { await allure.epic("Signing in"); await allure.tags("signin", "regression"); await allure.owner("qa-team"); await allure.parameter("browser", "chrome"); const user = await allure.step("Prepare the user", async () => ({ login: "jane@example.com", password: "s3cr3t", })); await allure.step("Sign in", async () => { await allure.step("Fill form", async (ctx) => { await ctx.parameter("login", user.login); await ctx.parameter("password", user.password, "masked"); }); await allure.step("Submit", async () => { const responseData = { token: "abc123" }; await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json", }); }); }); }); ``` -------------------------------- ### Allure API Usage with Mocha Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-mocha/README.md Example demonstrating how to use the Allure API within Mocha tests to add descriptions, epics, features, stories, tags, issues, owners, parameters, and steps. ```javascript import { describe, it } from "mocha"; import * as allure from "allure-js-commons"; describe("signing in with a password", () => { it("should sign in with a valid password", async () => { await allure.description("The test checks if an active user with a valid password can sign in to the app."); await allure.epic("Signing in"); await allure.feature("Sign in with a password"); await allure.story("As an active user, I want to successfully sign in using a valid password"); await allure.tags("signin", "ui", "positive"); await allure.issue("https://github.com/allure-framework/allure-js/issues/1", "ISSUE-1"); await allure.owner("eroshenkoam"); await allure.parameter("browser", "chrome"); const user = await allure.step("Prepare the user", async () => { return await createAnActiveUserInDb(); }); await allure.step("Make a sign-in attempt", async () => { await allure.step("Navigate to the sign in page", async () => { // ... }); await allure.step("Fill the sign-in form", async (stepContext) => { await stepContext.parameter("login", user.login); await stepContext.parameter("password", user.password, "masked"); // ... }); await allure.step("Submit the form", async () => { // ... // const responseData = ... await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" }); }); }); await allure.step("Assert the signed-in state", async () => { // ... }); }); }); ``` -------------------------------- ### Custom ReporterRuntime Integration with Allure-JS Commons Source: https://context7.com/allure-framework/allure-js/llms.txt Build a custom integration to emit standard allure-results. This example shows how to create a custom runtime that forwards messages to the reporter and maps framework lifecycle events. ```typescript import { Stage, Status } from "allure-js-commons"; import type { RuntimeMessage } from "allure-js-commons/sdk"; import { ReporterRuntime, createDefaultWriter } from "allure-js-commons/sdk/reporter"; import { MessageTestRuntime, setGlobalTestRuntime } from "allure-js-commons/sdk/runtime"; // 1. Create a runtime that forwards messages to the reporter class MyRuntime extends MessageTestRuntime { constructor(private readonly forward: (msg: RuntimeMessage) => void) { super(); } async sendMessage(msg: RuntimeMessage) { this.forward(msg); } } // 2. Create the reporter runtime with a file-system writer const reporter = new ReporterRuntime({ writer: createDefaultWriter({ resultsDir: "./allure-results" }), }); let currentUuid: string | undefined; // 3. Register the global runtime so allure-js-commons facade calls work setGlobalTestRuntime( new MyRuntime((msg) => { if (currentUuid) { reporter.applyRuntimeMessages(currentUuid, [msg]); } else { reporter.applyGlobalRuntimeMessages([msg]); } }), ); // 4. Map your framework lifecycle to ReporterRuntime methods export const onTestStart = (name: string, fullName: string) => { currentUuid = reporter.startTest({ name, fullName, stage: Stage.RUNNING }); }; export const onTestPass = () => { if (!currentUuid) return; reporter.updateTest(currentUuid, (r) => { r.status = Status.PASSED; r.stage = Stage.FINISHED; }); reporter.stopTest(currentUuid); reporter.writeTest(currentUuid); currentUuid = undefined; }; export const onTestFail = (error: Error) => { if (!currentUuid) return; reporter.updateTest(currentUuid, (r) => { r.status = Status.BROKEN; r.stage = Stage.FINISHED; r.statusDetails = { message: error.message, trace: error.stack }; }); reporter.stopTest(currentUuid); reporter.writeTest(currentUuid); currentUuid = undefined; }; ``` -------------------------------- ### Initialize allureCypress in cypress.config.js Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md Call `allureCypress` within the `setupNodeEvents` function in your `cypress.config.js` to initialize the plugin. ```APIDOC ## Initialize allureCypress in cypress.config.js ### Description Call `allureCypress` within the `setupNodeEvents` function in your `cypress.config.js` to initialize the plugin. ### Method ```javascript import { defineConfig } from "cypress"; import { allureCypress } from "allure-cypress/reporter"; export default defineConfig({ e2e: { setupNodeEvents: (on, config) => { allureCypress(on, config); return config; }, // ... }, }); ``` ``` -------------------------------- ### Configure Bun Preload Hook Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-bun/README.md Configure Bun to preload allure-bun/setup by adding it to the preload array in bunfig.toml. ```toml [test] preload = ["allure-bun/setup"] ``` -------------------------------- ### Configure allure-cypress in cypress.config.js Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md Initialize the allure-cypress plugin within the setupNodeEvents function in your cypress.config.js file. ```javascript import { defineConfig } from "cypress"; import { allureCypress } from "allure-cypress/reporter"; export default defineConfig({ e2e: { setupNodeEvents: (on, config) => { allureCypress(on, config); return config; }, // ... }, }); ``` -------------------------------- ### Generate and Open Allure Report (CLI) Source: https://context7.com/allure-framework/allure-js/llms.txt Use the Allure CLI to generate an HTML report from `allure-results` and then open it. ```bash # Allure Report 2 (allure CLI) allure generate ./allure-results -o ./allure-report allure open ./allure-report ``` -------------------------------- ### Enable Allure Reporter via CLI Source: https://github.com/allure-framework/allure-js/blob/main/packages/newman-reporter-allure/README.md Run Newman collections with the allure reporter enabled. The results will be saved to the ./allure-results directory by default. ```shell $ newman run "" -e "" -r allure ``` -------------------------------- ### Allure Jasmine Test Example Source: https://context7.com/allure-framework/allure-js/llms.txt Example test case using Jasmine with Allure decorators for adding test metadata and steps. ```typescript // auth.spec.ts import * as allure from "allure-js-commons"; describe("signing in with a password", () => { it("should sign in with a valid password", async () => { await allure.epic("Signing in"); await allure.feature("Sign in with a password"); await allure.tags("signin", "regression"); await allure.owner("qa-team"); await allure.parameter("browser", "chrome"); const user = await allure.step("Prepare the user", async () => ({ login: "jane@example.com", password: "s3cr3t", })); await allure.step("Fill sign-in form", async (ctx) => { await ctx.parameter("login", user.login); await ctx.parameter("password", user.password, "masked"); }); await allure.step("Submit the form", async () => { const response = { status: "ok" }; await allure.attachment("response", JSON.stringify(response), { contentType: "application/json", }); }); }); }); ``` -------------------------------- ### Sync API Usage Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cucumberjs/README.md Demonstrates how to use the synchronous facade of the Allure API for synchronous step definitions. ```APIDOC ## Sync API Facade ### Description Use the synchronous facade from `allure-js-commons/sync` when your step definitions involve synchronous helpers or matcher integrations. ### Example ```js import * as allure from "allure-js-commons/sync"; allure.step("check result", () => { allure.parameter("mode", "sync"); }); ``` **Note:** The sync facade is strict-sync only, meaning `allure.step()` must finish synchronously and must not return a `Promise`. ``` -------------------------------- ### Playwright Test with Allure metadata and steps Source: https://context7.com/allure-framework/allure-js/llms.txt Example Playwright Test spec demonstrating Allure metadata, parameters, steps, and attachments. ```typescript // auth.spec.ts import { test } from "@playwright/test"; import * as allure from "allure-js-commons"; test("sign in with a valid password", async ({ page }) => { await allure.description("Verifies that a valid user can sign in."); await allure.epic("Authentication"); await allure.feature("Sign in with a password"); await allure.tags("signin", "e2e"); await allure.owner("qa-team"); await allure.parameter("browser", "chromium"); const user = await allure.step("Prepare user", async () => ({ login: "jane@example.com", password: "s3cr3t", })); await allure.step("Navigate to sign-in page", async () => { await page.goto("https://example.com/signin"); }); await allure.step("Fill sign-in form", async (ctx) => { await ctx.parameter("login", user.login); await ctx.parameter("password", user.password, "masked"); await page.fill("#login", user.login); await page.fill("#password", user.password); }); await allure.step("Submit form", async () => { await page.click("button[type=submit]"); const screenshot = await page.screenshot(); await allure.attachment("screenshot after submit", screenshot, { contentType: "image/png" }); }); }); ``` -------------------------------- ### Import allure-cypress in cypress/support/e2e.js Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md Import the `allure-cypress` package in your `cypress/support/e2e.js` file to enable its functionality. ```APIDOC ## Import allure-cypress in cypress/support/e2e.js ### Description Import the `allure-cypress` package in your `cypress/support/e2e.js` file to enable its functionality. ### Method ```javascript import "allure-cypress"; ``` ``` -------------------------------- ### Run Mocha with allure-mocha reporter via CLI Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-mocha/README.md Execute Mocha tests and generate Allure results using the allure-mocha reporter directly from the command line. ```bash npx mocha -R allure-mocha ``` -------------------------------- ### Allure API Usage Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cucumberjs/README.md Examples of using the Allure API within Cucumber.js step definitions to add rich information to test reports. ```APIDOC ## Allure API in Step Definitions ### Description Utilize the `allure-js-commons` library to enhance test reports with descriptions, epics, tags, issues, owners, parameters, steps, and attachments. ### Example ```js import { Given, When } from "@cucumber/cucumber"; import * as allure from "allure-js-commons"; Given("an active user", async function () { await allure.description("The test checks if an active user with a valid password can sign in to the app."); await allure.epic("Signing in"); await allure.tags("signin", "ui", "positive"); await allure.issue("https://github.com/allure-framework/allure-js/issues/1", "ISSUE-1"); await allure.owner("eroshenkoam"); await allure.parameter("browser", "chrome"); this.user = await createAnActiveUserInDb(); }); When("they sign in with a valid password", async function () { await allure.step("Navigate to the sign in page", async () => { // ... }); await allure.step("Fill the sign-in form", async (stepContext) => { await stepContext.parameter("login", this.user.login); await stepContext.parameter("password", this.user.password, "masked"); // ... }); await allure.step("Submit the form", async () => { // ... // const responseData = ... await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" }); }); }); ``` More details are available at [https://allurereport.org/docs/cucumberjs-reference/](https://allurereport.org/docs/cucumberjs-reference/). ``` -------------------------------- ### Configure Allure Bun Reporter Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-bun/README.md Configure Allure reporter settings via globalThis.allureBunConfig or the ALLURE_BUN_CONFIG environment variable. Use a custom preload for advanced configurations like listener or link-template functions. ```typescript import type { ReporterConfig } from "allure-js-commons/sdk/reporter"; globalThis.allureBunConfig = { resultsDir: "allure-results", environmentInfo: { bun: Bun.version, }, globalLabels: { layer: "api", }, links: { issue: { urlTemplate: "https://issues.example/%s", }, }, } satisfies ReporterConfig; await import("allure-bun/setup"); ``` -------------------------------- ### Setting Allure Labels via Environment Variables (Bash) Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-js-commons/README.md Illustrates how to apply labels to all tests by setting environment variables before running tests. This is useful for categorizing tests by epic, feature, or other custom criteria. ```bash ALLURE_LABEL_epic="Story 1" npm test ``` -------------------------------- ### Import allure-cypress in support file Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md Import the allure-cypress package in your cypress/support/e2e.js file to enable its functionality. ```javascript import "allure-cypress"; ``` -------------------------------- ### Configure Cypress for Allure reporting (Node.js) Source: https://context7.com/allure-framework/allure-js/llms.txt Configure Cypress to use the Allure reporter by integrating it into the setupNodeEvents function in cypress.config.js. ```javascript // cypress.config.js import { defineConfig } from "cypress"; import { allureCypress } from "allure-cypress/reporter"; export default defineConfig({ e2e: { setupNodeEvents(on, config) { allureCypress(on, config); // pass config as second arg for test-plan support return config; }, }, }); ``` -------------------------------- ### Configure allure-mocha reporter in .mocharc.json Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-mocha/README.md Enable the allure-mocha reporter by specifying it in your Mocha configuration file. ```json { "reporter": "allure-mocha" } ``` -------------------------------- ### Setting up Allure Jasmine Reporter Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-jasmine/README.md Configure your Jasmine environment to use the Allure Jasmine reporter by adding it to the Jasmine environment. ```APIDOC ## Setting up Allure Jasmine Reporter ### Description Configure your Jasmine environment to use the Allure Jasmine reporter by adding it to the Jasmine environment. ### Code ```ts import AllureJasmineReporter from "allure-jasmine"; jasmine.getEnv().addReporter(new AllureJasmineReporter()); ``` ### Notes - Ensure the helper file is matched against the `helpers` regular expression in your Jasmine configuration. - Customize reporter behavior using [configuration options](https://allurereport.org/docs/jasmine-configuration/). ``` -------------------------------- ### Generate and Open Allure Report (v2) Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-bun/README.md Commands to generate and open the Allure report using Allure Report version 2. ```bash allure generate ./allure-results -o ./allure-report allure open ./allure-report ``` -------------------------------- ### Viewing the Report Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cucumberjs/README.md Instructions on how to generate and open the Allure report after test execution. ```APIDOC ## View Allure Report ### Description Commands to generate and serve the Allure report from the `allure-results` directory. ### Allure Report 2 ```bash allure generate ./allure-results -o ./allure-report allure open ./allure-report ``` ### Allure Report 3 ```bash npx allure generate ./allure-results npx allure open ./allure-report ``` ``` -------------------------------- ### Run Playwright Tests with Allure Reporter via CLI Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-playwright/README.md Execute Playwright tests and specify the allure-playwright reporter directly from the command line. ```bash npx playwright test --reporter=line,allure-playwright ``` -------------------------------- ### Generate and Open Allure Report (v3) Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-bun/README.md Commands to generate and open the Allure report using Allure Report version 3. ```bash npx allure generate ./allure-results npx allure open ./allure-report ``` -------------------------------- ### Create Custom Jest Environment with Allure Source: https://context7.com/allure-framework/allure-js/llms.txt Use the createJestEnvironment factory helper to integrate Allure with a custom Jest environment. ```javascript // Using a custom Jest environment import CustomEnv from "jest-environment-custom"; import { createJestEnvironment } from "allure-jest/factory"; export default createJestEnvironment(CustomEnv); ``` -------------------------------- ### Allure API - Synchronous Usage Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-codeceptjs/README.md Shows how to use the synchronous facade of the Allure API for scenarios where synchronous helpers or matcher integrations are used. ```APIDOC ## Allure API (Sync) For synchronous helpers or matcher integrations, use the sync facade from `allure-js-commons/sync`. ### Example ```javascript import * as allure from "allure-js-commons/sync"; allure.step("check result", () => { allure.parameter("mode", "sync"); }); ``` **Note:** The sync facade is strict-sync only. `allure.step()` must finish synchronously and must not return a `Promise`. ``` -------------------------------- ### Run Mocha tests with Allure Reporter via CLI Source: https://context7.com/allure-framework/allure-js/llms.txt Alternatively, specify the allure-mocha reporter directly when running Mocha tests from the command line. ```bash # Or via CLI npx mocha -R allure-mocha ``` -------------------------------- ### Create A Wrapped Fetch Instance Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-fetch/README.md Wrap the global fetch function with `withAllure` to automatically record HTTP exchanges. This is useful for standard fetch usage within your tests. ```typescript import { withAllure } from "allure-fetch"; const fetchWithAllure = withAllure(fetch); const response = await fetchWithAllure("https://api.example.com/orders", { method: "POST", headers: { "authorization": `Bearer ${token}`, "content-type": "application/json", }, body: JSON.stringify({ sku: "ABC-123" }), }); ``` -------------------------------- ### Configure Cucumber.js with Allure Formatter Source: https://context7.com/allure-framework/allure-js/llms.txt Configure Cucumber.js to use the 'allure-cucumberjs/reporter' formatter via a configuration file. ```json // cucumber.json { "default": { "format": ["allure-cucumberjs/reporter"] } } ``` -------------------------------- ### Configure Playwright Test reporter via CLI Source: https://context7.com/allure-framework/allure-js/llms.txt Alternatively, configure the Allure reporter for Playwright Test using the command-line interface. ```bash # Or pass via CLI npx playwright test --reporter=line,allure-playwright ``` -------------------------------- ### Correct Allure Cypress Configuration Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md Pass the Cypress config as the second argument to `allureCypress` for the test plan feature to work correctly. ```javascript allureCypress(on, config); ``` ```javascript allureCypress(on, config, { resultsDir: "output", }); ``` -------------------------------- ### Allure Sync API Usage Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cucumberjs/README.md Utilize the synchronous facade from allure-js-commons/sync when your step definitions involve synchronous helpers or matcher integrations. Ensure `allure.step()` finishes synchronously. ```javascript import * as allure from "allure-js-commons/sync"; allure.step("check result", () => { allure.parameter("mode", "sync"); }); ``` -------------------------------- ### Configure Cucumber.js Reporter via CLI Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cucumberjs/README.md Alternatively, specify the allure-cucumberjs/reporter formatter directly via the command line interface. ```shell npx cucumber-js --format allure-cucumberjs/reporter ``` -------------------------------- ### Enabling Allure Mocha Reporter Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-mocha/README.md Instructions on how to enable the allure-mocha reporter in your Mocha test suite, either through configuration files or the command line. ```APIDOC ## Enabling Allure Mocha Reporter ### Description Enable the `allure-mocha` reporter to generate Allure results from your Mocha test runs. This can be done via a configuration file like `.mocharc.json` or directly through the command line interface. ### Configuration File (`.mocharc.json`) ```json { "reporter": "allure-mocha" } ``` ### Command Line Interface (CLI) ```bash npx mocha -R allure-mocha ``` After enabling the reporter, test results will be generated in the `./allure-results` directory. Further customization of the reporter's behavior can be achieved using [configuration options](https://allurereport.org/docs/mocha-configuration/). ``` -------------------------------- ### Async Facade for Allure Reporting Source: https://context7.com/allure-framework/allure-js/llms.txt Use the async facade to add labels, metadata, nested steps, and attachments to test results. Ensure all calls are awaited. Attachments can be created from strings or file paths. ```ts import * as allure from "allure-js-commons"; // Labels and metadata await allure.epic("Authentication"); await allure.feature("Password sign-in"); await allure.story("Active user signs in with valid password"); await allure.owner("qa-team"); await allure.tags("signin", "regression", "smoke"); await allure.severity("critical"); await allure.issue("https://tracker.example.com/AUTH-42", "AUTH-42"); await allure.tms("https://tms.example.com/TC-7", "TC-7"); await allure.parameter("browser", "chromium"); await allure.description("Verifies the happy-path sign-in flow."); // Nested steps with return values const user = await allure.step("Prepare test user", async () => { return { login: "jane@example.com", password: "s3cr3t" }; }); await allure.step("Sign in", async () => { await allure.step("Fill form", async (ctx) => { await ctx.parameter("login", user.login); await ctx.parameter("password", user.password, "masked"); // hidden in report }); await allure.step("Submit", async () => { const responseData = { token: "abc123", expiresIn: 3600 }; await allure.attachment("response body", JSON.stringify(responseData, null, 2), { contentType: "application/json", }); }); }); // Attach a file already on disk await allure.attachmentPath("screenshot.png", "screenshot.png", { contentType: "image/png", }); ``` -------------------------------- ### Run Newman Collection with Allure Reporter Source: https://context7.com/allure-framework/allure-js/llms.txt Execute a Postman collection using Newman and the Allure reporter. You can combine it with other reporters or specify a custom export directory. ```bash # Run a collection with the allure reporter newman run "My Collection.json" -e "staging.env.json" -r allure # Combine with the built-in CLI reporter newman run "My Collection.json" -e "staging.env.json" -r cli,allure # Specify a custom results directory newman run "My Collection.json" -r allure --reporter-allure-export my-allure-results ``` -------------------------------- ### Configure Vitest for Browser Testing Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-vitest/README.md Enable browser testing in vitest.config.js and include the playwright provider for Allure integration. ```diff import { defineConfig } from "vitest/config"; import { playwright } from "@vitest/browser-playwright"; export default defineConfig({ test: { reporters: [ "default", "allure-vitest/reporter", ], }, browser: { provider: playwright(), enabled: true, headless: true, instances: [ { browser: "chromium" }, ], }, }); ``` -------------------------------- ### Configure Jasmine with Allure Reporter Source: https://context7.com/allure-framework/allure-js/llms.txt Register the AllureJasmineReporter in a Jasmine helper file to enable Allure reporting. ```typescript // helpers/setup.ts import AllureJasmineReporter from "allure-jasmine"; jasmine.getEnv().addReporter(new AllureJasmineReporter()); ``` -------------------------------- ### View the report with Allure Report 2 Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md Instructions for generating and opening the Allure report using Allure Report 2. ```APIDOC ## View the report with Allure Report 2 ### Description Instructions for generating and opening the Allure report using Allure Report 2. ### Commands ```bash allure generate ./allure-results -o ./allure-report allure open ./allure-report ``` ``` -------------------------------- ### Basic Usage in Tests (Async) Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-js-commons/README.md Demonstrates basic usage of the Allure API within asynchronous test code. Imports the main allure module and uses functions like epic, feature, owner, parameter, step, and attachment. ```typescript import * as allure from "allure-js-commons"; await allure.epic("Authentication"); await allure.feature("Password sign-in"); await allure.owner("qa-team"); await allure.parameter("browser", "chromium"); await allure.step("Submit valid credentials", async () => { await allure.attachment("request", JSON.stringify({ login: "jane" }), { contentType: "application/json", }); }); ``` -------------------------------- ### View the report with Allure Report 3 Source: https://github.com/allure-framework/allure-js/blob/main/packages/allure-cypress/README.md Instructions for generating and opening the Allure report using Allure Report 3. ```APIDOC ## View the report with Allure Report 3 ### Description Instructions for generating and opening the Allure report using Allure Report 3. ### Commands ```bash npx allure generate ./allure-results npx allure open ./allure-report ``` ```