10

I've established a considerable set of protractor test suites and I'm looking to implement it into jenkins to run these tests with each new build. To handle the output, simply outputting it to a text file doesn't suffice anymore e.g. protractor conf.js --suite [suiteName] > output.text

I've found protractor reporters here and here but I haven't found any information on manually manipulating the protractor output to represent it more clearly and attractively without the use of external frameworks / libraries.

Appreciate any input!

Tom Nijs
  • 3,835
  • 3
  • 22
  • 40
  • Does this help at all? http://stackoverflow.com/questions/29652810/unable-to-generate-report-when-using-jasmine-reporters-in-protractor – Aaron Apr 16 '15 at 17:29
  • @Aaron Thanks for the reply, I've looked at the jasmine-reporters plugin but I'm looking to manipulate the output myself rather than using a predefined plugin. – Tom Nijs Apr 17 '15 at 08:13

4 Answers4

6

It sounds like you want to create a custom Jasmine reporter. The reporter API is explained in the Jasmine docs.

Since you only want to do stuff with test results, you only need to implement the specDone callback. Your reporter would look something like this:

var myReporter = {
  specDone: function(results)( {
    writeToFile('Suite started: ' + result.description + ' whose full description is: ' + result.fullName);
  }
};

Then you can add your reporter to Jasmine in your conf file:

jasmine.getEnv().addReporter(myReporter);
Andrew Eisenberg
  • 28,387
  • 9
  • 92
  • 148
0

I think my project could satisfy your requirements partially and I would like to give you more input with executable solution.

You can generate readability test report automatically with this project. You have to install an additional module with NPM and add a few line in your protractor config file.

http://vorachet.github.io/protractor-build-verification-testreport/

Excerpt:

protractor-build-verification-testreport

Build verification test (Smoke testing ,Confidence testing, Sanity testing) is done by testers before accepting a new build. Build verification test is also one of the most cost-effective method for identifying and fixing defects in software.

protractor-build-verification-testreport provides a Node.js module used to generate readability HTML test report based on Protractor environment. If Protractor is an equipment in your build verification test process, protractor-build-verification-testreport could help you doing test report tasks effectively.

Drew
  • 24,851
  • 10
  • 43
  • 78
vrj
  • 531
  • 3
  • 4
0

Email-able Report

import:  var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
            savePath: './emailable-report/',
            consolidateAll: false,
            screenshotsFolder: 'reportsscreenshots',
            takeScreenshots: true,
            takeScreenshotsOnlyOnFailures: true
        }));

Summary Report

import:  var HtmlReporter = require('protractor-beautiful-reporter');
jasmine.getEnv().addReporter(new HtmlReporter({
            baseDirectory: './summary-report',
            screenshotsSubfolder: 'images',
            jsonsSubfolder: 'jsons',
            takeScreenShotsOnlyForFailedSpecs: true,
            docTitle: 'NAVA 2.1 Tablet Site Automation Execution Summary ..'
        }).getJasmine2Reporter());
  • protractor-jasmine2-html-reporter
  • protractor-beautiful-reporterist item
0

Install protractor-jasmine2-html-reporter via NPM

npm install protractor-jasmine2-html-reporter --save-dev

In your Protractor configuration file, register protractor-jasmine2-html-reporter in jasmine:

var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');

// Setup the report before any tests start

beforeLaunch: function() {
    return new Promise(function(resolve) {
        reporter.beforeLaunch(resolve);
    })
},


onPrepare: function() {
    browser.driver.manage().window().maximize();
    jasmine.getEnv().addReporter(
        new Jasmine2HtmlReporter({
            savePath: 'target/screenshots', // put your destination file
        })
    );



    jasmine.getEnv().addReporter(new SpecReporter({
        displayFailuresSummary: true,
        displayFailedSpec: true,
        displaySuiteNumber: true,
        displaySpecDuration: true
    }));

    jasmine.getEnv().addReporter(reporter);
},

// Close the report after all tests finish

afterLaunch: function(exitCode) {
    return new Promise(function(resolve) {
        reporter.afterLaunch(resolve.bind(this, exitCode));
    });
},
NightOwl888
  • 55,572
  • 24
  • 139
  • 212
Madiop Niang
  • 533
  • 4
  • 11