Giter Club home page Giter Club logo

multiple-cucumber-html-reporter's Introduction

Multiple Cucumber HTML Reporter

Discord GitHub Workflow Status (with branch) GitHub npm

Multiple 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:

  • a quick overview of all tested features and scenarios
  • a features overview that can hold multiple runs of the same feature / runs of the same feature on different browsers / devices
  • a features overview that can be searched / filtered / sorted
  • a feature(s) overview with metadata of the used browser(s) / devices

Important

The default time notation in Cucumber is in nanoseconds. When you use a version of Cucumber that uses milliseconds (like CucumberJS 2 and 3) and you want to show the duration you should use displayDuration AND durationInMS = true

Snapshot - Features overview

or with dark mode enabled: image image

A sample can be found here

But you can also create a beautiful overview when you don't want to use CucumberJS with browser(meta)data but with custom metadata, see customMetadata. This nice feature has been created by LennDG

Snapshot - Features overview

A sample can be found here

Install

Install this module locally with the following command:

npm install multiple-cucumber-html-reporter

Save to dependencies or dev-dependencies:

npm install multiple-cucumber-html-reporter --save
npm install multiple-cucumber-html-reporter --save-dev

Compatibility

Multiple Cucumber HTML Reporter now works with CucumberJS 1, 2, 3 and 4.

Usage

If you are using Protractor I would advise you to use protractor-multiple-cucumber-html-reporter-plugin. If you are using webdriver.io please check WEBDRIVER.IO.MD for usage. It provides multiple-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.

cucumber-js 2.x and lower

Multiple 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("multiple-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: "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" },
    ],
  },
});

cucumber-js 3.x

Since cucumber-js 3.x the AfterFeatures hook is not supported anymore. To use Multiple 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 this name_of_feature.chrome.1495298685509.json

Options

jsonDir

  • Type: String
  • Mandatory: Yes

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

  • Type: String
  • Mandatory: Yes

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.

staticFilePath

  • Type: boolean
  • Default: false
  • Mandatory: No

If true each feature will get a static filename for the html. Use this feature only if you are not running multiple instances of the same tests.

openReportInBrowser

  • Type: boolean
  • Default: false
  • Mandatory: No

If true the report will automatically be opened in the default browser of the operating system.

saveCollectedJSON

  • Type: boolean
  • Default: false
  • Mandatory: No

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

  • Type: boolean
  • Default: false
  • Mandatory: No

This will disable the log so will NOT see this.

=====================================================================================
    Multiple Cucumber HTML report generated in:

    /Users/WasiqB/multiple-cucumber-html-reporter/.tmp/index.html
========================================================================

pageTitle

  • Type: string
  • Mandatory: No
  • Default: Multiple Cucumber HTML Reporter

You can change the report title in the HTML head Tag

reportName

  • Type: string
  • Mandatory: No

You can change the report name to a name you want

pageFooter

  • Type: string
  • Mandatory: No

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>

plainDescription

  • Type: boolean
  • Default: false
  • Mandatory: No

The feature description is assumed to be a simple string and the library formats it accordingly, by copying it inside a paragraph tag. Since the description can be any free text, it can also be as complex as a full div, e.g.:

<div>
  <p>
    <strong>Test description </strong> : The test implements comparisons using
    all our datatypes
  </p>
  <p><strong>Expected result </strong> : Device does not reset</p>
  <p><strong>Feature type </strong> : Robustness</p>
  <p><strong>Comments </strong> : Test covers comparison operators</p>
</div>

If the description already include formatting tags you can include it as is by setting plainDescription to true.

displayDuration

  • Type: boolean
  • Default: false
  • Mandatory: No

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

  • Type: boolean
  • Default: false
  • Mandatory: No

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 nanoseconds. This parameter relies on displayDuration: true

hideMetadata

  • Type: boolean
  • Default: false
  • Mandatory: No

If set to true metadata Devicetype, Device, OS, App, Browser are not being displayed in the Features overview.

displayReportTime

  • Type: boolean
  • Default: false
  • Mandatory: No

If set to true the date and time at which the JSON-files were generated, is displayed on the Features overview.

useCDN

  • Type: boolean
  • Default: false
  • Mandatory: No

If you prefer, you can use CDN for assets.

customStyle

  • Type: path
  • Mandatory: No

If you need to add some custom style to your report. Add it like this customStyle: 'your-path-where/custom.css'. Please note that the doughnut charts uses the same colors as used by the status icons, i.e. the .*-color classes. Refer to the test directory and the embedded-array test report for a complete color customization example.

overrideStyle

  • Type: path
  • Mandatory: No

If you need to replace completely the default style for your report. Add it like this overrideStyle: 'your-path-where/custom.css' Please refer to the test directory for an example.

metadata

  • Type: JSON
  • Mandatory: No

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

  • Type: boolean
  • Default: false
  • Mandatory: No

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" },
];

On the features overview page the custom metadata is shown like: Snapshot - Features overview custom metadata

IMPORTANT: This does not work correctly if features have different sets of metadata. Try to avoid this situation. Much like with metadata, if you provide the custom 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**

customData

  • Type: object
  • Mandatory: No

You can add a custom data block to the report like this

Snapshot - Features overview custom data

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

  • Type: string
  • Mandatory: No
  • Default: Custom data title

Select a title for the custom data block. If not provided it will be defaulted.

customData.data

  • Type: array
  • Mandatory: yes

The data you want to add. This needs to be in the format

data: [{ label: "your label", value: "the represented value" }];

Metadata

The report can also show on which browser / device a feature has been executed. It is shown on the features overview in the table as well as on the feature overview in a container.

Adding metadata to the Cucumber JSON

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 = {
  "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

  • Type: string

e.g.: The name of the app.

metadata.app.version

  • Type: string

e.g.: The version of the app.

metadata.browser.name

  • Type: string
  • Possible values: internet explorer | edge | chrome | firefox | safari

If no correct value is provided the ?-icon with the text not known is shown

metadata.browser.version

  • Type: 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 text not known is shown

metadata.device

  • Type: 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 text not known is shown

metadata.platform.name

  • Type: string
  • Possible values: windows | osx | linux | ubuntu | android | ios

If no correct value is provided the ?-icon with the text not known is shown

metadata.platform.version

  • Type: string

e.g.: The version of the platform

If no correct value is provided the ?-icon with the text not known is shown

Metadata example features overview

Snapshot - Features overview browser / device info

Metadata example scenario with and without known data

Snapshot - Scenario browser / device info Snapshot - Scenario app / device info Snapshot - Scenario browser / device info not known

FAQ

Only 1 report is shown in the features overview table

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:

  • the name of the feature
  • the name of the browser / device it is running on
  • a unix timestamp with for example this (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:

  • the features that have been executed
  • on which browser
  • a timestamp to see which feature has been executed the last (if featurename and browser are the same)

Metadata shows not known or not the correct icons

There could be 2 causes:

  1. The metadata has not (correctly) been added to the Cucumber JSON.
  2. The metadata.browser.name or metadata.platform.name can't be mapped to the right icon

To fix this see the part about Metadata and check the possible values.

How to attach Screenshots to HTML report

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.

Check the framework you are using to attach screenshots to the JSON file.

How to attach Plain Text to HTML report

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.

Check the framework you are using to attach plain text to the JSON file. Please make sure to convert binary/non-readable data to a suitable textual representation, e.g. via Base64 encoding.

How to attach pretty JSON to HTML report

You can attach JSON at any time to a Cucumber JSON file. You can add them during running or when a scenario failed.

Check the framework you are using to attach JSON data to the JSON file.

Changelog and Releases

The Changelog and releases can be found here

Contributing

How to contribute can be found here

Credits

In the search for a reporting tools for Cucumber I found a few tools that helped me a lot:

multiple-cucumber-html-reporter's People

Contributors

achingbrain avatar bacarozzo avatar baskercarrer avatar brian-dawson-nerdery avatar bsteensma avatar dannycohn avatar dawn-minion avatar deckaddict avatar dependabot[bot] avatar georgexcv avatar hannatarasevich avatar harsha509 avatar hdorgeval avatar jkroepke avatar kabomi avatar kevinkuszyk avatar kontownik avatar lenntt avatar luizfelipeneves avatar maxmanthey avatar mschluer avatar pazaan avatar shinusuresh avatar tomardern avatar vincebarresi avatar wasiqb avatar wluu avatar wswebcreation avatar yaronassa avatar yoghi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multiple-cucumber-html-reporter's Issues

Is it possible to group features in the REPORT HTML based on the feature folder

My test automation library got implementations for multiple widgets in the application. Hence I created independent folders to group the respective feature file. When I run the wdio-multiple-cucumber-html-reported, it combines all feature file into one big list . Is it possible to retain the same folder structure?

I would prefer to see all the feature files listed under their respective folder name.
It would be nice to have expand and collapse of features by using the folder names

Previously I used allure report and migrating now to this multiple html reporter. Would be nice to have this feature included that helps the BA and Project team to go through their folders to locate the specific feature file

module can't work with mobile-app metadata

For adding metadata to the report we can add the following for browsers:

metadata:{
    browser: {
        name: 'chrome',
        version: '60'
    },
    device: 'Local test machine',
    platform: {
        name: 'ubuntu',
        version: '16.04'
    }
}

Fore native / hybrid apps you don't have a browser. If you don't provide the browser-objectthe module will fail in rendering the templates.

Solution:
OR the browser-object or the app-object needs to be optional. The app-object can be something like this

app:{
    name: 'app-name',
    version: 'xx.xx'
}

Also:

  • add an icon
  • specs
  • gh-pages

Scenario name

Hi, I love this report but the scenarios name don't show.
Chrome Version 59.0.3071.115

In the example found in README.me, don't show too.

report_issue

The picture on html report disappeared

Environment (please complete the following information):

  • multiple-cucumber-html-reporter: [1.11.4]
  • Node.js version: [v10.13.0]
  • NPM version: [6.4.1]
  • Platform name and version: [Ubuntu 18]
  • Cucucmber version: [5.0.2]

Config of protractor + multiple-cucumber-html-reporter
An example of how you configured the reporter in your webdriver.io config

Describe the bug
This happened on my Azure DevOps pipeline. When I ran command "node create-html-report-chrome.js", this error generated:
2018-12-19T03:18:15.6138772Z (node:27356) UnhandledPromiseRejectionWarning: Error: Exited with code 3
2018-12-19T03:18:15.6139151Z at ChildProcess.cp.once.code (/home/fergad061436/myagent/_work/8/s/node_modules/opn/index.js:84:13)
2018-12-19T03:18:15.6139404Z at Object.onceWrapper (events.js:273:13)
2018-12-19T03:18:15.6140531Z at ChildProcess.emit (events.js:182:13)
2018-12-19T03:18:15.6141686Z > [email protected] report-chrome /home/fergad061436/myagent/_work/8/s
2018-12-19T03:18:15.6142536Z at maybeClose (internal/child_process.js:962:16)
2018-12-19T03:18:15.6143104Z > node create-html-report-chrome.js
2018-12-19T03:18:15.6144335Z at Socket.stream.socket.on (internal/child_process.js:381:11)
2018-12-19T03:18:15.6144398Z
2018-12-19T03:18:15.6145375Z at Socket.emit (events.js:182:13)
2018-12-19T03:18:15.6145443Z
2018-12-19T03:18:15.6146338Z at Pipe._handle.close (net.js:606:12)
2018-12-19T03:18:15.6146400Z
2018-12-19T03:18:15.6161341Z (node:27356) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2018-12-19T03:18:15.6161501Z =====================================================================================
2018-12-19T03:18:15.6165951Z (node:27356) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2018-12-19T03:18:15.6166109Z Multiple Cucumber HTML report generated in:
2018-12-19T03:18:15.6166305Z
2018-12-19T03:18:15.6166824Z /home/fergad061436/myagent/_work/8/s/reports/index.html
2018-12-19T03:18:15.6167104Z =====================================================================================

And the impact will be like this:
https://ibb.co/BGHHrKq

To Reproduce
Run command "node create-html-report-chrome.js"
Open the html report

Expected behavior
The html report will be generated properly.

Log
2018-12-19T03:18:15.6138772Z (node:27356) UnhandledPromiseRejectionWarning: Error: Exited with code 3
2018-12-19T03:18:15.6139151Z at ChildProcess.cp.once.code (/home/fergad061436/myagent/_work/8/s/node_modules/opn/index.js:84:13)
2018-12-19T03:18:15.6139404Z at Object.onceWrapper (events.js:273:13)
2018-12-19T03:18:15.6140531Z at ChildProcess.emit (events.js:182:13)
2018-12-19T03:18:15.6141686Z > [email protected] report-chrome /home/fergad061436/myagent/_work/8/s
2018-12-19T03:18:15.6142536Z at maybeClose (internal/child_process.js:962:16)
2018-12-19T03:18:15.6143104Z > node create-html-report-chrome.js
2018-12-19T03:18:15.6144335Z at Socket.stream.socket.on (internal/child_process.js:381:11)
2018-12-19T03:18:15.6144398Z
2018-12-19T03:18:15.6145375Z at Socket.emit (events.js:182:13)
2018-12-19T03:18:15.6145443Z
2018-12-19T03:18:15.6146338Z at Pipe._handle.close (net.js:606:12)
2018-12-19T03:18:15.6146400Z
2018-12-19T03:18:15.6161341Z (node:27356) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2018-12-19T03:18:15.6161501Z =====================================================================================
2018-12-19T03:18:15.6165951Z (node:27356) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2018-12-19T03:18:15.6166109Z Multiple Cucumber HTML report generated in:
2018-12-19T03:18:15.6166305Z
2018-12-19T03:18:15.6166824Z /home/fergad061436/myagent/_work/8/s/reports/index.html
2018-12-19T03:18:15.6167104Z =====================================================================================

Auto-detect edge in the browser metadata

I have some e2e tests running in edge, but it's not picking up the browser in the metadata:

image

and this in the json file:

"metadata": {
  "browser": {
    "name": "microsoftedge",
    "version": "41.16299.15.0"
  }
}

It looks like the templates are looking for edge. Would you take a PR which updates them to accept either string?

The html report is not generated after the tests have finished, even though the json files are generated correctly in the specified path

Environment:

  • multiple-cucumber-html-reporter: 1.11.2
  • Node.js version: 8.11.1
  • NPM version: 5.6.0
  • Platform name and version: Windows 10
  • Cucumber version: 5.0.0

Config of protractor + multiple-cucumber-html-reporter

  • Configuration file:
exports.config = {
	onPrepare: function () {
		'use strict';		
		require('babel-core/register');		
		browser.getCapabilities().then(function (capabilities) {
			browser.browserPlatform = capabilities.get('platform');
			browser.browserName = capabilities.get('browserName');
			browser.browserVersion = capabilities.get('version');
		});
	},
	framework: 'custom',	
	frameworkPath: require.resolve('protractor-cucumber-framework'),
	cucumberOpts: {		
		require: ['../features/step_definitions/*.js', '../features/support/*.js'],
		format: 'json:dist/teste2e/report/report2/report.json'
	},
	specs:['../features/*.feature'],	
	directConnect: false,
	jasmineNodeOpts: {
		defaultTimeoutInterval: 250000
	}
};
  • Reporter Hook:
module.exports = function () {
	'use strict';
	const report = require('multiple-cucumber-html-reporter');
	this.AfterFeatures(function(callback) {
		report.generate({
			jsonDir: './teste2e/report/',
			reportPath: './teste2e/report/',
			metadata:{
				browser: {
					name: browser.browserName,
					version: browser.browserVersion
				},
				device: 'Local test machine',
				platform: {
					name: browser.browserPlatform,					
				}
			}
		});
		callback();
	});
};

Bug description
The html report is not generated after the tests have finished, even though the json files are generated correctly in the specified path.

The following error is displayed in the console after the test finish running:

[14:35:56] E/launcher - Unexpected token e in JSON at position 0
[14:35:56] E/launcher - SyntaxError: Unexpected token e in JSON at position 0
    at JSON.parse (<anonymous>)
    at step.embeddings.forEach (<path>\node_modules\multiple-cucumber-html-reporter\lib\generate-report.js:329:67)
    at Array.forEach (<anonymous>)
    at scenario.steps.forEach.step (<path>\node_modules\multiple-cucumber-html-reporter\lib\generate-report.js:326:25)
    at Array.forEach (<anonymous>)
    at _parseSteps (<path>\node_modules\multiple-cucumber-html-reporter\lib\generate-report.js:321:20)
    at feature.elements.forEach.scenario (<path>\node_modules\multiple-cucumber-html-reporter\lib\generate-report.js:250:18)
    at Array.forEach (<anonymous>)
    at _parseScenarios (<path>\node_modules\multiple-cucumber-html-reporter\lib\generate-report.js:240:22)
    at suite.features.forEach.feature (<path>\node_modules\multiple-cucumber-html-reporter\lib\generate-report.js:186:17)
[14:35:56] E/launcher - Process exited with error code 199

The issue seems to be with the following line in the generate-report.js file where json.parse is used:
step.text = (step.text ? step.text : []).concat([JSON.parse(embedding.data)]);

Expected behavior
A index.html file should be generated in the report folder.

Possible fix
I've replaced json.parse with json.stringify and the report was generated successfully.

step.text = (step.text ? step.text : []).concat([JSON.stringify(embedding.data)]);

Additional details
I could also reproduce this issue with the latest version of protractor-multiple-cucumber-html-reporter-plugin.
report.txt

Request for new enhancement to Report like customized titles for this Report like Project Name, Release name and Cycle name and execution start & end time along with timezone

Hi - This report is really great. I was wondering if we can have additional details on the Report like below

  • Project/Application Name: 'XYZ Automation',
  • Release Name: 'ABC',
  • Cycle Name: '2',
  • Execution Start Time: Nov 13th 2017, 02:31 PM EST
  • Execution End Time: Nov 13th 2017, 02:56 PM EST

User should be allowed to pass this data as below

const report = require('multiple-cucumber-html-reporter');
report.generate({
      automaticallyGenerateReport: true,
      removeExistingJsonReportFile: true,
      removeOriginalJsonReportFile: true,
      openReportInBrowser: true,
      saveCollectedJSON: true,
      jsonOutputPath: './reports/report-plugin-json-output-folder/',
      reportPath: './reports/protractor-multiple-cucumber-html-report/',
      disableLog: false,
      metadataKey: 'deviceProperties',
      Project/Application Name : 'XYZ Automation',
      Release Name: 'ABC',
      Cycle  : '2',
      ShowExecutionTimeFlag: true  
      customizedReportName : 'Multi Browser Protractor Cucumber HTML Report'
});

Also if possible customized name for the Report file as mentioned above - customizedReportName

Thanks

Problem with maxInstances>1

Hi,

when using maxInstances with a number > 1 the AfterFeature Hook tries to create the report every time a browser instance is closed. The problem is, if other instances are still running, the JSON File ist not yet finished and the parser throws an error instead of ignoring the files with size = 0 (these files are not yet finished).

14:37:09] E/launcher - e2e\utils\hooks.js:17 C:\Project\e2e\reports\multi\json_cucumber_chrome.13040.json: Unexpected end of JSON input
[14:37:09] E/launcher - SyntaxError: e2e\utils\hooks.js:17 C:\Project\e2e\reports\multi\json_cucumber_chrome.13040.json: Unexpected end of JSON input
at JSON.parse ()
at Object.readFileSync (C:\Project\node_modules\jsonfile\index.js:70:17)
at files.map.file (C:\Project\node_modules\multiple-cucumber-html-reporter\lib\collect-jsons.js:22:32)
at Array.map (native)
at collectJSONS (C:\Project\node_modules\multiple-cucumber-html-reporter\lib\collect-jsons.js:22:11)

Presenting total number of passed/failed tests in addition to percentage

Hi

Thanks for creating awesome reporter. You did a great job. I have small suggestion that might be helpful.
When I check the reports I am often interested in total number of failed tests/scenarios. Currently I can see only percentage values. I noticed that percentages are presented in table and also on the graph tooltip. I wonder if it is possible to present total number of passed/failed/etc test cases on the tooltip. That would be consistent with total number of all test/scenarios that are presented in the middle of the graph and give possibility to assess results in different dimension.

obraz

Show table in steps

The report don't show the table of each step.

Image with the step:

report_issue3

Image with the report without the table:

report_issue2

Multiple cucumber_output (json) into Single Report with different Metadata

Hi @wswebcreation

Now I have 2 set of test executions

  1. puppeteer chrome
  2. puppeteer firefox
    both produce 2 different JSON output.

Able to produce a single report by pointing outputDir.

But I want to feed different metadata for each output.

What I see we have only metadata which applied for all output files

I made a small change in collect-json.js to adopt different metadata for each output file

metadata sample

metadata: {
    "cucumber_report_chrome": {
      browser: {
        name: 'chrome',
        version: '68.0.3419.0'
      },
      device: 'Local Test Machine',
      platform: {
        name: 'linux',
        version: 'x86_64'
      },
    },
    "cucumber_report_firefox": {
      browser: {
        name: 'firefox',
        version: '65.0'
      },
      device: 'Local Test Machine',
      platform: {
        name: 'linux',
        version: 'x86_64'
      },
    }
}

cucumber_report_chrome
cucumber_report_firefox
these are output filenames (without json) which produced by cucumberjs execution.

How do you see this? should raise the PR for the changes.

I made it as additional if block to accept if there is multiple metadata otherwise it will go as global one which applied all the files.

( I don't find an easy way to add metadata inside cucumberjs report )

Allowing custom metadata

The code that Cucumber tests in my project does not have anything to do with browsers, devices or OS. It does however have other environment variables that change between different features.

It would be nice if there was a way to define custom metadata instead of the static metadata currently present.

I am willing to create a PR that updates the project to allow for this if this is not already a feature of the project that I somehow missed.

report failed to generate on big json

$ rimraf st-coverage && node reports/generate.js
lodash.templateSources[8]:244
((__t = ( step.image[i] )) == null ? '' : __t) +
^

RangeError: Invalid string length
at eval (lodash.templateSources[8]:244:48)
at arrayEach (/Users/muthu/Documents/office/workspace/ui-st-automation/node_modules/multiple-cucumber-html-reporter/node_modules/lodash/lodash.js:508:11)
at Function.forEach (/Users/muthu/Documents/office/workspace/ui-st-automation/node_modules/multiple-cucumber-html-reporter/node_modules/lodash/lodash.js:9334:14)
at eval (lodash.templateSources[8]:78:4)
at arrayEach (/Users/muthu/Documents/office/workspace/ui-st-automation/node_modules/multiple-cucumber-html-reporter/node_modules/lodash/lodash.js:508:11)
at Function.forEach (/Users/muthu/Documents/office/workspace/ui-st-automation/node_modules/multiple-cucumber-html-reporter/node_modules/lodash/lodash.js:9334:14)
at eval (lodash.templateSources[8]:10:4)
at suite.features.forEach.feature (/Users/muthu/Documents/office/workspace/ui-st-automation/node_modules/multiple-cucumber-html-reporter/lib/generate-report.js:505:78)
at Array.forEach ()
at _createFeatureIndexPages (/Users/muthu/Documents/office/workspace/ui-st-automation/node_modules/multiple-cucumber-html-reporter/lib/generate-report.js:487:20)

Do you recognize this issue?

Allow some way to customize attachment names

Hi! Found reports generated by this project really cool. I'm planning to have multiple attachments of various types for some scenario steps. As of now they are all named by their type (Screenshot+, Show info+, etc)

Would be great if there will be a possibility to override these default names. When having multiple attachments of the same type it would be super helpful to know what's in each one of them.

I expect this to require some work for cucumber runners when generating reports, but for example with cucumber-js I believe extra fields could be easily added to report json using custom formatter.

Right now we have:

{
    "data":"",
    "media": {
        "encoding": "base64",
        "type": "image/png"
    }
}

Maybe support something like this?

{
    "data":"",
    "media": {
        "encoding": "base64",
        "type": "image/png"
    },
    "name": "My custom attachment"
}

or this:

{
    "data":"",
    "media": {
        "encoding": "base64",
        "type": "image/png",
        "name": "My custom attachment"
    }
}

not sure right now which one of these options would be cleaner for cucumber integration

After Features hook

Hi,
I have this AfterFeatures hook but it isn't displaying any report..

image

Any idea why?

Error on file lock when multiple instances are running parallel

Hello,

we having a Problem since some weeks. We updated some of our node-modules recently and since then we're getting some errors when the report is created.
We are running multiple instances parallel. We think the problem is, when two or more instances are trying to create the report nearly at the same time:

[chrome #01-118] [08:41:46] I/plugins - �[31m 	 Fail:  protractor-multiple-cucumber-html-reporter-plugin Runtime �[39m
[chrome #01-118] [08:41:46] E/plugins - 		Failure during postResults: EBUSY: resource busy or locked, unlink 'C:\dev\clientapplication\e2e\reports\assets\fonts\fontawesome-webfont.woff'
[chrome #01-118] [08:41:46] E/plugins - 		Error: EBUSY: resource busy or locked, unlink 'C:\dev\clientapplication\e2e\reports\assets\fonts\fontawesome-webfont.woff'
[chrome #01-118] 		    at Object.unlinkSync (fs.js:949:3)
[chrome #01-118] 		    at mayCopyFile (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:69:8)
[chrome #01-118] 		    at onFile (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:60:12)
[chrome #01-118] 		    at getStats (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:51:39)



[chrome #01-118] 		    at startCopy (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:41:10)
[chrome #01-118] 		    at fs.readdirSync.forEach.item (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:142:5)
[chrome #01-118] 		    at Array.forEach (<anonymous>)
[chrome #01-118] 		    at copyDir (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:141:23)
[chrome #01-118] 		    at mayCopyDir (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:131:10)
[chrome #01-118] 		    at onDir (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:120:12)
[chrome #01-118] 		    at getStats (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:48:32)
[chrome #01-118] 		    at startCopy (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:41:10)
[chrome #01-118] 		    at fs.readdirSync.forEach.item (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:142:5)
[chrome #01-118] 		    at Array.forEach (<anonymous>)
[chrome #01-118] 		    at copyDir (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:141:23)
[chrome #01-118] 		    at mayCopyDir (C:\dev\clientapplication\node_modules\multiple-cucumber-html-reporter\node_modules\fs-extra\lib\copy-sync\copy-sync.js:131:10)

Feature being shown as passed when there is no code written for it

It would be great to have the Feature Status shown as Undefined or Pending
(i.e. 1. if there is a feature file WITHOUT a step_definition file then it should show as Undefined
2. if there is a feature file WITH a step_definition file but no REAL code then it should show Pending)
in addition to how it works now.

Empty .json files might be skipped instead of making reporter crash

While having several cucumbers running, an empty .json file is there.
So when creating the report before one of tests finishes (or after a crash), the reporter crashes too (Unexpected end of JSON input).

Technically an empty string is invalid JSON, so its sort of expected

JSON.parse('');
VM59:1 Uncaught SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at <anonymous>:1:6

However, a way to ignore empty (non-finalized) files would be very welcome, for my use case where several cucumbers run at the same time.

[openReportInBrowser] Never call callback on Mac os

Environment (please complete the following information):

  • multiple-cucumber-html-reporter: latest
  • Node.js version:v8.10.0
  • NPM version: 5.8.0
  • Platform name and version: MacOs
  • Cucucmber version: 4.0.0

Config of custom framework + multiple-cucumber-html-reporter
const options = {
jsonDir: REPORTS_PATH + "/",
reportPath: REPORTS_PATH + "/",
openReportInBrowser: true,
displayDuration: true,
customMetadata: true,
saveCollectedJSON: true,
};

Describe the bug
After generating a report and open the browser, process got stuck and never terminate the node process on MacOS

This is the relevant ticket for opn package sindresorhus/open#91
issue resolved on this ticket sindresorhus/open#92

this is the place where it got stuck https://github.com/wswebcreation/multiple-cucumber-html-reporter/blob/master/lib/generate-report.js#L150

To Reproduce

  1. configure openReportInBrowser: true,
  2. Generate report

[Include code or an example repository that can easily be set up]

Expected behavior
Node process should be terminated after opening the browser without CTRL + C. open browser [opn package], promise should be resolved on MacOS.

generate-report.js calculates time wrongly as Cucumber 4 returns time in nano seconds

Environment (please complete the following information):

  • multiple-cucumber-html-reporter: 1.10.1
  • Node.js version: 10.1.0
  • NPM version: 5.6.0
  • Platform name and version: Ubuntu
  • Cucucmber version: 4.2.1

Config of TestCafe + multiple-cucumber-html-reporter
"node report-generator.js",

Describe the bug
When we create the report, though the tests run only for 10-15 seconds, the duration is displayed in hours in the report.
Digging down the issue, I found that the below code considers the time in MS though cucumber returns in nano second
return moment.utc(durationInMS ? ns : ns / 1000000).format('HH:mm:ss.SSS');
If I change the code to the one as mentioned below, all works fine
return moment.utc( ns / 1000000).format('HH:mm:ss.SSS');

To Reproduce
Run the tests with Cucumber 4 version

[Include code or an example repository that can easily be set up]

Expected behavior
Not sure why the durationInMS is not failing and ns condition is getting invoked to convert nano to milli seconds

When running scenarios in parallel, scenarios data is overwritten in the json files so report only shows half information

I am running scenarios in parallel on Browser Stack using 4 different feature files which has 2 scenarios (Examples) in each file.
So report is showing as 4 features and 4 scenarios which is wrong. Expected is it should 4 features & 8 scenarios.

Below are the configuration details:

{
 "cucumber": "^3.2.0",
 "protractor": "^5.2.2",
 "protractor-cucumber-framework": "^4.1.1",
"multiple-cucumber-html-reporter": "^1.4.1",
"protractor-multiple-cucumber-html-reporter-plugin": "^1.3.0",
nodeJs : V7.9.0
}

Sample Feature file

Feature: **************************
  **********************************
  Background: ******************************
    ************ "****" ************************
  Scenario Outline: ************************
    Given ************ "****" ************************
    When U************ "****" ","<abc>","<xyz>","<pqr>","<rst>"
    Then User should complete the "****" ********* "<lmn>","<opq>" **********

  Examples:
  |abc         |xyz             |pqr             |rst        | lmn        |  opq    |
  |1             |4                 |7                |10        | 12          |  25      |
  |2             |5                 |8                |11        | 6            |  25      |

Here feature name is same & platform & browser combination is also same. But since I am running 8 scenarios in parallel, I am expecting the report should show 4 features & 8 scenarios on dashboard. And after clicking on each feature, it should show 2 scenarios in it.
However currently if I click on feature file, it only shows 1 scenario. It means the json files which are generated are overwritten for the same features & browser/os combination, even though they ran for different scenario.
Note : There is no issue if I run directly features in parallel. This issue is coming only when I am running scenarios in parallel. Attaching the more files for clear understanding.

Please let me know if you need more data in order to fix this issue. Thanks in advance !!!

TypeError: CollectJSONS

When running wdio with:
onComplete: () => {report.generate({jsonDir: './report/',reportPath: './report/' });}

The report.json, produced by wdio, is correctly loaded:
const data = fs.readFileSync(file).toString() || "[]"; (collect-json.js:22)

Yet a TypeError: JSON.parse(...).map is not a function is received. (collect-json.js:23)

Any help would be appreciated.

Inconsistency Git Repo and NPM Package

When generating a report while using the package from NPM (^1.10.0) the duration of fields is incorrectly displayed (all set to 00:00:00:00.000) when using durationInMS set to true.

When trying to replicate this issue with the code pulled from Github the durations were correctly set.

I am not sure where exactly the bug is located, however I think that some sort of synchronization issue is present.

Invalid characters being reported

I see the following in the report:

[
"��^�,e",
[
{
"key": val
}
]
]

This happens for the following cucumber JSON results:
"embeddings": [
{
"data": "orderCxl",
"mime_type": "text/plain"
},
{
"data": "[{"key":val}]",
"mime_type": "application/json"
}
]

It only happens when the data is orderCxl. For any other value for the first data, it reports correctly.

Scenario names within a feature file have duplicate names in the html report

Scenario names within a feature file have duplicate names in the html report.
Actually, the name of the last scenario executed in a feature file is used as name of all the scenarios in the report. Checked the JSON file and see that all scenario names are duplicate. This issue need fixing on priority.

Unable to generate report getting following error

Environment (please complete the following information):

  • multiple-cucumber-html-reporter: 1.11.4
  • Node.js version: v10.4.0
  • NPM version: 6.1.0
  • Platform name and version: MacOsX
  • Cucucmber version: 5.0.2

Config of wd + cucumber + multiple-cucumber-html-reporter
var reporter2 = require('multiple-cucumber-html-reporter');

Describe the bug
Unable to generate report from a single json file available at the path, was working previously,
able to gererate html for same .json by cucumber-html-reporter

Expected behavior
Should be able to generate report as the same cucumber-report.json is generating report by another npm package

Log

TypeError: JSON.parse(...).map is not a function
at files.map.file (.../node_modules/multiple-cucumber-html-reporter/lib/collect-jsons.js:23:30)
at Array.map ()
at collectJSONS (.../node_modules/multiple-cucumber-html-reporter/lib/collect-jsons.js:20:15)
at Object.generateReport [as generate] (.../node_modules/multiple-cucumber-html-reporter/lib/generate-report.js:67:23)
at .../runtime/world.js:244:27
at process._tickCallback (internal/process/next_tick.js:61:11)

Additional context
Using a customised framework using cucumber+wd

Export parsing functions

Hi again

I am using CucumberJS Slack Bot and I noticed that it incorrectly parses Cucumber JSON report. I would like to update this module and reuse parsing functions from multiple-cucumber-html-reporter. I thought that add dependency to multiple-cucumber-html-reporter and use its parse functions would be a good idea but as far as I know Java parsing functions are not exported. I would like to ask to export those functions so I can easily use them outside of reporter or propose some other way to reuse those functions.

Jacek

Background tasks are considered as scenarios

In my cucumber feature files, there is a Background scenario in most cases, which runs before each scenario (similar to @BeforeMethod in TestNG).

The report generated by multiple-cucumber-html-reporter considers these tasks as scenarios as well, so the combined report shows a much higher total scenario count than there actually is.

Is there any way to exclude the Background scenarios?

Show duration

It would be great if the report can show duration at step, scenario and feature levels.
Other reports provide the facility to show the duration. This helps to evaluate the performance of api/ui.

Not able to view SCENARIO OUTLINE example data set value in report html steps

I am not seeing the data variables in their respective scenario steps while reading the cucumber html report.

The Examples value are appearing for the scenario outline steps, if the data is passed inline..
like below. Here and values are getting replaced with the corresponding iteration data on each individual scenario
Scenario Outline:
Given I login as a user "" and password ""
Examples:
|username|password|
|userOne|passOne|
|userTwo|passTwo|

But the Scenario Outline Example data is not appearing and the placeholder appears null.
Scenario Outline:
Given I login to the application with the below data
|getUsername|getPassword|
|||
Examples:
|username|password|
|userOne|passOne|
|userTwo|passTwo|

image

Combining reports from initial run and rerun

Hi

I wonder if there is a way to combine results from cucumber initial run and rerun in a way that most recent results are presented in the report. If a test passed during the rerun I would like reporter to be smart enough to override previous failure.

I would be grateful for answer

Jacek

Possibility to add global metadata

Hi,

insead of manipulating each JSON File before creating the report it would be much easier (like in cucumber-html-report) to set the metadata for all files via options.

Code from cucumber-html-report:

var options = {
jsonFile: 'test/report/cucumber_report.json',
output: 'test/report/cucumber_report.html',
metadata: {
"browser": {
"name": "chrome",
"version": "58"
},
"device": "desktop",
"platform": {
"name": "Windows",
"version": "7"
}
}
};

Why After hook is now shown on report ?

Currently the reporter ignores hooks that fails. This cause some confusion to the users, because the CI is broken, but the report is green.

Can we add a option to consider these steps ?

External CSS and JS dependencies blocked in stricter CI environments

Environment:

  • Node.js version: 8.9.3
  • NPM version: 5.5.1
  • webdriver.io version: 4.13.1
  • wdio-cucumber-framework version: 1.1.0 (I believe this bug is independent of cucumber framework)
  • wdio-multiple-cucumber-html-reporter version: 0.1.3

Config of webdriver.io and the reporter

reporters: ["dot", "junit", "multiple-cucumber-html"],
    
reporterOptions: {
    outputDir: "./reports",
    junit: {
        outputDir: "./reports/"    
    },
    htmlReporter: {
        jsonFolder: "./reports/",
        reportFolder: "./reports/"
    }
},

Description
The external CSS/JS dependencies of the resulting index.html file are not compatible with a stricter CI environment when loading up the report inside that environment.

Depending on your CI configuration and the security levels of your CI environment you might set up the HTTP Content-Security-Policy response header to self, which in turn refers to the origin from which the protected document (in our case the html test report) is being served, and prevents other sources from being loaded.

I'm not sure about the expected behaviour in this case, but it impacts anyone trying to use the plugin in a more closed CI environment. My suggestions for a possible fix would be:

  • to include these libraries somehow as part of the reporter, which doesn't seem to be a positive fix;
  • allow the user to somehow point at them in a different way via configuration;
  • or allow the user to define a custom html template?

Snapshots
screen shot 2018-08-14 at 11 26 35

/cc @wswebcreation

Pragmatically add metadata within cucumber?

Using cucumber 4 (seems no reason why that wouldnt work like 3?), so I have a post cucumber script to translate json to html.

I'm a bit stuck trying to get my environment variables (browser name, app version etc.) into the cucumber json file DURING cucumber execution.

I don't think cucumber offers an attach, or any way to just fiddle yourself with the testcase to get the metadata in the json?
Do I have to create my own formatter - forked from the json formatter?

An example, documentation or formatter would really help me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.