Skip to content

Commit

Permalink
Take screenshot of failed e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
djuretic committed Jan 1, 2014
1 parent 3c5f9d7 commit c572a19
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/e2e/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ describe('front page', function() {
browser.sleep(1000);
});

// based on https://github.com/angular/protractor/issues/114#issuecomment-29046939
afterEach(function(){
var currentSpec = jasmine.getEnv().currentSpec;
var passed = currentSpec.results().passed();
if(!passed){
var filename = 'exception_' + currentSpec.description + '.png';
browser.takeScreenshot().then(function(png){
var fs = require('fs');
var buffer = new Buffer(png, 'base64');
var stream = fs.createWriteStream(filename);
stream.write(buffer);
stream.end();
});
}
});

it('shows the front page', function(){
var button = element(by.className('btn'));
expect(button.getText()).toEqual('Play');
Expand Down

0 comments on commit c572a19

Please sign in to comment.