multiple-cucumber-html-reporter
Advanced tools
Comparing version 1.10.1 to 1.10.2
@@ -5,2 +5,8 @@ CHANGELOG | ||
======= | ||
<a name="1.10.2"></a> | ||
## [1.10.2](https://github.com/wswebcreation/multiple-cucumber-html-reporter/compare/v1.10.1...v1.10.2) (2018-07-03) | ||
### Bugfix | ||
* **fix:** Remove error thrown if no json files are found [54](https://github.com/wswebcreation/multiple-cucumber-html-reporter/issues/54), **tnx to [daviddekanter](https://github.com/daviddekanter)** | ||
<a name="1.10.1"></a> | ||
@@ -7,0 +13,0 @@ ## [1.10.1](https://github.com/wswebcreation/multiple-cucumber-html-reporter/compare/v1.10.0...v1.10.1) (2018-05-04) |
@@ -7,2 +7,3 @@ 'use strict'; | ||
const path = require('path'); | ||
const chalk = require('chalk'); | ||
@@ -19,38 +20,39 @@ module.exports = function collectJSONS(options) { | ||
if (files.length === 0) { | ||
throw new Error(`No JSON files found in '${options.jsonDir}'. NO REPORT CAN BE CREATED!`); | ||
} | ||
files.map(file => { | ||
// Cucumber json can be empty, it's likely being created by another process (#47) | ||
const data = fs.readFileSync(file).toString() || "[]"; | ||
JSON.parse(data).map(json => { | ||
if (options.metadata && !json.metadata) { | ||
json.metadata = options.metadata; | ||
} else { | ||
json = Object.assign({ | ||
"metadata": { | ||
"browser": { | ||
"name": "not known", | ||
"version": "not known" | ||
}, | ||
"device": "not known", | ||
"platform": { | ||
"name": "not known", | ||
"version": "not known" | ||
if (files.length > 0) { | ||
files.map(file => { | ||
// Cucumber json can be empty, it's likely being created by another process (#47) | ||
const data = fs.readFileSync(file).toString() || "[]"; | ||
JSON.parse(data).map(json => { | ||
if (options.metadata && !json.metadata) { | ||
json.metadata = options.metadata; | ||
} else { | ||
json = Object.assign({ | ||
"metadata": { | ||
"browser": { | ||
"name": "not known", | ||
"version": "not known" | ||
}, | ||
"device": "not known", | ||
"platform": { | ||
"name": "not known", | ||
"version": "not known" | ||
} | ||
} | ||
} | ||
}, json); | ||
} | ||
jsonOutput.push(json) | ||
}, json); | ||
} | ||
jsonOutput.push(json) | ||
}); | ||
}); | ||
}); | ||
if (options.saveCollectedJSON) { | ||
const file = path.resolve(options.reportPath, 'merged-output.json'); | ||
fs.ensureDirSync(options.reportPath); | ||
jsonFile.writeFileSync(file, jsonOutput, {spaces: 2}); | ||
if (options.saveCollectedJSON) { | ||
const file = path.resolve(options.reportPath, 'merged-output.json'); | ||
fs.ensureDirSync(options.reportPath); | ||
jsonFile.writeFileSync(file, jsonOutput, {spaces: 2}); | ||
} | ||
return jsonOutput; | ||
} | ||
return jsonOutput; | ||
console.log(chalk.yellow(`WARNING: No JSON files found in '${options.jsonDir}'. NO REPORT CAN BE CREATED!`)); | ||
return "[]"; | ||
}; |
{ | ||
"name": "multiple-cucumber-html-reporter", | ||
"version": "1.10.1", | ||
"version": "1.10.2", | ||
"description": "Generate beautifull cucumberjs reports for multiple instances (browsers / devices)", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -57,3 +57,3 @@ Multiple Cucumber HTML Reporter | ||
## Compatibility | ||
Multiple Cucumber HTML Reporter **now works with CucumberJS 1, 2 and 3**. | ||
Multiple Cucumber HTML Reporter **now works with CucumberJS 1, 2, 3 and 4**. | ||
@@ -63,2 +63,4 @@ ## Usage | ||
> **If you are using [webdriver.io](http://webdriver.io/) please check [WEBDRIVER.IO.MD](./docs/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.** | ||
@@ -306,3 +308,3 @@ | ||
const metadata = "metadata": { | ||
const metadata = { | ||
"browser": { | ||
@@ -405,18 +407,8 @@ "name": "chrome", | ||
Depending on the framework you are using, you can add a screenshot to the report like this | ||
> Check the framework you are using to attach screenshots to the JSON file. | ||
```javascript | ||
return driver.takeScreenshot() | ||
.then(function (buffer) { | ||
const decodedImage = new Buffer(screenshot.replace(/^data:image\/png;base64,/, ''), 'base64'); | ||
scenario.attach(decodedImage, 'image/png'); | ||
} | ||
``` | ||
### 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. | ||
```javascript | ||
scenario.attach('place here what you want to show in the report'); | ||
``` | ||
> Check the framework you are using to attach plain text to the JSON file. | ||
@@ -426,5 +418,3 @@ ### How to attach pretty JSON to HTML report | ||
```javascript | ||
scenario.attach(JSON.stringify(yourJsonObject)); | ||
``` | ||
> Check the framework you are using to attach JSON data to the JSON file. | ||
@@ -431,0 +421,0 @@ ## Changelog |
111166
896
429