Gathering detailed insights and metrics for wdio-cucumberjs-json-reporter
Gathering detailed insights and metrics for wdio-cucumberjs-json-reporter
Gathering detailed insights and metrics for wdio-cucumberjs-json-reporter
Gathering detailed insights and metrics for wdio-cucumberjs-json-reporter
npm install wdio-cucumberjs-json-reporter
54.4
Supply Chain
83.8
Quality
76.5
Maintenance
100
Vulnerability
91.6
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
24 Stars
598 Commits
32 Forks
11 Watching
10 Branches
24 Contributors
Updated on 25 Nov 2024
TypeScript (99.49%)
JavaScript (0.46%)
Shell (0.04%)
Cumulative downloads
Total Downloads
Last day
3.3%
10,006
Compared to previous day
Last week
12%
55,178
Compared to previous week
Last month
6.2%
213,906
Compared to previous month
Last year
31.4%
2,110,467
Compared to previous year
4
20
A WDIO reporter that creates CucumberJS JSON files for WebdriverIO v8 and up.
This 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.
The easiest way is to keep wdio-cucumberjs-json-reporter
as a devDependency in your package.json
.
1{ 2 "devDependencies": { 3 "wdio-cucumberjs-json-reporter": "^5.0.0" 4 } 5}
You can simple do it by:
1npm install wdio-cucumberjs-json-reporter --save-dev
so it will automatically be added to your package.json
Instructions on how to install WebdriverIO
can be found here.
Configure the output directory and the language in your wdio.conf.js file:
1export const config = { 2 // ... 3 reporters: [ 4 // Like this with the default options, see the options below 5 'cucumberjs-json', 6 7 // OR like this if you want to set the folder and the language 8 [ 'cucumberjs-json', { 9 jsonFolder: '.tmp/new/', 10 language: 'en', 11 }, 12 ], 13 ], 14 // ... 15}
DON'T USE BOTH WAYS OF ADDING THE REPORTER, THIS IS JUST AN EXAMPLE!
jsonFolder
String
.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
String
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.
disableHooks
boolean
false
Hook details will not be part of generation if this property sets to true
.
reportFilePerRetry
boolean
true
When a spec is retried the report will be appended to the existing report file from the previous tries if this property is set to false
.
Example:
['cucumberjs-json', { jsonFolder: '.tmp/new/', language: 'en', disableHooks:true}]
Note:
This is currently not supported if you are using WebdriverIO V6, WebdriverIO V5 still supports this and WebdriverIO V7 supports it again
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
1// Example wdio.conf.js 2export const config = { 3 //.. 4 capabilities: [ 5 { 6 browserName: 'chrome', 7 // Add this 8 'cjson:metadata': { 9 // For a browser 10 browser: { 11 name: 'chrome', 12 version: '58', 13 }, 14 // for an app 15 app: { 16 name: 'name.of.app.ipa', 17 version: '1.2.3', 18 }, 19 device: 'MacBook Pro 15', 20 platform: { 21 name: 'OSX', 22 version: '10.12.6' 23 } 24 }, 25 }, 26 ], 27};
The metadata object needs to have the
cjson
prefix, otherwise it will not work!
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
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.
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
.
metadata.platform.name
string
windows | osx | linux | ubuntu | android | ios
metadata.platform.version
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.
You have the option to attach data to the JSON file in all these hooks / steps:
The only thing you need to provide is the following code in your step files.
For ES Modules (ESM)
1import cucumberJson from 'wdio-cucumberjs-json-reporter'; 2 3// Attach a string (if no type is provided it will automatically default to `text/plain` 4cucumberJson.attach('just a string'); 5cucumberJson.attach('just a second string', 'text/plain'); 6 7// Attach JSON 8cucumberJson.attach({"json-string": true}, 'application/json'); 9 10// Attach a screenshot in a before hook 11cucumberJson.attach(await browser.takeScreenshot(), 'image/png');
For CommonJS (CJS)
1const { attach } = require("wdio-cucumberjs-json-reporter"); 2 3// Attach a string (if no type is provided it will automatically default to `text/plain` 4attach('just a string'); 5attach('just a second string', 'text/plain'); 6 7// Attach JSON 8attach({"json-string": true}, 'application/json'); 9 10// Attach a screenshot in a before hook 11attach(await browser.takeScreenshot(), 'image/png');
The 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
1npm install multiple-cucumber-html-reporter --save-dev
Add this to your configuration file
1import fs from 'node:fs/promises' 2// Import the module 3import { generate } from 'multiple-cucumber-html-reporter' 4 5// Example wdio.conf.js 6export const config = { 7 //.. 8 9 // ===== 10 // Hooks 11 // ===== 12 /** 13 * Gets executed once before all workers get launched. 14 */ 15 onPrepare: () => { 16 // Remove the `.tmp/` folder that holds the json and report files 17 return fs.rm('.tmp/', { recursive: true }); 18 }, 19 /** 20 * Gets executed after all workers got shut down and the process is about to exit. 21 */ 22 onComplete: () => { 23 // Generate the report when it all tests are done 24 generate({ 25 // Required 26 // This part needs to be the same path where you store the JSON files 27 // default = '.tmp/json/' 28 jsonDir: '.tmp/json/', 29 reportPath: '.tmp/report/', 30 // for more options see https://github.com/wswebcreation/multiple-cucumber-html-reporter#options 31 }); 32 } 33}
THIS MODULE CAN ONLY WORK WITH WebdriverIO V8+!
For V6 please check the docs here and use version 2.0.4
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!!
No vulnerabilities found.
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
dependency not pinned by hash detected -- score normalized to 1
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More