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

Commit

Permalink
Merge pull request #4 from actionless/master
Browse files Browse the repository at this point in the history
added support for taking screenshots only on failed specs
  • Loading branch information
swissmanu committed Mar 18, 2014
2 parents 9e3ad3a + 1eb9787 commit 34dd939
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ new ScreenShotReporter({

Default is `false`.

### Screenshots only for failed test cases (optional)
Also you can define if you want capture screenshots only from failed test cases using the `takeScreenShotsOnlyForFailedSpecs:` option:

```javascript
new ScreenShotReporter({
baseDirectory: '/tmp/screenshots'
, takeScreenShotsOnlyForFailedSpecs: true
});
```

Default is `false`.

## Postprocess Meta Data
A screenshot is saved as PNG image. Along with it, a JSON file with a matching filename is created.

Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ function ScreenshotReporter(options) {
this.metaDataBuilder = options.metaDataBuilder || defaultMetaDataBuilder;
this.takeScreenShotsForSkippedSpecs =
options.takeScreenShotsForSkippedSpecs || false;
this.takeScreenShotsOnlyForFailedSpecs =
options.takeScreenShotsOnlyForFailedSpecs || false;
}

/** Function: reportSpecResults
Expand All @@ -114,6 +116,9 @@ function reportSpecResults(spec) {
if(!self.takeScreenShotsForSkippedSpecs && results.skipped) {
return;
}
if(self.takeScreenShotsOnlyForFailedSpecs && results.passed()) {
return;
}

browser.takeScreenshot().then(function (png) {
browser.getCapabilities().then(function (capabilities) {
Expand Down Expand Up @@ -160,4 +165,4 @@ function reportSpecResults(spec) {

};

module.exports = ScreenshotReporter;
module.exports = ScreenshotReporter;

0 comments on commit 34dd939

Please sign in to comment.