Skip to content

Commit 6130bf3

Browse files
author
Marc Rooding
committed
Updated the README
1 parent cfa80d6 commit 6130bf3

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,31 @@ cucumberOpts: {
8383
},
8484
```
8585

86+
#### Screenshot support for failing scenarios
87+
88+
Adding screenshots of failing scenarios to the HTML report requires you to add an After hook. This can be easily achieved by creating a Javascript file with the following content:
89+
90+
```js
91+
module.exports = function TakeScreenshot() {
92+
this.After(function (scenario, callback) {
93+
if (scenario.isFailed()) {
94+
browser.takeScreenshot().then(function (png) {
95+
var decodedImage = new Buffer(png, 'base64').toString('binary');
96+
scenario.attach(decodedImage, 'image/png');
97+
98+
callback();
99+
});
100+
} else {
101+
callback();
102+
}
103+
});
104+
};
105+
```
106+
107+
If you're using the cucumberOpts as shown in *Setting up Protractor, CucumberJS and the JSON listener* then all you need to do is save this to a Javascript file in the 'support/' folder. Otherwise you have to change the cucumberOpts require property to load your hook.
108+
109+
This is all that's required to add the saved screenshots to the HTML report.
110+
86111
## Contributing
87112
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.
88113

@@ -91,4 +116,9 @@ In lieu of a formal styleguide, take care to maintain the existing coding style.
91116
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.
92117

93118
## Release History
94-
_(Nothing yet)_
119+
0.0.6:
120+
- Support for saving screenshots of failed scenarios
121+
122+
0.0.5:
123+
- More robust creation of the output directory [thanks smuldr!](https://github.com/smuldr)
124+
- Fixed the HTML reporter when using multiple feature files

0 commit comments

Comments
 (0)