Skip to main content
Skip table of contents

Cypress to TestRail Reporter Plugin Configuration

In order to begin writing your execution records from your Cypress e2e tests into related test cases in TestRail you will need the following configurations --

TestRail API Key

  1. Log in to TestRail

  2. In the upper right of the interface find your name and click it to spawn a menu

    Clicking your name in TestRail

    Clicking your name

  3. Select My Settings

  4. Select the API KEYS tab

    Select the API KEYS tab

    Select the “API KEYS” tab

  5. Click Add Key link

  6. Use Add API Key dialog to name the key something relevant like 'Cypress Integration'

    Naming the API Key

    Naming the API Key

  7. Click Generate Key

  8. Copy the displayed key out and save it somewhere secure

    Copy the API key

    Copy the API key

  9. Click Add Key

  10. Verify that key was added to list of API Keys

    Verify the key is listed

    Verify the key is listed

  11. Click Save Settings

THIS IS VERY IMPORTANT. DON'T FORGET THIS STEP!

Corresponding TestRail Objects

  1. Navigate to project dashboard

  2. Verify projectID in URL

    Inspect projectID in the URL

    Inspect projectID in the URL

  3. Navigate to 'Test Cases' tab

  4. Verify suiteID in URL

    Inspect suiteID in the URL

    Inspect suiteID in the URL

  5. Tag test cases in your Cypress test file by using the unique identifier of the test case in the test title

    Locate the unique identifier for the test case

    Locate the unique identifier for the test case

  6. In order to run a subset of tests available in your project's test suite, you will need to organize them into a section in TestRail and discover that section's groupId.

    Select the group in your test case collection

    Select the group in your test case collection

    Inspect groupID in the URL

    Inspect groupID in the URL

Environment Variables Set

  1. TR_USER : the email address for your TestRail account

  2. TR_API_KEY : the API key that you created for use by Cypress to TestRail reporter in TestRail

  3. TR_PROJECTID : the unique identifier for your TestRail project

  4. TR_SUITEID : the unique identifier for the test suite from your project (by default a project is set up with only one test suite)

  5. TR_RUN_NAME : the name that you would like to see in TestRail for this run

  6. TR_INCLUDE_ALL : true if you want to run all test cases in the test suite || false if you want to run a subset of test cases available in your test suite

  7. TR_GROUPID : the unique identifier of your section/group of automated tests in your test suite

  8. TR_FILTER : a string to match the names of your test cases to (even if you don't want to filter, you must include this variable set to an empty string)

CODE
export TR_USER="your-testrail-email-here" TR_API_KEY="your-API-key" TR_PROJECTID="your-projectid" TR_SUITEID="your-suiteid" TR_RUN_NAME="human readable name" TR_INCLUDE_ALL="TRUE/FALSE" TR_GROUPID="subset of test cases collected into group" TR_FILTER="a string to filter on (can be blank)"

Invoke Cypress with Custom Reporter Options

CODE
yarn cy:testrail-run --spec src/applications/<your app>/tests/e2e/<your test file>

The above yarn script is using your previously set environment variables to set the reporter options --

CODE
"cy:testrail-run": "cypress run --config-file config/cypress-testrail.json --reporter-options host=<https://dsvavsp.testrail.io/,username=$TR_USER,password=$TR_API_KEY,projectId=$TR_PROJECTID,suiteId=$TR_SUITEID,runName=$TR_RUN_NAME,includeAllInTestRun=$TR_INCLUDE_ALL,groupId=$TR_GROUPID,filter=$TR_FILTER",>

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.