# cypress-testrail-integration

> TestRail integration for Cypress autotests

Latest version **1.0.6** (published 2025-09-14) · MIT License license · 0 weekly downloads

## Install

```sh
npm install cypress-testrail-integration
pnpm add cypress-testrail-integration
yarn add cypress-testrail-integration
bun add cypress-testrail-integration
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2025-09-14 |
| First published | 2023-01-03 |
| Weekly downloads | 0 |
| License | MIT License |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ivan Smolyarov |
| Maintainers | smoliarick_npm |
| Keywords | cypress, testrail |

## Links

- npm: https://www.npmjs.com/package/cypress-testrail-integration
- Repository: https://github.com/Smoliarick/cypress-testrail-integration
- Homepage: https://github.com/Smoliarick/cypress-testrail-integration#readme
- Issues: https://github.com/Smoliarick/cypress-testrail-integration/issues
- npm.io page: https://npm.io/package/cypress-testrail-integration

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.2.2

## Alternatives

- [@snazzah/davey](https://npm.io/package/@snazzah/davey.md) — 1.5M weekly downloads
- [@vendure/testing](https://npm.io/package/@vendure/testing.md) — 8.3K weekly downloads
- [vue-simple-context-menu](https://npm.io/package/vue-simple-context-menu.md) — 6.6K weekly downloads
- [cypress-webpack-preprocessor-v5](https://npm.io/package/cypress-webpack-preprocessor-v5.md) — 2.1K weekly downloads
- [@backstage/plugin-catalog-backend-module-puppetdb](https://npm.io/package/@backstage/plugin-catalog-backend-module-puppetdb.md) — 1.3K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2025-09-14
- 1.0.5 — 2025-08-07
- 1.0.4 — 2025-08-07
- 1.0.3 — 2023-02-26
- 1.0.2 — 2023-01-03
- 1.0.1 — 2023-01-03
- 1.0.0 — 2023-01-03

## README

<h1>cypress-testrail-integration</h1>

<a href="https://github.com/Smoliarick/cypress-testrail-integration"><img src="https://github.githubassets.com/favicons/favicon.png" style="background: white"></a>

This package helps to create a new Test Run in Test Rail with results from Cypress Run.

⚠️ Check that all Test Case IDs, which you use, are existed in Test Rail. If you try to add a new Test Run (if you don't use existed Test Run ID), it doesn't work, because Test Rail API doesn't allow creating a new Test Run using non-existed IDs. Example: you have these Test Case IDs = `['1', '2', '3']`, your Cypress autotests have these IDs in results = `['1', '2', '3', '4']` => error! because Test Rail doesn't contain Test Case with ID = `4`.

<h1>Content</h1>

- [Installation](#installation)
- [Add package into `cypress.config.js` file](#add-package-into-cypressconfigjs-file)
- [Update titles for autotests using template](#update-titles-for-autotests-using-template)
- [Running code](#running-code)
- [Your own parser and titles for autotests](#your-own-parser-and-titles-for-autotests)
- [Your own name for Test Rail Test Runs](#your-own-name-for-test-rail-test-runs)
- [Using created Test Run for results](#using-created-test-run-for-results)
- [Example](#example)

## Installation

```
npm i cypress-testrail-integration
```

## Add package into `cypress.config.js` file

1. Create any file with Test Rail credentials and data. Example (`.env` file):

```
TESTRAIL_USERNAME=your_testrail_username
TESTRAIL_PASSWORD=your_testrail_password
TESTRAIL_HOSTNAME=https://your_domain.testrail.io/
TESTRAIL_PROJECT_ID=your_testrail_project_id
```

2. Export package and create a new object into the [`after-run-api`](https://docs.cypress.io/api/plugins/after-run-api) part of the cypress config file (use credentials and data for Test Rail from step 1).
3. Run `addResultsToTestRailTestRun` method for creating a new Test Run in Test Rail (with Test Case IDs from autotests) and adding results into created Test Run.

Full code:

```js
const { defineConfig } = require("cypress");

require("dotenv").config();

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      on("after:run", async (results) => {
        // Export package
        const TestrailIntegration = require("cypress-testrail-integration");
        // Create a new object with Test Rail credentials and data
        const testrailIntegration = new TestrailIntegration(
          process.env.TESTRAIL_USERNAME, // Test Rail username
          process.env.TESTRAIL_PASSWORD, // Test Rail password
          process.env.TESTRAIL_HOSTNAME, // Test Rail hostname
          process.env.TESTRAIL_PROJECT_ID // Test Rail project_id
        );
        // Create a new Test Run in Test Rail and add results from Cypress Run
        await testrailIntegration.addResultsToTestRailTestRun(results);
      });
      return config;
    },
    specPattern: "cypress/e2e/**/*.spec.{js, jsx, ts, tsx}",
  },
});
```

## Update titles for autotests using template

Update titles for your autotests using this template:

```js
it("[Test Case IDs with any first letter]: [Autotest's title]", () => {
  // autotest
});
```

Example:

```js
it("C1, C2: Verify that google page has input field", () => {
  // autotest
});
```

```js
it("C3: Verify that google page doesn't have input field ", () => {
  // autotest
});
```

## Running code

If you completed to updated autotests titles and config file, run this command for test:

```
npx cypress run
```

If all works OK, you will see a new Test Run with results. It contains all Test Cases with Test Case IDs from your autotests.

Video example:

https://user-images.githubusercontent.com/104084410/210332253-d14ed4e4-f3f0-4e4f-8de5-7c97809d7d81.mp4

## Your own parser and titles for autotests

If you want to use your own parser and titles for autotests, you can add a new parser into the constructor for `TestrailIntegration`.

1. Create a new parser for the `cypress.config.js` file
2. Add it into the `TestrailIntegration` constructor as a `parser` param
3. Update your autotests titles using your own parser

Example:

```js
setupNodeEvents(on, config) {
  on('after:run', async (results) => {
    function newParser(title) { // new parser
      const splittedTitle = title.split(':');
      const testCaseIds = splittedTitle[0]
        .split(',')
        .map((element) => element = element.trim().substring(1));
      return testCaseIds;
    }

    const TestrailIntegration = require('cypress-testrail-integration');
    const testrailIntegration = new TestrailIntegration(
      process.env.TESTRAIL_USERNAME,
      process.env.TESTRAIL_PASSWORD,
      process.env.TESTRAIL_HOSTNAME,
      process.env.TESTRAIL_PROJECT_ID,
      parser = newParser // adding a new parser
    );
    await testrailIntegration.addResultsToTestRailTestRun(results);
  });
  return config;
},
```

⚠️ Be careful, new parser should return array of the Test Case IDs. Example: `['1', '2', '3', '4', '5', '6', '7']` or `['1']` for 1 Test Case ID.

## Your own name for Test Rail Test Runs

Default name is `[Today's date] Test Run: Cypress Autotest`, e.g. `2023-01-03 Test Run: Cypress Autotest`.

If you want to add a new name for Test Rail Test Run, add it into the constructor. Example:

```js
setupNodeEvents(on, config) {
  on('after:run', async (results) => {
    const TestrailIntegration = require('cypress-testrail-integration');
    const testrailIntegration = new TestrailIntegration(
      process.env.TESTRAIL_USERNAME,
      process.env.TESTRAIL_PASSWORD,
      process.env.TESTRAIL_HOSTNAME,
      process.env.TESTRAIL_PROJECT_ID,
      testRunName = 'New Test Run' // adding a new name for Test Run
    );
    await testrailIntegration.addResultsToTestRailTestRun(results);
  });
  return config;
},
```

## Using created Test Run for results

If you want to use created Test Run in Test Rail for adding results, you can add it's ID into the `addResultsToTestRailTestRun` method. Example:

```js
setupNodeEvents(on, config) {
  on('after:run', async (results) => {
    const TestrailIntegration = require('cypress-testrail-integration');
    const testrailIntegration = new TestrailIntegration(
      process.env.TESTRAIL_USERNAME,
      process.env.TESTRAIL_PASSWORD,
      process.env.TESTRAIL_HOSTNAME,
      process.env.TESTRAIL_PROJECT_ID
    );

    // 25 is ID for existed Test Rail Test Run
    await testrailIntegration.addResultsToTestRailTestRun(results, runId = 25);
  });
  return config;
},
```

## Example

You can use this example: https://github.com/Smoliarick/cypress-testrail-integration-example. This project was set up using cypress-testrail-integration package.

---
_Source: https://npm.io/package/cypress-testrail-integration · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
