Adding Reports and Screenshots to Your Protractor Tests

Adding Reports and Screenshots to Your Protractor Tests

If you fancy sticking it out with Protractor (unlike I did), I highly suggest you add jasmine  2 html reporter to your test projects.

The Jasmine part

Adding Jasmine will give you a little report in the command window listing all tests that have been run, including which have passed and which have failed.

To add this to your project run this command via npm:

npm install protractor-jasmine2-html-reporter --save (--save will save to project dependencies in package.json)

Note: Make sure you have a package.json file in your project. This details the packages required for your project. If you built your project from scratch you may not have it yet.

The HTML-Reporter part

This produces HTML reports of your test results. You can state the save path of these files within the conf.js file as a parameter in the Jasmine2HtmlReporter.

Add this to your conf.js file to register protractor-jasmine2-html-reporter in jasmine:

exports.config = {
// ...
onPrepare: function () {
// output HTML page and creates screenshots
let Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
new Jasmine2HtmlReporter({
savePath: 'target/'+ + '/Screenshots'

Overall, using Jasmine defintely makes it easier to interpret the results from your tests. And, although pretty basic, the HTML reporter can be styled to produce great looking results in case they need to be shown to anyone unable to run the tests via commandline or used in larger reports.


Leave a Reply

Your email address will not be published. Required fields are marked *

Looking for Something?