You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-16Lines changed: 46 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,11 @@
1
1
# gulp-protractor-cucumber-html-report
2
2
3
-
> Generate html report from JSON file returned by cucumber js json formatter
4
-
>
3
+
> Generate html report from JSON file returned by CucumberJS json formatter
4
+
5
+
This is a stand-alone fork from [grunt-protractor-cucumber-html-report](https://github.com/robhil/grunt-protractor-cucumber-html-report)
5
6
6
7
## Getting Started
7
-
This plugin requires Grunt`~3.9.0`
8
+
This plugin requires Gulp`~3.9.0`
8
9
9
10
If you haven't used [Gulp](http://gulpjs.com/) before, be sure to check out the [Getting Started](https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md) guide, as it explains how to create a Gulpfile as well as install and use Gulp plugins. Once you're familiar with that process, you may install this plugin with this command:
10
11
@@ -21,30 +22,59 @@ var reporter = require('gulp-protractor-cucumber-html-report');
21
22
## The "protractor-cucumber-html-report" task
22
23
23
24
### Overview
24
-
In your project's Gulpfile, add a section named `protractor-cucumber-html-report` to the data object passed into `grunt.initConfig()`.
25
+
In your project's Gulpfile, you can use the reporter in your pipeline as follows:
25
26
26
27
```js
27
-
grunt.initConfig({
28
-
protractor_cucumber_html_report: {
29
-
options: {
30
-
// Task-specific options go here.
31
-
},
32
-
your_target: {
33
-
// Target-specific options go here.
34
-
},
35
-
},
36
-
});
28
+
gulp.src('./cucumber-test-results.json')
29
+
.pipe(protractorReport({
30
+
dest:'reports/'
31
+
}));
37
32
```
38
33
34
+
### Saving CucumberJS json to disk when using Protractor
35
+
If you're using Protractor in combination with CucumberJS there currently is [no way](https://github.com/cucumber/cucumber-js/issues/90) to save the CucumberJS JSON output to a file.
36
+
37
+
It is however possible to add a listener to the CucumberJS JSON formatter and save it to a file manually. The following hook can be added to your project and included to your Protractor configuration.
38
+
39
+
```js
40
+
module.exports=functionJsonOutputHook() {
41
+
var Cucumber =require('cucumber');
42
+
var JsonFormatter =Cucumber.Listener.JsonFormatter();
43
+
var fs =require('fs');
44
+
var path =require('path');
45
+
46
+
JsonFormatter.log=function (json) {
47
+
fs.writeFile(path.join(__dirname, './reports/cucumber-test-results.json'), json, function (err) {
Above snippet will hook into the CucumberJS JSON formatter and save the JSON to a file called 'cucumber-test-results.json' in the ./reports folder (relative from this file's location)/
58
+
59
+
### Setting up Protractor, CucumberJS and the JSON listener
60
+
61
+
In your protractor.conf.js add a reference to the hook listener (as shown above). In this example the file is found in 'support/'. Also make sure to set the output format to 'json'.
62
+
63
+
```js
64
+
cucumberOpts: {
65
+
require: ['steps/*.js', 'support/*.js'],
66
+
format:'json'
67
+
},
68
+
```
39
69
### Options
40
70
41
-
#### dest
71
+
#### options.dest
42
72
Type: `String`
43
73
Default value: `'.'`
44
74
45
75
The output directory for the HTML report relative from the Gulpfile
0 commit comments