cucumber-html-reporter
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -0,1 +1,27 @@ | ||
### 0.2.8 (2016-08-30) | ||
#### Enhancements | ||
* Generate consolidated report from multiple JSON files: [PR#12](https://github.com/gkushang/cucumber-html-reporter/pull/12) | ||
* Provide the path of `jsonDir` to generate consolidated report, | ||
``` bash | ||
var reporter = require('cucumber-html-reporter'); | ||
... | ||
... | ||
var options = { | ||
theme: 'bootstrap', | ||
jsonDir: 'test/reports', | ||
output: 'test/report/cucumber_report.html', | ||
reportSuiteAsScenarios: true, | ||
launchReport: true | ||
}; | ||
reporter.generate(options); | ||
``` | ||
### 0.2.7 (2016-08-16) | ||
@@ -2,0 +28,0 @@ |
@@ -5,5 +5,5 @@ 'use strict'; | ||
var _ = require('lodash'); | ||
var commondir = require('commondir'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var jsonDir = require('./jsonDir'); | ||
var nodeFs = require('node-fs'); | ||
@@ -59,3 +59,2 @@ var open = require('open'); | ||
var featuresSummary = suite.features.summary; | ||
var rootDir = commondir(_.map(featureOutput, 'uri')); | ||
var screenShotDirectory; | ||
@@ -67,3 +66,2 @@ suite.reportAs = 'features'; | ||
featureOutput.forEach(function(feature) { | ||
feature.relativeFolder = feature.uri.slice(rootDir.length); | ||
feature.scenarios = {}; | ||
@@ -235,11 +233,10 @@ feature.scenarios.passed = 0; | ||
if(options.jsonDir) { | ||
jsonDir.collectJSONS(options) | ||
} | ||
if (isValidJsonFile()) { | ||
generateReport(options); | ||
launchReport(); | ||
if (callback) { | ||
callback(); | ||
} else { | ||
return true; | ||
} | ||
return callback ? callback() : true; | ||
} | ||
@@ -246,0 +243,0 @@ } |
{ | ||
"name": "cucumber-html-reporter", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"description": "Generates Cucumber HTML reports in three different themes", | ||
@@ -47,3 +47,3 @@ "main": "index.js", | ||
"chai": "^3.5.0", | ||
"commondir": "^1.0.1", | ||
"find": "^0.2.7", | ||
"js-base64": "^2.1.9", | ||
@@ -50,0 +50,0 @@ "jsonfile": "^2.3.1", |
@@ -5,3 +5,6 @@ cucumber-html-reporter | ||
[![Build Status](https://travis-ci.org/gkushang/cucumber-html-reporter.svg?branch=develop)](https://travis-ci.org/gkushang/cucumber-html-reporter) [![v](https://img.shields.io/npm/v/cucumber-html-reporter.svg)](https://www.npmjs.com/package/cucumber-html-reporter) | ||
[![Dependency Status](https://david-dm.org/gkushang/cucumber-html-reporter.svg)](https://david-dm.org/gkushang/cucumber-html-reporter) | ||
[![License](https://img.shields.io/npm/l/cucumber-html-reporter.svg)](LICENSE) | ||
Generate Cucumber HTML reports with pie charts | ||
@@ -47,2 +50,5 @@ > Available HTML themes: `['bootstrap', 'foundation', 'simple']` | ||
reporter.generate(options); | ||
//to generate consodilated report from multi-cucumber JSON files, please use `jsonDir` option instead of `jsonFile`. More info is available in `options` section below. | ||
``` | ||
@@ -82,3 +88,13 @@ | ||
#### `jsonDir` | ||
Type: `String` | ||
If you have more than one cucumber JSON files, provide the path of JSON directory. This module will create consolidated report of all Cucumber JSON files. | ||
e.g. `jsonDir: 'test/reports'` //where _reports_ directory contains valid `*.json` files | ||
N.B.: `jsonFile` takes precedence over `jsonDir`. We recommend to use either `jsonFile` or `jsonDir` option. | ||
#### `output` | ||
@@ -85,0 +101,0 @@ Type: `String` |
@@ -6,2 +6,4 @@ 'use strict'; | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var find = require('find'); | ||
@@ -24,7 +26,15 @@ var hooks = function() { | ||
var outputDirectory = 'test/report/'; | ||
var jsonFile = 'test/report/cucumber_report.json'; | ||
var jsonDir = 'test/report/multi'; | ||
function removeReports() { | ||
var files = find.fileSync(/\.html/, outputDirectory); | ||
files.map(function(file) { | ||
fs.unlinkSync(file); | ||
}); | ||
} | ||
function getOptions(theme) { | ||
return { | ||
theme: theme, | ||
jsonFile: 'test/report/cucumber_report.json', | ||
output: path.join(outputDirectory, 'cucumber_report_' + theme + '.html'), | ||
@@ -35,15 +45,50 @@ reportSuiteAsScenarios: true | ||
//Generate Bootstrap theme report | ||
reporter.generate(getOptions(theme.bootstrap)); | ||
function getJsonFileOptions(theme) { | ||
var options = getOptions(theme); | ||
options.jsonFile = jsonFile; | ||
return options; | ||
} | ||
//Generate Foundation theme report | ||
reporter.generate(getOptions(theme.foundation)); | ||
function getJsonDirOptions(theme) { | ||
var options = getOptions(theme); | ||
options.jsonDir = jsonDir; | ||
//Generate Simple theme report | ||
reporter.generate(getOptions(theme.simple)); | ||
return options; | ||
} | ||
function assertJsonFile() { | ||
//assert reports | ||
assertHtmlReports(outputDirectory); | ||
//Generate Bootstrap theme report | ||
reporter.generate(getJsonFileOptions(theme.bootstrap)); | ||
//Generate Foundation theme report | ||
reporter.generate(getJsonFileOptions(theme.foundation)); | ||
//Generate Simple theme report | ||
reporter.generate(getJsonFileOptions(theme.simple)); | ||
//assert reports | ||
assertHtmlReports(outputDirectory); | ||
} | ||
function assertJsonDir() { | ||
//Generate Bootstrap theme report | ||
reporter.generate(getJsonDirOptions(theme.bootstrap)); | ||
//Generate Foundation theme report | ||
reporter.generate(getJsonDirOptions(theme.foundation)); | ||
//Generate Simple theme report | ||
reporter.generate(getJsonDirOptions(theme.simple)); | ||
//assert reports | ||
assertHtmlReports(outputDirectory); | ||
} | ||
assertJsonFile(); | ||
removeReports(); | ||
assertJsonDir(); | ||
callback(); | ||
@@ -50,0 +95,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
397489
31
3359
167
3
1
0
+ Addedfind@^0.2.7
+ Addedfind@0.2.9(transitive)
+ Addedtraverse-chain@0.1.0(transitive)
- Removedcommondir@^1.0.1
- Removedcommondir@1.0.1(transitive)