Created
May 8, 2014 11:31
-
-
Save capaj/d2ca08afa2eb5ac1d4ee to your computer and use it in GitHub Desktop.
protractor will take screenshot on any jasmine spec fail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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