cucumber-html-reporter
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -0,1 +1,21 @@ | ||
### 0.1.4 (2016-06-28) | ||
#### Enhancements | ||
* Using `path` instead of separators to make platform agnostic | ||
* Updated tests `hooks` | ||
* README updated with the instructions on how to integrate reporter to the cucumber hooks | ||
### 0.1.3 (2016-06-27) | ||
#### Bug fixes | ||
* Fixed a bug in template path | ||
* README updated | ||
### 0.1.1 (2016-06-27) | ||
@@ -2,0 +22,0 @@ |
@@ -7,2 +7,3 @@ 'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
@@ -52,7 +53,4 @@ var generateReport = function(options) { | ||
if (options.output.lastIndexOf('/') > -1) { | ||
screenShotDirectory = options.output.substring(0, options.output.lastIndexOf('/')) + '/screenshot/'; | ||
} else { | ||
screenShotDirectory = 'screenshot/'; | ||
} | ||
screenShotDirectory = options.output ? path.join(options.output, '..', 'screenshot') : 'screenshot/'; | ||
featureOutput.forEach(function(feature) { | ||
@@ -94,4 +92,4 @@ feature.relativeFolder = feature.uri.slice(rootDir.length); | ||
} | ||
name = name + Math.round(Math.random() * 10000) + '.png'; //randomize the file name | ||
var filename = screenShotDirectory + name; | ||
name = name + '_' + Math.round(Math.random() * 10000) + '.png'; //randomize the file name | ||
var filename = path.join(screenShotDirectory, name); | ||
fs.writeFile(filename, new Buffer(embedding.data, 'base64'), function(err) { | ||
@@ -179,6 +177,6 @@ if (err) { | ||
//use custom template based on user's requirement | ||
if (fs.existsSync(options.templateDir + '/' + name)) { | ||
return options.templateDir + '/' + name; | ||
if (options.templateDir && fs.existsSync(path.join(options.templateDir, name))) { | ||
return path.join(options.templateDir, name); | ||
} else { | ||
return 'node_modules/cucumber-html-reporter/templates/' + options.theme + '/' + name; | ||
return path.join(__dirname, '..', 'templates', options.theme, name); | ||
} | ||
@@ -185,0 +183,0 @@ } |
{ | ||
"name": "cucumber-html-reporter", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Generates Cucumber HTML reports in three different themes", | ||
@@ -44,3 +44,2 @@ "main": "index.js", | ||
"commondir": "^1.0.1", | ||
"fs": "0.0.2", | ||
"js-base64": "^2.1.9", | ||
@@ -47,0 +46,0 @@ "jsonfile": "^2.3.1", |
@@ -45,4 +45,20 @@ cucumber-html-reporter | ||
> Plugin the above code to the cucumber's `AfterFeatures` hook | ||
> Plugin the above code to the cucumber's `AfterFeatures` hook as shown in [test/features/step_definitions/hooks][7] and pick the theme you are interested in. | ||
> This module converts Cucumber's JSON format to HTML reports. In order to generate JSON formats, run the Cucumber to create the JSON format and pass the file name to the formatter as shown below, | ||
``` | ||
$ cucumberjs test/features/ -f json:test/report/cucumber_report.json | ||
``` | ||
> Multiple formatter are also supported, | ||
``` | ||
$ cucumberjs test/features/ -f pretty -f json:test/report/cucumber_report.json | ||
``` | ||
> Are you using cucumber with other frameworks or running [cucumber-parallel][6]? Pass relative path of JSON file to the `options` as shown [here][7] | ||
## Options | ||
@@ -87,2 +103,4 @@ | ||
[5]: http://htmlpreview.github.io/?https://github.com/gkushang/grunt-cucumberjs/blob/cucumber-reports/test/cucumber-reports/cucumber-report-simple.html "Simple Theme Reports" | ||
[6]: https://www.npmjs.com/package/cucumber-parallel "cucumber-parallel" | ||
[7]: https://github.com/gkushang/cucumber-html-reporter/blob/develop/test/features/step_definitions/hooks.js#L13-L44 | ||
@@ -14,6 +14,7 @@ 'use strict'; | ||
this.registerHandler('AfterFeatures', function(features, callback) { | ||
var theme = { | ||
bootstrap: 'templates/bootstrap', | ||
foundation: 'templates/foundation', | ||
simple: 'templates/simple' | ||
bootstrap: 'bootstrap', | ||
foundation: 'foundation', | ||
simple: 'simple' | ||
}; | ||
@@ -23,15 +24,20 @@ | ||
return { | ||
templateDir: theme.template, //this is required only for unit-test of this module, otherwise pass `theme: [value]` as an option | ||
output: 'test/report/cucumber_report_' + theme.name + '.html', | ||
theme: theme, | ||
jsonFile: 'test/report/cucumber_report.json', | ||
theme: theme.theme, | ||
output: 'test/report/cucumber_report_' + theme + '.html', | ||
reportSuiteAsScenarios: true | ||
}; | ||
} | ||
reporter.generate(getOptions({template: theme.bootstrap, name: 'bootstrap', theme: 'bootstrap'})); | ||
reporter.generate(getOptions({template: theme.foundation, name: 'foundation'})); | ||
reporter.generate(getOptions({template: theme.simple, name: 'simple'})); | ||
//Generate Bootstrap theme report | ||
reporter.generate(getOptions(theme.bootstrap)); | ||
//Generate Foundation theme report | ||
reporter.generate(getOptions(theme.foundation)); | ||
//Generate Simple theme report | ||
reporter.generate(getOptions(theme.simple)); | ||
//assert reports | ||
assertHtmlReports(); | ||
@@ -38,0 +44,0 @@ |
181286
6
105