Skip to content

Commit c2ef652

Browse files
nicolaspayotMarc Rooding
authored andcommitted
Fix example with fs-extra in README
1 parent b49af64 commit c2ef652

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ gulp.src('./cucumber-test-results.json')
4848
```
4949

5050
#### Saving CucumberJS JSON to disk when using Protractor
51-
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.
52-
51+
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.
52+
5353
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.
5454

5555
I've added 2 different hooks which basically do the same but one of the 2 requires you to add an extra dependency to your package.json. You're free to choose which one you prefer.
@@ -111,20 +111,20 @@ var Cucumber = require('cucumber');
111111

112112
var JsonFormatter = Cucumber.Listener.JsonFormatter();
113113

114-
var reportFile = ''../../reports/cucumber-test-results.json';
114+
var reportsDir = path.join(__dirname, '../../reports');
115+
var reportFile = path.join(reportsDir, 'cucumber-test-results.json');
115116

116117
module.exports = function JsonOutputHook() {
117118
JsonFormatter.log = function (json) {
118-
var destination = path.join(__dirname, reportFile);
119-
fs.open(destination, 'w+', function (err, fd) {
119+
fs.open(reportFile, 'w+', function (err, fd) {
120120
if (err) {
121-
fs.mkdirsSync(destination);
122-
fd = fs.openSync(destination, 'w+');
121+
fs.mkdirsSync(reportsDir);
122+
fd = fs.openSync(reportFile, 'w+');
123123
}
124124

125125
fs.writeSync(fd, json);
126126

127-
console.log('json file location: ' + destination);
127+
console.log('json file location: ' + reportFile);
128128
});
129129
};
130130

@@ -174,22 +174,22 @@ This is all that's required to add the saved screenshots to the HTML report.
174174
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.
175175

176176
## Copyright
177-
177+
178178
Copyright for portions of project [gulp-protractor-cucumber-html-report](https://github.com/mrooding/gulp-protractor-cucumber-html-report) are held by Robert Hilscher, 2015 as part of project [grunt-protractor-cucumber-html-report](https://github.com/robhil/grunt-protractor-cucumber-html-report). All other copyright for project [gulp-protractor-cucumber-html-report](https://github.com/mrooding/gulp-protractor-cucumber-html-report) are held by Marc Rooding, 2015.
179179

180180
## Release History
181181
0.0.9:
182182
- The readme now contains 2 different ways to use the JSON output hook. One using an external library and one without.
183-
183+
184184
0.0.8:
185185
- Fix for not ignoring the After screenshot step
186-
186+
187187
0.0.7:
188188
- Empty After steps as a result of the screenshot hook will not be added to the HTML report anymore
189-
189+
190190
0.0.6:
191191
- Support for saving screenshots of failed scenarios
192-
192+
193193
0.0.5:
194194
- More robust creation of the output directory [thanks smuldr!](https://github.com/smuldr)
195195
- Fixed the HTML reporter when using multiple feature files

0 commit comments

Comments
 (0)