allure-mocha

Allure Mocha integration

Usage no npm install needed!

<script type="module">
  import allureMocha from 'https://cdn.skypack.dev/allure-mocha';
</script>

README

allure-mocha

This project implements Allure integration with Mocha framework.

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:

// es-modules
import { allure } from 'allure-mocha/runtime';
// or commonjs
const { allure } = require('allure-mocha/runtime');

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

Decorators Support

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

Examples

See mocha-allure2-example project, which is already configured to use latest Allure 2 features with decorators support.

Thanks

@srg-kostyrko for help and assistance.