Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
protractor-multiple-cucumber-html-reporter-plugin
Advanced tools
A protractor plugin to use multiple-cucumber-html-reporter with CucumberJs 1, 2 or 3
This plugin will connect Protractor, CucumberJS and protractor-cucumber-framework to generate unique JSON files per feature with only a few lines of code. It will also replace the extra CucumberJS hook you needed to make in CucumberJS 1 and 2 to generate unique JSON report files.
It was born when CucucmberJS 3 removed the
registerHandler
andregisterListener
. As of version 3 Protractor and CucumberJS users don't have the possibility to generate and create unique JSON report files. With this module they have.
You will also get multiple-cucumber-html-reporter as a dependency and use it on the fly to generate beautiful reports. A sample can be found here
Node.js | Protractor | CucumberJS | protractor-cucumber-framework | multiple-cucumber-html-reporter |
---|---|---|---|---|
6.x | 4.x | 1.x | 3.1.2 or higher | 1.0.0 or higher |
7.x | 5.x | 2.x | ||
3.x |
npm install protractor-multiple-cucumber-html-reporter-plugin --save-dev
You need to do 2 things.
format: 'json:.tmp/results.json'
to your cucumberOpts
in the config. This will tell CucumbjerJS to generate a JSON-file. As of protractor-cucumber-framework
version 3.1.2 you will get unique JSON files, see also here.protractor-multiple-cucumber-html-reporter-plugin
in the plugins
block inside
protractor.config.js
.!!The path that is defined in the
format
is the path where all files and reports are saved. Advice is not to save the CucumberJS JSON report fil in the root of the project but in for example a.tmp/
folder!!
Here is a short config example of both steps.
const path = require('path');
exports.config = {
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
cucumberOpts: {
require: [
path.resolve(process.cwd(), './**/*.steps.js')
],
// Tell CucumberJS to save the JSON report
format: 'json:.tmp/results.json',
strict: true
},
specs: [
'*.feature'
],
multiCapabilities: [{
browserName: 'chrome',
shardTestFiles: true,
maxInstances: 2,
chromeOptions: {
args: ['disable-infobars']
}
}],
// Here the magic happens
plugins: [{
package: 'protractor-multiple-cucumber-html-reporter-plugin',
options:{
// read the options part
}
}]
};
If you don't provide options
the pluging will use the defaults as mentioned below. Options can be added by creating an object like this:
plugins: [{
package: 'protractor-multiple-cucumber-html-reporter-plugin',
options:{
// read the options part for more options
automaticallyGenerateReport: true,
removeExistingJsonReportFile: true
}
}]
automaticallyGenerateReport
boolean
false
Setting this option will autimatically generate a new report with multiple-cucumber-html-reporter
. It will generate a log at the end of the testexection where you can find the report and looks like this. This means that you don't need to call the report module in a seperate node process. For the options of the report see the options openReportInBrowser
, reportPath
and saveCollectedJSON
=====================================================================================================
Multiple Cucumber HTML report generated in:
/Users/wswebcreation/protractor-multiple-cucumber-html-reporter-plugin/.tmp/report/index.html
=====================================================================================================
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'}
]
}
THIS WILL ONLY WORK WITH
automaticallyGenerateReport:true
. IF YOU GENERATE THE REPORT LATER PLEASE LOOK AT multiple-cucumber-html-reporter
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'}
]
customStyle
path
If you need add some custom style to your report. Add it like this customStyle: 'your-path-where/custom.css'
disableLog
boolean
false
This will disable the log so will NOT see this.
=====================================================================================================
Multiple Cucumber HTML report generated in:
/Users/wswebcreation/protractor-multiple-cucumber-html-reporter-plugin/.tmp/report/index.html
=====================================================================================================
displayDuration
boolean
If set to true
the duration of steps, scenarios and features is displayed on the Features overview and single feature page in an easily readable format.
This expects the durations in the report to be in nanoseconds, which might result in incorrect durations when using a version of Cucumber(JS 2 and 3) that does not report in nanoseconds but in milliseconds. This can be changed to milliseconds by adding the parameter durationInMS: true
, see below
NOTE: Only the duration of a feature can be shown in the features overview. A total duration over all features CAN NOT be given because the module doesn't know if all features have been run in parallel
durationInMS
boolean
false
If set to true
the duration of steps will be expected to be in milliseconds, which might result in incorrect durations when using a version of Cucumber(JS 1 or 4) that does report in nanaseconds.
This parameter relies on displayDuration: true
jsonOutputPath
string
json-output-folder
The directory that will hold all the unique 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 jsonOutputPath
will be relative from the path where the script is executed. Executing it from the root of your project will also search for the jsonOutputPath
from the root of you project.
If you DON'T provide this it will generate a json-output-folder
-folder in the path
that it defined the cucumberOpts.format
.
metadataKey
string
metadata
This will be the key
reference in the capabilities
or multiCapabilities
that will refer to where the instance specific data is saved. The metadata is used for the report that will be generated, see also metadata.
If for example all the metadata is already present in the capabilities
but with the key
called deviceProperties
you can add the option metadataKey: 'deviceProperties'
and the plugin will automatically copy the deviceProperties
-object to the metadata
of the report.
openReportInBrowser
boolean
false
Settign this option will automatically open the generated report in the default browser of the operating system. See also here.
overrideStyle
path
If you need replace default style for your report. Add it like this overrideStyle: 'your-path-where/custom.css'
pageFooter
string
You can customise Page Footer if required. You just need to provide a html string like <div><p>A custom footer in html</p></div>
pageTitle
string
You can change the report title in the HTML head Tag
removeExistingJsonReportFile
boolean
false
Settign this option will remove the previous unique JSON report file if it exists. It will prevent double reports of 1 feature + browser execution combination when generating te report with multiple-cucumber-html-reporter
. This may come in handy when you rerun your flakey features with for example protractor-flake
removeOriginalJsonReportFile
boolean
false
Setting this option will remove the original json report file, defined in the cucumberOpts.format
. It will clean up the folder where you save all your results and may be needed if you have a lot of JSON-files with screenshots in it.
reportName
string
You can change the report name to a name you want.
THIS WILL ONLY WORK WITH
automaticallyGenerateReport:true
. IF YOU GENERATE THE REPORT LATER PLEASE LOOK AT multiple-cucumber-html-reporter
reportPath
string
report
The directory in which the report needs to be saved, relative from where the script is started. See also here.
If you DON'T provide this it will generate a report
-folder in the path
that it defined the cucumberOpts.format
.
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.
saveCollectedJSON
boolean
false
multiple-cucumber-html-reporter
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
See also here
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. You can add this by adding the following object to your capabilities
or multiCapabilities
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['disable-infobars']
},
// Add this
metadata: {
browser: {
name: 'chrome',
version: '58'
},
device: 'MacBook Pro 15',
platform: {
name: 'OSX',
version: '10.12.6'
}
}
}
// Or
multiCapabilities: [{
browserName: 'chrome',
chromeOptions: {
args: ['disable-infobars']
},
// Add this
metadata: {
browser: {
name: 'chrome',
version: '58'
},
device: 'MacBook Pro 15',
platform: {
name: 'OSX',
version: '10.12.6'
}
}
}
See the metadata information here for the correct values.
If you don't provide a
browser.name
or abrowser.version
the module will try to determine this automatically. The rest will be shown as questionmarks in the report
report/features
-folder, but they are not shown in the overview-page: See the answer in issue 13The Changelog/Releases can be found here
How to contribute can be found here
When creating this plugin I got a lot of inspiration from:
If this plugin was helpful for you, please give it a ★ Star on Github and npm
FAQs
A protractor plugin to use multiple-cucumber-html-reporter with CucumberJs 1, 2 or 3
The npm package protractor-multiple-cucumber-html-reporter-plugin receives a total of 3,271 weekly downloads. As such, protractor-multiple-cucumber-html-reporter-plugin popularity was classified as popular.
We found that protractor-multiple-cucumber-html-reporter-plugin 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.