If you are using either the Mocha or Jasmine test framework with Protractor, follow the instructions below to report results.
npm install mocha-tesults-reporter --save
npm install jasmine-tesults-reporter --save
Your Protractor conf.js file must contain the three properties below to have results upload to Tesults:
Set framework you are using
framework: 'mocha'
framework: 'jasmine'
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'
}
}
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
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
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:
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) {});
}
};
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) {});
}
};
This completes Protractor specific configuration. Now continue viewing the Tesults Mocha or Tesults Jasmine documentation to complete setup.
Result interpretation is not currently supported by this integration. If you are interested in support please contact help@tesults.com.
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.
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.
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.