Search code examples
cypressintegration-testingtestrailmochawesome

Cypress multi reporters: using mochawesome with autoset-status-cypress-testrail-reporter


I need to use two reporters with my Cypress tests: mochawesome to generate html reports, and autoset-status-cypress-testrail-reporter to publish test results to Testrail.

The main tool I could find that would enable me to use multiple reporters is cypress-multi-reporters.

However, If I try to use cypress-multi-reporters with autoset-status-cypress-testrail-reporter, alone or in conjunction with mochawesome as below (in cypress.json), it does not work. It will not print out any errors, but it just will not publish the results to Testrail, and it will not generate the mochawesome reports.

{
  "reporterEnabled": "mochawesome, autoset-status-cypress-testrail-reporter",
  "mochawesomeReporterOptions": {
    "reportDir": "cypress/reports",
    "overwrite": false,
    "html": true,
    "json": false
  },
  "autosetStatusCypressTestrailReporterReporterOptions": {
    "host": "https://xxxxxx/",
    "username": "xxxxx",
    "password": "xxxx",
    "projectId": 1,
    "runId": 1234
  }
}

Can anyone tell me why the above is not working, or suggest a similar tool that would work with both mochawesome and autoset-status-cypress-testrail-reporter?


Solution

  • Got this to work in the end. The solution was

    OPTION 1 - to include only the below in cypress.json:

    "reporter": "cypress-multi-reporters",
    "reporterOptions": {
      "configFile": "reporter-config.json"
    }
    

    Then to create a new file called reporter-config.json, and add the config for each reporter in there:

    {
      "reporterEnabled": "mochawesome, autoset-status-cypress-testrail-reporter",
      "mochawesomeReporterOptions": {
        "reportDir": "cypress/reports",
        "overwrite": false,
        "html": true,
        "json": false
      },
      "autosetStatusCypressTestrailReporterReporterOptions": {
        "host": "https://xxxxxx/",
        "username": "xxxxx",
        "password": "xxxx",
        "projectId": 1,
        "runId": 1234
      }
    }
    

    OPTION 2 - to have everything inside cypress.json, like so:

    "reporter": "cypress-multi-reporters",
    "reporterOptions": {
      "reporterEnabled": "mochawesome, autoset-status-cypress-testrail-reporter",
      "mochawesomeReporterOptions": {
        "reportDir": "cypress/reports",
        "overwrite": false,
        "html": true,
        "json": false
      },
      "autosetStatusCypressTestrailReporterReporterOptions": {
        "host": "https://xxxxxx/",
        "username": "xxxxx",
        "password": "xxxx",
        "projectId": 1,
        "runId": 1234
      }
    }