Skip to content

Instantly share code, notes, and snippets.

@capaj
Created May 8, 2014 11:31
Show Gist options
  • Save capaj/d2ca08afa2eb5ac1d4ee to your computer and use it in GitHub Desktop.
Save capaj/d2ca08afa2eb5ac1d4ee to your computer and use it in GitHub Desktop.
protractor will take screenshot on any jasmine spec fail
var fs = require('fs');
var originalAddMatcherResult = jasmine.Spec.prototype.addMatcherResult;
jasmine.Spec.prototype.addMatcherResult = function() {
if (!arguments[0].passed()) {
browser.takeScreenshot().then(function(png) {
var stream = fs.createWriteStream("./screenshot.png");
stream.write(new Buffer(png, 'base64'));
stream.end();
});
}
return originalAddMatcherResult.apply(this, arguments);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment