Allure framewok integration for Mocha framework
- Learn more about Allure Report at https://allurereport.org
- 📚 Documentation – discover official documentation for Allure Report
- ❓ Questions and Support – get help from the team and community
- 📢 Official annoucements – be in touch with the latest updates
- 💬 General Discussion – engage in casual conversations, share insights and ideas with the community
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
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 { epic } = require("allure-js-commons");
it("is a test", async () => {
await epic("Some info");
});
const { parameter } = require("allure-js-commons");
it("is a test", async () => {
await parameter("parameterName", "parameterValue");
});
The parameter
method may also take the third argument with the hidden
and excluded
options:
mode: "hidden" | "masked"
- masked
replaces the value with *
characters to secure sensitive data, and hidden
hides the parameter from report.
excluded: true
- excludes the parameter from the history.
import { parameter } from "allure-js-commons";
it("is a test", async () => {
await parameter("parameterName", "parameterValue", {
mode: "hidden",
excluded: true,
});
});
To make tests more readable and avoid explicit API calls, you may use a special extension - ts-test-decorators.
mocha-allure-example - a minimal setup for using Mocha with Allure.