mocha.jscypresstest-results

Cypress tests with mocha multi reports; not able to get aggregated results for all test spec


Cypress tests with mocha multi reports don't show results from all the tests

My test structure looks like so:
cypress
 integration
  module1
   module1test1_spec.js
   module1test1_spec.js
  module2
   module2test1_spec.js
   module2test1_spec.js

I have set up Cypress to use mocha-multi-reports like in instruction provided under
https://docs.cypress.io/guides/tooling/reporters.html#Multiple-Reporters
My config.json looks exactly like here:
https://github.com/cypress-io/cypress-example-docker-circle#spec--xml-reports
When Cypress finishes testing, results.xml file shows results from last test spec ONLY; module2test1_spec.js
How to configure this to get the aggregated results from all test spec?


Solution

  • You can use [hash].xml in your path.

    e.g. ./path_to_your/test-results.[hash].xml. [hash] is replaced by MD5 hash of test results XML. This enables support of parallel execution of multiple mocha-junit-reporter's writing test results in separate files.

    https://www.npmjs.com/package/mocha-junit-reporter#results-report

    I solved this problem with this way.

    my config.json file seems like this:

    "reporterEnabled": "spec,json, mocha-junit-reporter",
      "mochaJunitReporterReporterOptions": {
        "mochaFile": "multiple-results/[hash].xml",