With Cypress reporter plugin, you can automatically populate cypress generated test results into your Test Runs in TestCollab.

How it works?

  • You have test cases in a project in TestCollab that need to be automated

  • Test cases are added to a test plan and are assigned to their testers

  • You use Cypress for test case automation, and have Mochawesome Reporter

Using the node package testcollab-cypress-plugin, the Mochawesome (JSON) report can be used to populate the results back into TestCollab, automatically updating the status of executed test cases.

Installation

In order to install the plugin, simply run the command:

npm install -g testcollab-cypress-plugin

The package is ready to use once it is installed.

Setting the environment variable

In order to use testcollab-cypress-plugin we have to set the value of environment variable NODE_ENV (has to be in capitals) to production (has to be in small case)

Here is the command used in Linux :

export NODE_ENV = production

You can later check whether the value is set correctly or not by using:

echo $NODE_ENV

The 'uploadTCRunResult' command syntax

Once package is installed "uploadTCRunResult" command would be available for execution


uploadTCRunResult --apiToken=<<API_TOKEN>>  --projectId=<<PROJECT_ID>>  --companyId=<<COMPANY_ID>>  --testPlanId=<<TESTPLAN_ID>>   --mochaJsonResult=<<RELATIVEPATH_TO_JSON>>

Notes: Your JSON file must follow mochawesome format.


The arguments

Argument

Purpose

Additional information

apiToken

API token of the tester who is the assignee for testcases to be executed.

To know how API tokens can be generated in TestCollab:

https://help.testcollab.com/en/articles/5299051-getting-an-api-token-generated

companyId

Id of the company registered with TestCollab

Availability:

  • Look for company_id query parameter on network calls from TestCollab app

  • Or contact us

projectId

Id of the project to which the testcases (and testplan) belong

Accessible from web browser's address bar

testPlanId

Id of the testplan to which the testcases to be executed have been added

Availability :

  • As a column on testplans list page

  • On the web browser's address bar

Mapping TestCollab test cases with cypress

In order for this package to map executed test cases with their corresponding Test Collab test cases ID, IDs should be appended to 'title' property of your 'tests' array in JSON as follows:

{
"stats": {
"suites": 1,
"tests": 4,
"passes": 3,
..........
..........
},

"results": [
{
"uuid": "dda20e6a-1473-4084-90b0-f1eb99f78e96",
.............
.............

"suites": [
{
"uuid": "ab6e0113-f0f1-45fe-9a95-fc72eb1a5a5b",
"title": "",
.............
.............
"tests": [
{
"title": "id-389440", ⬅ We parse testcase ID from here
"fullTitle": "Sample test",
},

Download above sample file here

f you are using multiple configurations in your test run, then test plan configuration ID should be specified in similar way in 'suites' array under title property like this:

{
"stats": {
"suites": 1,
"tests": 4,
"passes": 3,
..........
..........
},

"results": [
{
"uuid": "dda20e6a-1473-4084-90b0-f1eb99f78e96",
.............
.............

"suites": [
{
"uuid": "ab6e0113-f0f1-45fe-9a95-fc72eb1a5a5b",
"title": "TestSuite-1", ⬅ :information_source: Test plan configuration ID
.............
.............
"tests": [
{
"title": "id-5381", ⬅ :information_source: Test case ID
"fullTitle": "Sample test",
},

Download above sample file here



A Use Case

Run the Cypress script:

Next, uploadTCRunResult is run:

The results are meanwhile populated in TestCollab, the same can be checked by accessing the testcase execution details for the testplan.

Hope this article helps in better integration with Cypress for more related articles check out this section of user guide.

For any queries / suggestions please feel free to contact us at support@testcollab.com

Did this answer your question?