cypress
cypress copied to clipboard
Cypress json reporter does not generate output file.
Current behavior
Run cypress e2e tests with a json reporter and define an output file according to the mocha documentation. The output file will not be generated, but the json output will be printed to the console.
Desired behavior
When setting --reporter json --reporterOptions output=results.json, the output file should be generated and contain the results from the test run in JSON format.
Test code to reproduce
Create a new cypress e2e project with a single test and run the e2e suite.
Configure the cypress.config.js
and set reporter: 'json'
and reporterOptions: { output: 'testFile.json' }
.
Or from the command line: cypress run --reporter json --reporter-options "output=testFile.json"
Or check out this repository with a single e2e test and the correct configuration.
Cypress Version
12.17.4
Node version
v.18.10.0
Operating System
macOs 13.0
Debug Logs
No response
Other
The broken json reporter has quite a history, e.g. #18014, from previous issues I could not see it working for anyone. Previously there was some misunderstanding as the property to set the output file on the mocha side was renamed to reporterOption
while the cypress configuration is named reporterOptions
. Although mocha has made some fixes in their project, the output file still does not work. In my opinion this is because the mocha version in packages/server/package.json is set to 7.1.0. In mocha 7.1.0 the output file is not supported.