This project implements Allure integration with Mocha framework.
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:
// es-modules
import { allure } from 'allure-mocha/runtime';
// or commonjs
const { allure } = require('allure-mocha/runtime');
it('is a test', () => {
allure.epic('Some info');
});
To make tests more readable and avoid explicit API calls, you can use a special extension - ts-test-decorators.
See mocha-allure2-example project, which is already configured to use latest Allure 2 features with decorators support.
@srg-kostyrko for help and assistance.