LironEr / cypress-mochawesome-reporter

Zero config Mochawesome reporter for Cypress with screenshots and videos
MIT License
159 stars 49 forks source link

Marge Json output with html report #134

Closed soumyajit2pal closed 1 year ago

soumyajit2pal commented 1 year ago

Hi, Rather than deleting all JSON files after creating the HTML report, can we get the marge JSON file along with the HTML report? it will help us with some other validation.

joakim-sch commented 1 year ago

I mean you could do #135 but it seems a bit overkill to have an option just for that...

Will leave it up to @LironEr to if it makes any sense...

soumyajit2pal commented 1 year ago

Hi @joakim-sch, Thanks for the enhancement PR. JSON files are needed for someone doing test case pass/fail on the ALM tool using JSON and it's easy to use. it's better not to delete all jsons, and while creating HTML it's produce marge HTML report and deleting all jsons. instead of deleting all jsons just marge it to one json makes this package more powerfull.

LironEr commented 1 year ago

Hey @soumyajit2pal You can already do that by adding saveJson: true to reporterOptions, it will keep the merged JSON file next to the HTML file.

const { defineConfig } = require('cypress');

module.exports = defineConfig({
  reporter: 'cypress-mochawesome-reporter',
  reporterOptions: {
    saveJson: true
  },
  e2e: {
    setupNodeEvents(on, config) {
      require('cypress-mochawesome-reporter/plugin')(on);
    },
  },
});

Let me know if this is what you needed, if not I can look at the PR (thanks @joakim-sch)

joakim-sch commented 1 year ago

@LironEr Ah, the option already exists in the report generator. Nice. @soumyajit2pal documented here: adamgruber/mochawesome-report-generator/README.md

bdimitrovski commented 2 months ago

How does this work for cypress-multi-reporters? I have a reporter-config.js file like this:

{
    "reporterEnabled": "cypress-mochawesome-reporter, mocha-junit-reporter",
    "reporterOptions": {
        "charts": true,
        "reportPageTitle": "Cypress E2E Tests",
        "embeddedScreenshots": true,
        "inlineAssets": true,
        "saveJson": true
    },
    "mochaJunitReporterReporterOptions": {
        "mochaFile": "../tests/cypress/reports/junit/[hash].xml"
    }
}

and in cypress.config.ts defined:

module.exports = defineConfig({
    reporter: 'cypress-multi-reporters',
    reporterOptions: {
        configFile: 'reporter-config.json'  
        },
    ...

however, I cannot seem to get index.json as test results after the test run, no matter how I configure.

Using just cypress-mochawesome-reporter as a reporter, as shown in your example works well, however, I would like to keep the XML report generated by jUnit as well.

Is this possible to achieve at all?