Skip to content
This repository has been archived by the owner on Jan 26, 2023. It is now read-only.

Commit

Permalink
manual screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Alabor committed May 16, 2014
1 parent e9f9164 commit 68e2896
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,17 @@ function ScreenshotReporter(options) {
var originalAddMatcherResult = jasmine.Spec.prototype.addMatcherResult;
jasmine.Spec.prototype.addMatcherResult = function() {
if (!arguments[0].passed()) {
console.log(arguments[0]);
self.takeScreenshot(this, arguments[0]);
}
return originalAddMatcherResult.apply(this, arguments);
};

// manual screenshots
jasmine.Spec.prototype.takeScreenshot = function takeScreenshot(label) {
self.takeScreenshot(this, {
message: 'Manual Screenshot: ' + (label || 'unnamed')
});
};
}

ScreenshotReporter.prototype.takeScreenshot = function takeScreenshot(spec, results) {
Expand All @@ -129,8 +134,6 @@ ScreenshotReporter.prototype.takeScreenshot = function takeScreenshot(spec, resu
};

ScreenshotReporter.prototype.saveScreenshot = function saveScreenshot(spec, results, capabilities, png) {
//++this.currentScreenshotSession.index;

var descriptions = util.gatherDescriptions(
spec.suite
, [spec.description]
Expand Down

2 comments on commit 68e2896

@elgalu
Copy link

@elgalu elgalu commented on 68e2896 May 23, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
How can i use this within a protractor it() block?

@swissmanu
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you just fire this.takeScreenshot() inside your it block.
this implementation extends jasmines spec object.

Please sign in to comment.