Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
simple-cucumber-html-reporter
Advanced tools
Readme
Simple Cucumber HTML Reporter is a reporting module for Cucumber to parse the JSON output to a beautiful report. The difference between all the other reporting modules on the market is that this module has:
Install this module locally with the following command:
npm install simple-cucumber-html-reporter
Save to dependencies or dev-dependencies:
npm install simple-cucumber-html-reporter --save
npm install simple-cucumber-html-reporter --save-dev
simple Cucumber HTML Reporter now works with CucumberJS 2 and 3.
It provides
simple-cucumber-html-reporter
and some nice integration features that will make using Protractor + CucumberJS 1/2/3 nicely integrate with only a few lines of code.
simple Cucumber HTML Reporter transforms the Cucumber JSON output to a beautiful report. In order to let this happen add the piece of code that is placed below to CucumberJS AfterFeatures
-hook.
const report = require("simple-cucumber-html-reporter");
report.generate({
jsonDir: "./path-to-your-json-output/",
reportPath: "./path-where-the-report-needs-to-be/",
metadata: {
browser: {
name: "chrome",
version: "60"
},
device: "Local test machine",
platform: {
name: "ubuntu",
version: "16.04"
}
},
customData: {
title: "Automation Run",
data: [
{ label: "Project", value: "Simple project" },
{ label: "Release", value: "1.0.0" },
{ label: "Sprint", value: "5" }
]
}
});
Since cucumber-js 3.x the AfterFeatures
hook is not supported anymore. To use simple Cucumber HTML Reporter it must be run in a separate node executable after the cucumber-js process finishes.
IMPORTANT:
Make sure that, when you generate the JSON files with Cucumber, each file will have a UNIQUE name. If you don't provide a unique name Cucumber will override the JSON files.
Advice is to use for example the name of the feature, the name of the browser / device it is running on AND a unix timestamp with for example this
(new Date).getTime();
. This will result in something like thisname_of_feature.chrome.1495298685509.json
jsonDir
String
The directory that will hold all the generated JSON files, relative from where the script is started.
N.B.: If you use a npm script from the command line, like for example npm run generate-report
the jsonDir
will be relative from the path where the script is executed. Executing it from the root of your project will also search for the jsonDir
from the root of you project.
reportPath
String
The directory in which the report needs to be saved, relative from where the script is started.
N.B.: If you use a npm script from the command line, like for example npm run generate-report
the reportPath
will be relative from the path where the script is executed. Executing it from the root of your project will also save the report in the reportPath
in the root of you project.
openReportInBrowser
boolean
If true the report will automatically be opened in the default browser of the operating system.
saveCollectedJSON
boolean
This module will first merge all the JSON-files to 1 file and then enrich it with data that is used for the report. If saveCollectedJSON :true
the merged JSON AND the enriched JSON will be saved in the reportPath
. They will be saved as:
merged-output.json
enriched-output.json
disableLog
boolean
false
This will disable the log so will NOT see this.
=====================================================================================
simple Cucumber HTML report generated in:
/Users/rahul/simple-cucumber-html-reporter/.tmp/index.html
========================================================================
reportName
string
You can change the report name to a name you want
displayDuration
boolean
If set to true the duration of steps, scenarios and features is displayed on the Feature page in an easily readable format. This expects the durations in the report to be in milliseconds, which might result in incorrect durations when using a version of Cucumber that does not report in milliseconds (like v.1).
metadata
JSON
Print more data to your report, such as browser name + version, platform name + version and your environment. The values need to meet some predefined data, see Metadata for more info. Data can be passed like below.
If you provide the metadata when instantiating
multi-cucumber-html-reporter
the metadata will be added to each feature. If you already have metadata in your JSON then the metadata in the JSON will take precedence
metadata:{
browser: {
name: 'chrome',
version: '60'
},
device: 'Local test machine',
platform: {
name: 'ubuntu',
version: '16.04'
}
}
See metadata for more info
customMetadata
boolean
It is possible to provide custom metadata by setting this variable to true
. Custom metadata will override the regular metadata completely and potentially have strange formatting bugs if too many (10+) variables are used.
The columns will be in the order defined by the order of the list.
Adding the metadata is done in the same way as with normal metadata. The metadata is formed as a list of key-value pairs to preserve order:
metadata: [
{ name: "Environment v.", value: "12.3" },
{ name: "Plugin v.", value: "32.1" },
{ name: "Variable set", value: "Foo" }
];
IMPORTANT: This does not work correctly if features have different sets of metadata. Try to avoid this situation.
customData
object
You can add a custom data block to the report like this
customData: {
title: 'Run info',
data: [
{label: 'Project', value: 'Custom project'},
{label: 'Release', value: '1.2.3'},
{label: 'Cycle', value: 'B11221.34321'},
{label: 'Execution Start Time', value: 'Nov 19th 2017, 02:31 PM EST'},
{label: 'Execution End Time', value: 'Nov 19th 2017, 02:56 PM EST'}
]
}
customData.title
string
Custom data title
Select a title for the custom data block. If not provided it will be defaulted.
customData.data
array
The data you want to add. This needs to be in the format
data: [{ label: "your label", value: "the represented value" }];
The report can also show on which browser / device a feature has been executed. It is shown on the featurs overview in the table as well as on the feature overview in a container.
To be able to see this you will need to add the following to the Cucumber JSON before you save it.
// This represents the Cucumber JSON file that has be retrieved
const cucumberJSON;
const metadata = "metadata": {
"browser": {
"name": "chrome",
"version": "58"
},
"device": "string",
"platform": {
"name": "osx",
"version": "10.12"
}
}
// Add it with for example
cucumberJSON[0].metadata = metadata;
// Now save the file to the disk
metadata.app.name
string
e.g.: The name of the app.
metadata.app.version
string
e.g.: The version of the app.
metadata.browser.name
string
internet explorer | edge | chrome | firefox | safari
If no correct value is provided the
?
-icon with the textnot known
is shown
metadata.browser.version
string
e.g.: The version of the browser, this can be added manual or retrieved during the execution of the tests to get the exact version number.
If no correct value is provided the
?
-icon with the textnot known
is shown
metadata.device
string
e.g.: A name that represents the type of device. For example, if you run it on a virtual machine, you can place it here Virtual Machine
, or the name of the mobile, like for example iPhone 7 Plus
.
If no correct value is provided the
?
-icon with the textnot known
is shown
metadata.platform.name
string
windows | osx | linux | ubuntu | android | ios
If no correct value is provided the
?
-icon with the textnot known
is shown
metadata.platform.version
string
e.g.: The version of the platform
If no correct value is provided the
?
-icon with the textnot known
is shown
It could be that the name of the Cucumber JSON file that has been saved is not unique (enough).
My advice is to use for example:
(new Date).getTime();
This will result in something like this name_of_feature.chrome.1495298685509.json
.
The advantage of this is that when you look at the folder where the Cucumber JSON-files are saved you can see:
not known
or not the correct iconsThere could be 2 causes:
metadata.browser.name
or metadata.platform.name
can't be mapped to the right iconTo fix this see the part about Metadata and check the possible values.
You can attach screenshots at any time to a Cucumber JSON file. Just create a Cucumber scenario
-hook that will handle this. You can add them during running or when a scenario
failed.
Depending on the framework you are using, you can add a screenshot to the report like this
return driver.takeScreenshot()
.then(function (buffer) {
const decodedImage = new Buffer(screenshot.replace(/^data:image\/png;base64,/, ''), 'base64');
scenario.attach(decodedImage, 'image/png');
}
You can attach plain-text / data at any time to a Cucumber JSON file to help debug / review the results. You can add them during running or when a scenario
failed.
scenario.attach("place here what you want to show in the report");
You can attach JSON at any time to a Cucumber JSON file. You can add them during running or when a scenario
failed.
scenario.attach(JSON.stringify(yourJsonObject));
FAQs
Generates simple cucumberjs automation reports for browsers and devices
The npm package simple-cucumber-html-reporter receives a total of 113 weekly downloads. As such, simple-cucumber-html-reporter popularity was classified as not popular.
We found that simple-cucumber-html-reporter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.