# Testrail Reporter Reporter

> @wdio/testrail-reporter is a 3rd party package, for more information please see [GitHub](https://github.com/webdriverio-community/wdio-testrail-reporter) | [npm](https://www.npmjs.com/package/@wdio/testrail-reporter)

This reporter creates TestRail reports. The first thing you need is to enable the TestRail API so that report can communicate with TestRail and push the test results. To do so, log into your TestRail account and go to Administration > Site Settings > API and make sure you click the checkbox near Enable API.

Add TestRail's test case ID to the test description. e.g.

```
it("C123456 Page loads correctly", async () => {
```

This also supports multiple caseIDs. e.g.

```
it("C123456 C678910 Page loads correctly", async () => {
```

## Install[​](#install "Direct link to Install")

To use the reporter, add it to your `package.json`:

```
npm i --save-dev @wdio/testrail-reporter
```

## Usage[​](#usage "Direct link to Usage")

Add the reporter to your WDIO config file.

Example for when you want to create a new test run:

```
export const config = {
    // ...
    reporters:
        [
            ['testrail', {
                projectId: 1,
                suiteId: 1,
                domain: 'xxxxx.testrail.io',
                username: process.env.TESTRAIL_USERNAME,
                apiToken: process.env.TESTRAIL_API_TOKEN,
                runName: 'name for the test run',
                oneReport: true,
                includeAll: false,
                caseIdTagPrefix: '' // used only for multi-platform Cucumber Scenarios
            }
        ]
    ],
    // ...
}
```

Example for when you want to update an existing test run:

```
export const config = {
    // ...
    reporters:
        [
            ['testrail', {
                projectId: 1,
                suiteId: 1,
                domain: 'xxxxx.testrail.io',
                username: process.env.TESTRAIL_USERNAME,
                apiToken: process.env.TESTRAIL_API_TOKEN,
                existingRunId: 2345,
                oneReport: true,
                includeAll: false
            }
        ]
    ],
    // ...
}
```

Example for when you need different project and/or suite ids based on the test suite to execute:

```
export const config = {
    // ...
    reporters:
        [
            ['testrail', {
                projectId: process.env.TESTRAIL_PROJECT_NAME == 'PROJECT_A' ? 1 : 2,
                suiteId: process.env.TESTRAIL_SUITE_NAME == 'SUITE_A' ? 10 : 20,
                domain: 'xxxxx.testrail.io',
                username: process.env.TESTRAIL_USERNAME,
                apiToken: process.env.TESTRAIL_API_TOKEN,
                runName: 'name for the test run',
                oneReport: true,
                includeAll: false
            }
        ]
    ],
    // ...
}
```

## Options[​](#options "Direct link to Options")

### `projectId`[​](#projectid "Direct link to projectid")

ID of the testrail project.

Type: `string`

### `suiteId`[​](#suiteid "Direct link to suiteid")

ID of the suite, suite 1 is default.

Type: `string`

### `domain`[​](#domain "Direct link to domain")

Domain of your testrail instance, e.g. `your-domain.testrail.io`.

Type: `string`

### `username`[​](#username "Direct link to username")

Username of your testrail instance.

Type: `string`

### `apiToken`[​](#apitoken "Direct link to apitoken")

API token of your testrail instance.

Type: `string`

### `runName`[​](#runname "Direct link to runname")

Custom name for the test run.

Type: `string`

### `existingRunId`[​](#existingrunid "Direct link to existingrunid")

Id of an existing test run to update.

Type: `string`

### `oneReport`[​](#onereport "Direct link to onereport")

Create a single test run.

Type: `boolean`

### `includeAll`[​](#includeall "Direct link to includeall")

Include all tests in suite in test run.

Type: `boolean`

### `caseIdTagPrefix`[​](#caseidtagprefix "Direct link to caseidtagprefix")

Prefix use to locate for case ID in Cucumber tags, useful for multi-platform Cucumber Scenario executions

Type: `string`

### `useCucumber`[​](#usecucumber "Direct link to usecucumber")

Indicates whether the tests are written using the Cucumber framework. By default, it is set to `false`.

Type: `boolean`

### `timeInMinutes`[​](#timeinminutes "Direct link to timeinminutes")

Max time in past to consider when using 'oneReport' to check for existing runs.

Type: `number`

***

For more information on WebdriverIO see the [homepage](https://webdriver.io).
