• Stars
    star
    113
  • Rank 308,354 (Top 7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate Allure Report for jest. Allure Report, a flexible lightweight multi-language test report tool with the possibility to add steps, attachments, parameters and so on.

Jest-Allure reporting plugin

Add more power to your tests using Jest-Allure. Easily generate nice reports at the end of the execution.

Awesome License: MIT PRs Welcome

GitHub followers GitHub stars GitHub watchers

Examples


Allure Report

Allure Framework is a flexible lightweight multi-language test report tool that not only shows a very concise representation of what have been tested in a neat web report form, but allows everyone participating in the development process to extract maximum of useful information from everyday execution of tests.

Installation

yarn add -D jest-allure

or

npm install --save-dev jest-allure

Uses Jest-circus or jest -v >27 ?

Jest-allure doesn't support jest-circus. (but PR's are welcome)

As starting from jest@27 it uses jest-circus as default testrunner you must update jest.config.js and set:

"testRunner": "jest-jasmine2"

jest -v >24 ?

Then add jest-allure/dist/setup to setupFilesAfterEnv section of your config.

setupFilesAfterEnv: ["jest-allure/dist/setup"]

jest -v < 24 ?

add reporter to jest.config.js

reporters: ["default", "jest-allure"],

Run your tests and enjoy ๐Ÿฅค๐Ÿš€


How to get a report

You need to install the CLI in order to obtain a report.

To see a report in browser, run in console

allure serve

If you want to generate html version, run in console

allure generate

Advanced features

You can add description, screenshots, steps, severity and lots of other fancy stuff to your reports.

Global variable reporter available in your tests with such methods:

    description(description: string): this;
    severity(severity: Severity): this;
    epic(epic: string): this;
    feature(feature: string): this;
    story(story: string): this;
    startStep(name: string): this;
    endStep(status?: Status): this;
    addArgument(name: string): this;
    addEnvironment(name: string, value: string): this;
    addAttachment(name: string, buffer: any, type: string): this;
    addLabel(name: string, value: string): this;
    addParameter(paramName: string, name: string, value: string): this;

Example

import { Severity } from "jest-allure/dist/Reporter";
import { Feature } from "somwhere in your project";

describe("Fancy test", () => {
        ...
        
        it("Test your amazing feature", async () => {
            reporter
                .description("Feature should work cool")
                .severity(Severity.Critical)
                .feature(Feature.Betting)
                .story("BOND-007");

            reporter.startStep("Check it's fancy");
            // expect that it's fancy
            reporter.endStep();
            
            reporter.startStep("Check it's cool");
            // expect that it's cool
            reporter.endStep();

            const screenshotBuffer = await page.screenshot();
            reporter.addAttachment("Screenshot", screenshotBuffer, "image/png");
        });
        
        ...
    }
);

What's next

  • Generate report from Jest results
  • Add steps support
  • Add labels support
  • Add attachments support
  • Add more examples

Additional projects

visual-unit-tests

jest-allure-image-snapshot

Warning

jest-allure reporter dynamically configure "setupTestFrameworkScriptFile" option in Jest configuration. If you have your own setupTestFrameworkScriptFile file, you need to manually register allure reporter, for it you need to import jest-allure/dist/setup.

import "jest-allure/dist/setup";

In case if you have jest version > 24 just add jest-allure/dist/setup to setupFilesAfterEnv section of your config.

Contributors


Denis Artyuhovich

Dmitry Bogomya

More Repositories

1

ng2-rest-api

๐Ÿ”ด Rest API provider for angular 2.
TypeScript
209
star
2

ng-rest-api

๐Ÿค˜ Rest API provider for angular.
JavaScript
133
star
3

visual-unit-tests

๐ŸžExample how to implement visual unit tests for React application with jest and puppeteer plus allure report
TypeScript
54
star
4

ng2-typing-carousel

๐Ÿ“ Simple typing carousel directive for angular2.
JavaScript
11
star
5

wspr

WebSocket proxy for post http requests. Perfect for testing purposes/mocks ๐Ÿš€
TypeScript
10
star
6

terraform-typescript-frontend-infrastructure

AWS frontend infrastructure managed by terraform written with typescript
TypeScript
8
star
7

iac-talk-demo-project

Infrastructure As Code for JS applications on AWS with TypeScript
TypeScript
7
star
8

jest-environment-puppeteer-jsdom

JavaScript
3
star
9

Angular2-starter-kit

๐Ÿš€ Seed project for Angular 2 with typescript and es6 features (Typescript, Babel, Webpack, Gulp).
JavaScript
3
star
10

uptoversion

Raise a pull request to update the dependency to the specific version in any project
TypeScript
3
star
11

transformCssClassNames

Convert your css/scss/pcss/less class names
CSS
2
star
12

jest-allure-image-snapshot

JavaScript
1
star
13

SimpleGallery

๐Ÿ“ท Angular 1.5, Symfony 2.8, vagrant, postgreSql
PHP
1
star
14

jest-image

๐ŸŒ‡vs ๐ŸŒ†Custom jest matchers to test the visual regression
TypeScript
1
star
15

recoil-experiments

TypeScript
1
star
16

demoRN

TypeScript
1
star
17

js-inline-css-webpack-plugin

Simple webpack plugin for convert external stylesheet to embedded into js stylesheet
JavaScript
1
star
18

dynamicPixelmatch

Exclude some areas from image before comparison using pixelmatch
JavaScript
1
star