WebdriverIO test reporting

Powering up your WebdriverIO tests with Tesults reporting is easy. This page explains it all. If you have any questions please reach out to the Tesults team. If you are not using WebdriverIO view the Node.js and JavaScript docs for information about integrating with a lower level library.

This package requires Node.js 14+ and can be used with WebdriverIO when using the Mocha, Jasmine and Cucumber frameworks.

Installation

npm install wdio-tesults-service --save

Please note that wdio-tesults-service is the now the standard way to integrate with WebdriverIO. The older wdio-tesults-reporter has been deprecated and is no longer supported or recommended.

Configuration

In your WebdriverIO wdio.conf.js file add the Tesults reporter along with the options object:

exports.config = {
  // ...
    services: [
      ['tesults',
        {
          target: 'token'
        }
      ]
    ],
  // ...
}
targetRequired

You must provide your target token to push results to Tesults. If this arg is not provided the service does not attempt upload, effectively disabling it. You receive a target token when creating a project or new target and can regenerate one at anytime from the configuration menu. Find out more about targets

To support multiple reporting targets, you can either create multiple wdio.conf.js or rather than pass the target token as a string, retrieve it from a variable that is set from a command line argument or continuous integration system.

const target = () => { // target token from command line arg }
exports.config = {
  // ...
    services: [
      ['tesults',
        {
          target: target()
        }
      ]
    ],
  // ...
}

Basic configuration complete

At this point, if you run tests, results data will be uploaded to Tesults

npx wdio run ./wdio.conf.js

Enhanced reporting

Use the Tesults service to report additional properties for each test case. To begin doing this, require the service in your test spec file:

const tesultsService = require('wdio-tesults-service').default
// Alternatively: import tesultsService from 'wdio-tesults-service/worker.js'

Report custom fields, test steps and attach files to test cases using the Tesult service functions: description, custom, step, and file:

description

Add a description of the test case for reporting purposes.

tesultsService.description("some description here")

custom

Add a custom field and value to the test case for reporting purposes.

tesultsService.custom("Some custom field", "Some custom value")

file

Associate a file to the test case in order to upload it for reporting.

tesultsService.file("/absolute/path/to/file/screenshot.png")

Caution: If uploading files the time taken to upload is entirely dependent on your network speed. Typical office upload speeds of 100 - 1000 Mbps should allow upload of even hundreds of files quite quickly, just a few seconds, but if you have slower access it may take hours. We recommend uploading a reasonable number of files for each test case. The upload method blocks at the end of a test run while uploading test results and files. When starting out test without files first to ensure everything is setup correctly.

step

Add test steps to the test case for reporting. Each step is an object with a name and result (one of [pass, fail, unknown]). You can also add the optional fields description and reason (failure reason in case of step fail).

tesultsService.step({
  name: "First step",
  result: "pass"
})
tesultsService.step({
  name: "Second step",
  description: "Second step description",
  result: "fail"
  reason: "Error line 203 of test.js"
})

Build

Report build information by passing through data as options in wdio.conf.js

exports.config = {
  // ...
    services: [
      ['tesults',
        {
          target: 'token',
          build:{
            name: '1.0.0',
            result: 'pass', // one of [pass, fail, unknown]
            description: 'build description',
            reason: 'build failure reason' // if result is fail
          {
        }
      ]
    ],
  // ...
}

Build properties

nameOptional

Use this to report a build version or name for reporting purposes.


resultOptional

Use this to report the build result, must be one of [pass, fail, unknown].


descriptionOptional

Use this to report a build description for reporting purposes.


reasonOptional

Use this to report a build failure reason.


A complete example:

const tesultsService = require('wdio-tesults-service').default
describe('Test suite', () => {
  it('Test case', async () => {
    // ...
    tesultsService.description("some description here")
    tesultsService.custom("Some custom field", "Some custom value")
    tesultsService.step({
      name: "First step",
      result: "pass"
    })
    tesultsService.step({
      name: "Second step",
      result: "pass"
    })
    tesultsService.file("/absolute/path/to/file/screenshot.png")
    // ...
  });
});

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