tomyam1 / protractor-video-reporter

Jasmine reporter that captures a screencast of Protractor specs running on a headless browser, e.g. in CI server
MIT License
21 stars 21 forks source link

protractor-video-reporter

A Jasmine 2 reporter that captures a screencast of Protractor specs running on a headless browser, e.g. under Xvfb. This is especially usefull for debugging you e2e specs on you CI server. The reporter also creates a SRT subtitles file to for the video so you can see which spec you are currently viewing and whether it passed or failed.

Install

npm install --save-dev protractor-video-reporter

Prerequisites

You have to start Xvfb before starting Protractor and set the DISPLAY enviroment variable.

If you're using Jenkins CI, you can use the Xvfb plugin to easily achive that.

Usage

In the protractor configuration file:

var VideoReporter = require('protractor-video-reporter');

...

onPrepare: function() {
  ...
  jasmine.getEnv().addReporter(new VideoReporter({
    baseDirectory: Path.join(__dirname, 'reports/videos/')
  }));
}

Options

When uuid (default): Each spec video file will be placed at baseDirectory/{some random UUID}.mov. If you prefer this option, you would have to look at the "Spec video is in: ..." messages that are printed to the console.

When fullName: Each spec video will be placed at baseDirectory/{spec full name} - {spec status}.mov. The full name of the spec will be sanitized to be a valid file name

If you want to determine the full name yourself you can pass a function. The function recieves a single argument, the result object passed to specStarted. For example, you can do:

singleVideoPath: function (result) {
    // don't actually do this, you need to make sure fullName is a valid file name
    result.fullName + '.mov';
}

Debugging

If you encouter any issues with the reporter, e.g. video files are not created, turn on debugging by settings the DEBUG environment to protractor-video-reporter.