cypress: 3.0 - custom reporters broken now that tests are run in isolation
Is this a Feature or Bug?
Bug
Current behavior:
Each test suite overrides the previous one’s results.
Desired behavior:
Before 3.0, results were aggregated and the final report contained all test suite results.
Steps to reproduce:
Run with several test suites:
cypress run --reporter junit --reporter-options "mochaFile=results.xml
After completion, results.xml only contains the last test suite results.
Versions
3.0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 54
- Comments: 64 (17 by maintainers)
Commits related to this issue
- Add hash to each junit report https://github.com/cypress-io/cypress/issues/1824 — committed to zhammer/one-thing by zhammer 5 years ago
- Add circleci for cypress tests (#14) * Add circleci file * Udate jest report output location * Ignore steps files * Add hash to each junit report https://github.com/cypress-io/cypress/iss... — committed to zhammer/one-thing by zhammer 5 years ago
If anyone tries running from the command line (or through
package.jsonscript), you cannot pass the[hash]param as--reporter-optionsargument. Instead, you need to add the following to yourcypress.json:@abataub how do you know when the run is finished? You use our module API, which will yield you all of the results or you simply chain something off of
cypress runlikecypress run && echo "finished"@joshmccure nothing for this will be done with
3.0.2because other thanmochawesomewe’re not seeing anything that is a fire that needs putting out. We have talked internally about exposing a service which will aggregate the results for you and spit outjunitormochawesomeor whatever it is you want.The reason this likely needs to be moved to the service level is because of parallelization releasing in
3.1.0. In that case the reports will not only be split out by spec file but they will be split out across machines and there won’t be an easy way to aggregate the results except if you have a service that knows everything about the run. That’s the logical place to put it. For now you can also see all of the results aggregated correctly in the Dashboard - although I do understand the desire to want to have junit or mochawesome reports.@knoopx did you find what you were looking for? With the junit reporter you can pass
[hash]in the filename so that it will not overwrite the previous ones. Then you can use a tool to combine them if necessary.Incorrect. Testcafé is free and open source: https://devexpress.github.io/testcafe/faq/#what-is-the-difference-between-a-paid-and-an-open-source-testcafe-version-what-is-testcafe-studio
It also has proper TypeScript support, supports multiple browsers and supports parallel testing.
@Hollander I would start another issue that focuses around not being able to use [hash] in the module API. The issue identified in this thread is more general, thus the Cypress team’s rationale for marking it wontfix makes sense.
Ah, I’ve got it. It works as an option in cypress.json.
We could use mochawesome’s
reporterFilename, but Cypress plugins don’t support changing config per file/test suite.A quick win would be implementing in mochawesome a
[file]wildcard just like jUnit’s[hash].I have mochawesome working here -> https://github.com/testdrivenio/cypress-mochawesome-s3
Essentially-
Thanks everyone. Is there a way to pass the name of the given spec instead of the hash into the file name?
@HugoGiraudel Couldn’t you do something like this…
And then after the run just combine all the coverage reports with standard
nodecode.@adubatl Hi there. Any chance you’d share your code regarding coverage aggregation? 😃
@artemshoiko You can just exec
rm -rf mochawesome-reportto delete the report folder, or userimrafnpm package for this if you wish to stay cross-platform.I personally use
fs-extrato remove a folder from a JS module.Hey kids, I may have code to help those not using Mochaawesome.
At work, I need to generate a report of all end to end tests that passed/failed for audit purposes. In Protractor, I’d just put
resultJsonOutputFile: 'report.json'in the configuration, and it “just worked”. With Cypress, this would only work if you had all your files in 1 file.So I created a custom reporter to combine them. It’s not a library (yet?) but for those of you struggling to combine the reports a single reporter generates, perhaps the code can help you provide a reference on how you’d do it yourself.
https://github.com/JesterXL/cypress-report-combine-example
Specifically the combine function: https://github.com/JesterXL/cypress-report-combine-example/blob/master/reporters/combine-reports.js#L88
It:
rm -rf reportscypress runnode reporters/combine-reports.js --reportsFolder=reportsHopefully this is helpful. I know many people are using existing reporters that broken once Cypress went isolated, but they mentioned in #1946 that they may fix this in the future.
Any news regarding to mochawesome report? I am getting only the last report out of the whole suite.
@Hollander the modules API does not currently support the [hash] option - you need to provide it in your cypress.json. It should be picked up when you run through the module API, however. This is the solution my team is currently using for testing during CI.
The module API is here. You can
console.logthe.then()so you can see what is output.@SeriousM
…
It seems like you’ve been convinced this is a feature. I don’t think people would mind if you opened up an issue for that to be implemented.
@Bkucera
I expect to have a stable execution of one test or 100, on one machine or on 30. Stability shouldn’t be an option.
@brian-mann I guess you missed my point and I hope I can change that: I’m a new user to cypress and the first-time experience was not quite that good as “advertised”. The first thing to do when I look at new technology is to read the documentation and try it in the described way.
The docker-support is very bad documented, the docker images don’t have cypress in it. The “mochawesome” (as mentioned in the documentation) reporter can’t work as it supposed to be (since 3.x) and junit reports need the special “[hash]” in the filename. These points aren’t documented and I worked them out in many hours.
Don’t get me wrong, I thing cypress is a very nice tool and I very like the way it changes the way how e2e tests are done but the documentation and get-started-pages does not really help you after the “start ide and try it”-point.
how should I know that something was communicated before when I’m a new user?
Already discussing the problem.
I see your “go f*** yourself” here, thank you.
A problem that a small team or new project never will have for months or years.
I think the decision to enforce parallel execution (thus, split reports) was not well thought thru in terms to support all users, not just the big ones with your dashboard. A mode to run the tests in serial on one machine to return a single report should be added.
@brian-mann: I would like to discuss these points, not to offend nor get offended with strong words. I hope you want the same.
@brian-mann Whoops, that is what I intended to write.
I’m not having any luck. Trying on a different computer using the last three example specs. Running
npx cypress run --reporter junit --reporter-options "mochaFile=results/my-test-output.[hash].xml,toConsole=true"on the command line and the resulting file is `results/my-test-output.hash.xml’On the previous computer, I attempted using the module api with no success.