Skip to content

Latest commit

 

History

History
82 lines (55 loc) · 1.86 KB

README.md

File metadata and controls

82 lines (55 loc) · 1.86 KB

allure-mocha

This project implements Allure integration with Mocha framework.

Allure API doesn't work in parallel mode! If you want to use the functionality, please switch back to single thread mode!

Installation

npm i allure-mocha mocha --save-dev

or via yarn:

yarn add allure-mocha mocha --dev

Note that it's recommended to add the following dependencies as well for better user experience:

  • typescript
  • mocha-typescript
  • source-map-support

Usage

Either add allure-mocha into mocha.opts:

--reporter allure-mocha

Or pass the same value via commandline / scripts:

mocha -R allure-mocha

If you want to provide extra information, such as steps and attachments, import the allure object into your code:

const allureMocha = require("allure-mocha/runtime");

it("is a test", () => {
  allureMocha.allure.epic("Some info");
});

Parameters usage

import allureMocha from "allure-mocha/runtime";

it("is a test", () => {
  allureMocha.allure.parameter("parameterName", "parameterValue");
});

Also addParameter takes an third optional parameter with the hidden and excluded options: mode: "hidden" | "masked" - masked hide parameter value to secure sensitive data, and hidden entirely hide parameter from report

excluded: true - excludes parameter from the history

import allureMocha from "allure-mocha/runtime";

it("is a test", () => {
  allureMocha.allure.parameter("parameterName", "parameterValue", {
    mode: "hidden",
    excluded: true,
  });
});

Decorators Support

To make tests more readable and avoid explicit API calls, you can use a special extension - ts-test-decorators.

Examples

mocha-allure-example - minimal setup for using mocha with allure