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
Log in to TestRail
In the upper right of the interface find your name and click it to spawn a menu
Clicking your name
Select
My Settings
Select the
API KEYS
tabSelect the “API KEYS” tab
Click
Add Key
linkUse
Add API Key
dialog to name the key something relevant like 'Cypress Integration'Naming the API Key
Click
Generate Key
Copy the displayed key out and save it somewhere secure
Copy the API key
Click
Add Key
Verify that key was added to list of API Keys
Verify the key is listed
Click
Save Settings
THIS IS VERY IMPORTANT. DON'T FORGET THIS STEP!
Corresponding TestRail Objects
Navigate to project dashboard
Verify
projectID
in URLInspect projectID in the URL
Navigate to 'Test Cases' tab
Verify
suiteID
in URLInspect suiteID in the URL
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
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
Inspect groupID in the URL
Environment Variables Set
TR_USER
: the email address for your TestRail accountTR_API_KEY
: the API key that you created for use by Cypress to TestRail reporter in TestRailTR_PROJECTID
: the unique identifier for your TestRail projectTR_SUITEID
: the unique identifier for the test suite from your project (by default a project is set up with only one test suite)TR_RUN_NAME
: the name that you would like to see in TestRail for this runTR_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 suiteTR_GROUPID
: the unique identifier of your section/group of automated tests in your test suiteTR_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)
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
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 --
"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",>
Help and feedback
Get help from the Platform Support Team in Slack.
Submit a feature idea to the Platform.