Protractor test reporting

If you are using either the Mocha or Jasmine test framework with Protractor, follow the instructions below to report results.

Installation

Mocha

npm install mocha-tesults-reporter --save

Jasmine

npm install jasmine-tesults-reporter --save

Configuration

Your Protractor conf.js file must contain the three properties below to have results upload to Tesults:

1. Framework

Set framework you are using

Mocha

framework: 'mocha'

Jasmine

framework: 'jasmine'

2. Reporter configuration

Mocha

Require the mocha-tesults-reporter in your conf.js

const tesultsReporter = require("mocha-tesults-reporter")

Have reporter in mochaOpts in the config set to reference the mocha-tesults-reporter:

mochaOpts: {
  reporter: tesultsReporter,
  reporterOptions: {
    'tesults-target': 'token',
    'tesults-config': '/path/tesults-config.js',
    'tesults-files': '/path-to-files/files',
    'tesults-build-name': '1.0.0',
    'tesults-build-description': 'build description',
    'tesults-build-reason': 'build failure reason (if failed)',
    'tesults-build-result': 'pass'
  }
}

View the Mocha reporter documentation for details on the optional tesults-config, tesults-files and tesults-build-* arguments.

The reporterOptions sets args for the mocha-tesults-reporter. The reporterOptions is optional because you can alternatively pass the args through the command line to Protractor. Doing this in the conf.js is convenient for values that do not change.

The alternative method of passing mocha-tesults-reporter args, without reporterOptions in mochaOpts using protractor command line:

protractor conf.js --disableChecks --reporter-option tesults-target=token
--reporter-option tesults-files=/path-files

Jasmine

Register the jasmine-tesults-reporter with Jasmine (this is required if using Jasmine).

onPrepare: function(){
  const tesultsReporter = require('jasmine-tesults-reporter');
  jasmine.getEnv().addReporter(tesultsReporter);
}

You would then run the tests by passing the tesults-target arg (see the Jasmine docs for more details)

protractor conf.js --  tesults-target=token

3. The afterLaunch function

Mocha and Jasmine

Protractor's afterLaunch function must be added to the conf.js and set to resolve a promise in order to allow asynchronous operations in reporters to complete before Protractor exits. Upload will not occur without this function being present in the conf.js.

afterLaunch: function (exitCode) {
  return new Promise(function (resolve) {});
}

Putting this altogether, a conf.js would resemble:

Mocha

const tesultsReporter = require("mocha-tesults-reporter")

exports.config = {
  framework: 'mocha',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['todo-spec.js', 'todo-spec2.js'],
  mochaOpts: {
    reporter: tesultsReporter,
    slow: 3000,
    reporterOptions: {
      'tesults-target': 'token',
      'tesults-config': '/path/config.js',
      'tesults-files': '/path-to-files/files',
      'tesults-build-name': '1.0.0',
      'tesults-build-description': 'build description',
      'tesults-build-reason': 'build failure reason (if failed)',
      'tesults-build-result': 'pass'
    }
  },
  afterLaunch: function (exitCode) {
    return new Promise(function (resolve) {});
  }
};

Jasmine

exports.config = {
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['todo-spec.js', 'todo-spec2.js'],
  onPrepare: function(){
    const tesultsReporter = require('jasmine-tesults-reporter');
    jasmine.getEnv().addReporter(tesultsReporter);
  }
  afterLaunch: function (exitCode) {
    return new Promise(function (resolve) {});
  }
};

Back to Mocha or Jasmine

This completes Protractor specific configuration. Now continue viewing the Tesults Mocha or Tesults Jasmine documentation to complete setup.

Result Interpretation

Result interpretation is not currently supported by this integration. If you are interested in support please contact help@tesults.com.

Consolidating parallel test runs

If you execute multiple test runs in parallel or serially for the same build or release and results are submitted to Tesults within each run, separately, you will find that multiple test runs are generated on Tesults. This is because the default behavior on Tesults is to treat each results submission as a separate test run. This behavior can be changed from the configuration menu. Click 'Results Consolidation By Build' from the Configure Project menu to enable and disable consolidation by target. Enabling consolidation will mean that multiple test runs submitted with the same build name will be consolidated into a single test run.

Dynamically created test cases

If you dynamically create test cases, such as test cases with variable values, we recommend that the test suite and test case names themselves be static. Provide the variable data information in the test case description or other custom fields but try to keep the test suite and test name static. If you change your test suite or test name on every test run you will not benefit from a range of features Tesults has to offer including test case failure assignment and historical results analysis. You need not make your tests any less dynamic, variable values can still be reported within test case details.

Proxy servers

Does your corporate/office network run behind a proxy server? Contact us and we will supply you with a custom API Library for this case. Without this results will fail to upload to Tesults.

Have questions or need help? Contact us