npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jest-allure2

v1.2.3

Published

Allure 2 Reports for jest

Downloads

1,672

Readme

Jest-Allure2

An up to date Jest reporter that produces Allure 2 reports.

npm version Continuous Integration Continuous Deployment Known Vulnerabilities XO code style semantic-release License: MIT

Allure Report

Originally forked from jest-allure, this project uses the latest allure configuration ^2.0.0-beta.6.

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.

Features:

  • Most robust Allure API currently available to Jest.

  • Support for new attachment types that were not supported on previous versions.

  • Allure result files are now JSON, replacing the legacy XML format.

Requirements

| Resource | Description | | -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | | Jest | A delightful JavaScript testing framework. | | Allure 2 CLI | "A Java jar command line tool that turns Allure result files into beautiful Allure reports." |

:rocket: Quick start

  1. Add this package
yarn add --dev jest-allure2
  1. Update jest.setup.js
var { registerAllure } = require('jest-allure2')

registerAllure()
  1. Run tests
yarn test
  1. Generate the Allure report
allure generate

Advanced features

Add descriptions, screenshots, steps, severity and lots of other fancy details to the report.

The global variable will have a new allure object available with the following methods:

    allure.description(description: string): this;
    allure.severity(severity: Severity): this;
    allure.epic(epic: string): this;
    allure.feature(feature: string): this;
    allure.story(story: string): this;
    allure.step(name: string, status: string | (args:[any]) => string): this;
    allure.environment(name: string, value: string): this;
    allure.attachment(name: string, buffer: any, type: string): this;
    allure.label(name: string, value: string): this;
    allure.tag(name: string): this;
    allure.parameter(name: string, value: string): this;
    allure.issue(id: string): this;
    allure.tms(id: string): this;

Example

// Test subject
function sum(a: number, b: number): number {
	return a + b
}

// Tests
describe('Number functions', () => {
	beforeEach('Setup', () => {
		allure.severity(Severity.Critical)
		allure.feature(Feature.Billing)
		allure.story('BILL-217')
	})

	test('sum performs addition functionality', () => {
		allure.description('Tests should be ran when billing functionality is changed.')

		allure.step('Two integers can be added together.', () => {
			allure.parameter('a', 3)
			allure.parameter('b', 4)
			expect(sum(3, 4)).toBe(7)
		})

		allure.step('Two floats can be added together', () => {
			allure.parameter('a', 3.141)
			allure.parameter('b', 2.571)
			expect(sum(3.141, 2.571)).toBe(5.712)
		})

		allure.step('Two objects can be added together', () => {
			const a = { a: 1 }
			const b = { b: 2 }

			allure.parameter('a', a)
			allure.parameter('b', b)
			expect(sum(a, b)).toMatchSnapshot()
		})
	})
})

:gear: Options

The main export registerAllure() accepts three optional configuration arguments:

| Parameter | Description | Default | | --------------- | ----------------------------------------------------------------------------------- | ------------------ | | resultsDir | File path where result files are written. | "allure-results" | | environmentInfo | Key value pairs that will appear under the environment section of the Allure report | {} | | testMapper | Decorator that receives Allure test result objects. | undefined |

// jest.setup.js
var resultsDir = 'allure-results'
var environmentInfo = { Username: 'User-1331', password: 'password-1331' }
var testMapper = (results) => {
	if (result.status == Status.SKIPPED) {
		result.fullName = `(WAS SKIPPED) ${result.fullName}`
	}
	return result
}

registerAllure(resultsDir, environmentInfo, testMapper)