Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-allure2-adapter

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-allure2-adapter

Allure 2 Adapter for jest

  • 0.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.2K
increased by1.02%
Maintainers
1
Weekly downloads
 
Created
Source

Jest-Allure-2 reporting plugin

Originally forked from jest-allure.

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
  • todo

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-allure2-adapter

or

npm install --save-dev jest-allure2-adapter

jest -v >24 ?

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

setupFilesAfterEnv: ["jest-allure2-adapter/dist/setup"]

jest -v < 24 ?

add reporter to jest.config.js
reporters: ["default", "jest-allure2-adapter"],

Run tests. Results will be generated and stored in allure-results folder.


How to get a report

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

For example see allure-commandline.

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;
    descriptionHtml(description: string): this;
    severity(severity: Severity): this;
    epic(epic: string): this;
    feature(feature: string): this;
    story(story: string): this;
    owner(story: string): this;

    step<T>(name: string, body: () => any): T;
    startStep(name: string): this;
    endStep(status?: Status): this;

    addEnvironment(name: string, value: string): this;

    addAttachment(name: string, buffer: any, type: string): this;
    addTestAttachment(name: string, buffer: any, type: string): this;

    addLabel(name: string, value: string): this;
    addParameter(paramName: string, name: string, value: string): this;
    addParameters(...params: [string, any][]): this;

    addLink(options: {
        name?: string;
        url: string;
        type?: LinkType;
    }): this;

    addIssue(options: {
        id: string;
        name?: string;
        url?: string;
    }): this;

    addTms(options: {
        id: string;
        name?: string;
        url?: string;
    }): this;

Example (todo)

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
  • Ability to implement own JasmineAllureReporter
  • Add before/after hooks
  • Add examples
  • Ability to config (timestamp to step, jira link)

Warning

jest-allure2-adapter 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-allure2-adapter/dist/setup';

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

Contributors


Taisia Pitko

Keywords

FAQs

Package last updated on 29 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc