Skip to content

Custom reporter for pushing Webdriverio v6 results to a Testrail

Notifications You must be signed in to change notification settings

logicsci/wdio-v6-testrail-reporter

 
 

Repository files navigation

WebdriverIO v6 Mocha Testrail Reporter

====================

A WebdriverIO v6 reporter for Testrail. It will update last test run you have on testrail. For v4 version see original reporter

Configuration

Npm Install:

npm i wdio-v6-testrail-reporter --save-dev

Yarn Install:

yarn add -D wdio-v6-testrail-reporter

Import this library in you wdio.conf.js

const TestRailReporter = require('wdio-v6-testrail-reporter')

Your reporters should look like this:

    reporters: ['spec', [TestRailReporter, {
      testRailUrl: 'YourCompanyName.testrail.io',
      username: '[email protected]',
      password: 'testrail api key',
      projectId: 1,
      suiteId: 1,
    }]],

Since it's only updating last test run you will either need to create test run manually or make an api call to create one in onPrepare hook in your wdio.conf.js.

Creating test run function(we do it with axios, but you can use testrail api packages of your choice, doesn't really matter)

async function createTestRun() {
  const response = await axios.post(
    `https://YourCompanyName.testrail.io/index.php?/api/v2/add_run/${projectId}`,
    {
      suite_id: 1,
      name: 'Test Run name',
      include_all: true,
    },
    {
      auth: {
        username: '[email protected]',
        password: 'testrail api key',
      },
    },
  );
}
    async onPrepare () {
      createTestRun()
    }

FAQ

Why is it only updating last test run and not creating test run inside reporter itself?

I wasn't able to figure out how to create test run and reuse this testrun id with a new webdriverio reporter. onSuiteStart hook is called every time spec file is ran, not whole suite as a collection of files. Same with onRunnerStart. If you have 10 tests all runing in parallel it would create 10 test runs. If you know how to solve this problem please create a pull request or tell me how and i will be happy to fix this part.

References

About

Custom reporter for pushing Webdriverio v6 results to a Testrail

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 99.4%
  • JavaScript 0.6%