CucumberJS JSON Reporter
wdio-cucumberjs-json-reporter is a 3rd party package, for more information please see GitHub | npm A WDIO reporter that creates CucumberJS JSON files for WebdriverIO V6+
THIS MODULE CAN ONLY WORK WITH WebdriverIO V6+! For V5 please check the docs here and use version 1.3.0
THIS MODULE IS NOT A REPLACEMENT OF wdio-multiple-cucumber-html-reporter. THAT MODULE ONLY SUPPORTS WEBDRIVERIO V4 AND ALSO CREATES A REPORT. THIS MODULE ONLY CREATES A JSON, NO REPORT!!
#
What does it doThis reporter will generate a Cucumber JSON file for each feature that is being tested. The JSON file can be used with whatever report you want to use like for example multiple-cucumber-html-reporter.
It will also add metadata about the running instance to the feature file and last but not least, it will give you the opportunity to add attachments to the JSON output.
#
InstallationThe easiest way is to keep wdio-cucumberjs-json-reporter
as a devDependency in your package.json
.
You can simple do it by:
so it will automatically be added to your package.json
Instructions on how to install WebdriverIO
can be found here.
#
ConfigurationConfigure the output directory and the language in your wdio.conf.js file:
DON'T USE BOTH WAYS OF ADDING THE REPORTER, THIS IS JUST AN EXAMPLE!
#
OptionsjsonFolder
#
- Type:
String
- Mandatory: No
- Default:
.tmp/json/
The directory where the JSON files, generated by this report, will be stored, relative from where the script is started.
N.B.: If you use a npm script from the command line, like for example npm run test
the jsonFolder
will be relative from the path
where the script is executed. Executing it from the root of your project will also create the jsonFolder
in the root of you project.
language
#
- Type:
String
- Mandatory: No
- Default:
en
The language in which the Gherkin scenarios are written (defaults to English). The list of language codes and its keywords can be found here.
#
MetadataNote:\ This is currently not supported if you are using WebdriverIO V6, WebdriverIO V5 still supports this
As said, this report can automatically store the metadata of the current machine / device the feature has been executed on.
To customize this you can add IT by adding the following object to your capabilities
The metadata object needs to have the
cjson
prefix, otherwise it will not work!
#
Metadata valuesmetadata.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
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.
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
.
metadata.platform.name
#
- Type:
string
- Possible values:
windows | osx | linux | ubuntu | android | ios
metadata.platform.version
#
- Type:
string
e.g.: The version of the platform
If you don't provide the
browser
-object in the metadata, this module will automatically determine it for you. It will always override it with the most recent value it can determine.
If you don't provide the
device
and or theplatform
-object it will be defaulted for you tonot known
If you don't provide a
browser.name
or abrowser.version
the module will try to determine this automatically.
#
AttachmentYou have the option to attach data to the JSON file in all these hooks / steps:
- Before(All)
- After(All)
- Given
- When
- Then
- And
The only thing you need to provide is the following code in your step files.
#
Use it with multiple-cucumber-html-reporterThe previous module for WebdriverIO V4, wdio-multiple-cucumber-html-reporter,
had a build in connection with the multiple-cucumber-html-reporter-module. This is not the case for this
reporter because the new setup of WebdriverIO V5 is based on a instance which doesn't allow me to use the onPrepare
and onComplete
hook.
If you still want to use the multiple-cucumber-html-reporter-module you can add the following to your config file.
Install the module with
Maybe even install
fs-extra
to remove the report folder before you start all sessions.Add this to your configuration file