hermione-allure
TypeScript icon, indicating that this package has built-in type declarations

2.15.1 • Public • Published

hermione-allure

Allure integration for hermione@^8.x.x and above

Allure Report logo


Installation

Use your favorite node package manager to install required packages:

npm add -D hermione-allure allure-js-commons

Setup

Add hermione-allure field to plugins in your .hermione.conf.js file:

module.exports = {
  plugins: {
+    "hermione-allure": {
+      resultsDir: "./allure-results",
+      links: [
+        {
+          type: "issue",
+          urlTemplate: "https://example.org/issue/%s",
+        },
+        {
+          type: "tms",
+          urlTemplate: "https://example.org/task/%s",
+        },
+      ],
+    }
  }
}

Using allure commands

The plugin provides custom browser commands which allow to add additional info inside your tests:

import { expect } from "chai";
import { allure } from "hermione-allure/runtime";

it("my test", async ({ browser, currentTest }) => {
  await browser.url("https://www.example.org/");
  await browser.$("#btn").click();

  const screenshot = await browser.takeScreenshot();

  await allure(currentTest).attachment(screenshot, "image/png");
  await allure(currentTest).epic("my_epic");
  await allure(currentTest).parameter("parameter_name", "parameter_value", {
    mode: "hidden",
    excluded: false,
  });

  expect(browser.url).not.eq("https://www.startpage.com/");
});

Don't forget to pass current test id as first argument to command!

Supported commands

Display name

Change your test case name on custom value on the fly using displayName method:

import { allure } from "hermione-allure/runtime";

it("my test", async ({ currentTest }) => {
  await allure(currentTest).displayName("my test custom name");
});

Description

Provide description in markdown or html syntax:

import { allure } from "hermione-allure/runtime";

it("my test", async ({ currentTest }) => {
  await allure(currentTest).description("my **markdown description**");
  await allure(currentTest).descriptionHtml("<p>my <b>html description</b></p>");
});

Labels

Markup you tests with labels using low-level label method:

import { allure } from "hermione-allure/runtime";

it("my test", async ({ browser, currentTest }) => {
  await allure(currentTest).label("label_name", "label_value");
});

Or using aliases: id, epic, feature, story, suite, parentSuite, subSuite, owner, severity, tag:

import { allure } from "hermione-allure/runtime";

it("my test", async ({ currentTest }) => {
  await allure(currentTest).epic("my_epic");
});

Links

Add any link by low-level link method:

import { allure } from "hermione-allure/runtime";

it("my test", async ({ currentTest }) => {
  await allure(currentTest).link("http://example.org", "my_link_name", "my_link_type");
});

Or using aliases: issue, tms:

import { allure } from "hermione-allure/runtime";

it("my test", async ({ currentTest }) => {
  await allure(currentTest).issue("http://example.org", "my_link_name");
  await allure(currentTest).tms("http://example.org", "my_link_name");
});

If you configured links templates you can use shorter syntax of links as well:

import { allure } from "hermione-allure/runtime";

it("my test", async ({ currentTest }) => {
  await allure(currentTest).issue("1");
  await allure(currentTest).issue("2", "Issue name");
  await allure(currentTest).tms("1");
  await allure(currentTest).tms("2", "Task name");
});

Parameters

Test parameters can be added by parameter method:

import { allure } from "hermione-allure/runtime";

it("my test", async ({ currentTest }) => {
  await allure(currentTest).parameter("param_name", "param_value", {
    excluded: false,
  });
});

Attachments

Attach any file as string or buffer using attachment method:

import { allure } from "hermione-allure/runtime";

it("my test", async ({ currentTest }) => {
  await allure(currentTest).attachment(JSON.stringify({ foo: "bar" }), "application/json", "Attachment name");
});

If you want to attach a screenshot generated in tests, you can use the same method:

import { allure } from "hermione-allure/runtime";

it("adds screenshots", async ({ browser, currentTest }) => {
  const screenshot = await browser.takeScreenshot();

  await allure(currentTest).attachment(screenshot, "image/png");
});

Steps

The reporter provides step method to add steps inside your tests for better structure:

import { allure } from "hermione-allure/runtime";

it("my test", async ({ browser, currentTest }) => {
  await allure(currentTest).step("first step name", async () => {
    await allure(currentTest).step("second step name", async () => {
      await allure(currentTest).step("third step name", async () => {
        // all labels and links will be added to the test, not the step
        await allure(currentTest).label("foo", "bar");
        // attachments and parameters will be added to the step, not the test
        await allure(currentTest).parameter("baz", "qux");
        await allure(currentTest).attachment("attachment content", "text/plain");
      });
    });
  });
});

Custom history ID

You can reassign history ID for the test case using historyId method:

import { allure } from "hermione-allure/runtime";

it("my test", async ({ currentTest }) => {
  await allure(currentTest).historyId("my_history_id");
});

Custom test case ID

import { allure } from "hermione-allure/runtime";

it("my test", async ({ currentTest }) => {
  await allure(currentTest).testCaseId("my_id");
});

Package Sidebar

Install

npm i hermione-allure

Weekly Downloads

3

Version

2.15.1

License

Apache-2.0

Unpacked Size

52.4 kB

Total Files

17

Last publish

Collaborators

  • qameta-bot