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

jandk-cucumber-report

v1.2.0

Published

This module use cucumber's JSON report file to create an html report and send slack synthesis.

Downloads

620

Readme

Cucumber-report

This node module use cucumber's JSON report file to create an html report and send slack synthesis.

Installation

npm install jandk-cucumber-report

Usage

In your cucumber.conf.js, in an AfterAll hook (https://github.com/cucumber/cucumber-js/blob/master/docs/support_files/hooks.md), tell the reporter to load the report file, then to produce the html report and/or to send a synthesis to the slack channel.

const reporter = require('cucumber-report');

...

AfterAll(() => {

	setTimeout(() => { // We have to give time to cucumber to write the report file

		// Loading the report
		reporter.loadReport({
			filepath: "./cucumber_report.json"
		}).then((report) => {

			// Creating the HTML report
			reporter.toHtml({
				"report": report,
				"filepath": "htmlreport.html",
				"title": "REPORT TITLE",
				"logoPath": "./logo.png"
			}).catch((error) => {
				console.error(error);
			});

			// Sending synthesis to SLACK
			reporter.toSlack({
				"report": report,
				"filesToSend": ["/path/to/file1","an/other/path/to/anotherfile"], // file(s) sent
				"title": "REPORT TITLE", // facultative
				"token": "XXXXX-SLACK-APPLICATION-TOKEN", // See https://api.slack.com/apps
				"conversationId": "#the-channel-you-want-the-report-sent-to", // Remember to add your bot to the channel
				"sendMessageIfAllSuccess": true, // default to true
				"sendFileIfAllSuccess": true, // default to true
				"linkURL": "http://link-to-html-report", // facultative
				"limitFailedTestShown": 10, // Slack limits at 50 - default to 10
				"giphyAPIKey": "XXXXXXXXXXXXXX", // If you have no failed test and wish to celebrates with a gif, get an API Key : https://developers.giphy.com/ - facultative
				"giphyTag": "happy" // facultative
			}).catch((error) => {
				console.error(error);
			});

			// Finding regressions
			reporter.findRegression({
				"report": report,
				"logDir": "./logs",
				"logFilenameFormat": "YYYY-MM-DD-HH" // moment.js format date syntax (https://momentjs.com/docs/#/displaying/format/)
			}).then((regressions) => {

				// Sending those to slack
				reporter.toSlack({
					"regressions": regressions,
					"token": "XXXXX-SLACK-APPLICATION-TOKEN", // See https://api.slack.com/apps
					"title": "TESTING MODULE", // facultative
					"conversationId": "#the-channel-you-want-the-report-sent-to",
					"limitFailedTestShown": 10, // Slack limits at 50 - default to 10
					"giphyAPIKey": "XXXXXXXXXXXXXX", // If you have no regressions and wish to celebrates with a gif, get an API Key : https://developers.giphy.com/ - facultative
					"giphyTag": "happy" // facultative
				});

			})

		}).catch((error) => {
			console.error(error);
		});

	}, 1000);

}

limitFailedTestShown

If set to 0, no message will be shown.

About regression

This functionnality need to log the tests session in order to compare what just happened to what happened before. To do so, they save the current report to a directory with a datetime format filename. By changing this datetime format you can control the granularity of the log :

  • If you save report with "YYYY-MM-DD-HH-mm-ss-SSS" you will have every tests saved
  • If you save report with "YYYY-MM-DD" you will have 1 test saved per day (the last one)

Ajust your granularity to how often you run your tests.

Watch out for a too fine granularity : findRegression and findNewSuccess might create 2 different logs if the logFilenameFormat use seconds or milliseconds.

TODO

  • Handle empty cucumber's report
  • Report new successfull tests by analysing reports history
  • Implement test to allow anyone to update module safely
  • Have html templates/modules to change style
  • Explain feature arboresence naming system