cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.81k stars 3.17k forks source link

Cypress json reporter does not generate output file. #27636

Open lukasdo opened 1 year ago

lukasdo commented 1 year ago

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.

ctschacher commented 1 year ago

Facing the same problem: JSON output visible in command line (unfortunately mixed with standard text output) but no JSON file is created

(running Cypress v13.3.0)

cypress-app-bot commented 6 months ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

lukasdo commented 6 months ago

The issue is still existing in Cypress v13.7.1.

JoshuaJMoore commented 12 hours ago

Any updates on this? Thanks.