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

added support for taking screenshots only on failed specs #4

Merged
merged 1 commit into from
Mar 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;