LironEr / cypress-mochawesome-reporter

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

cypress-mochawesome-reporter v3.0.1 is failing to identify the package using reporter path #76

Closed MoonAditya closed 2 years ago

MoonAditya commented 2 years ago

Environment

- OS: Windows 10 enterprise
- Node: v14.15.0
- cypress-mochawesome-reporter: 3.0.1
- cypress: 8.7.0

What happened?

The issue is related to the cypress-mochawesome-reporter: { "version": "3.0.1"} this version has a strict check for the reporter name in the config.js file, see the code here

if (config.reporter === 'cypress-mochawesome-reporter') { return opts; }

It is a failing and logging a message that "cypress-mochawesome-reporter is not an active reporter" since we are providing the path of the package in our node module. I am only using this reporter. However, due to our project setup, we need the flexibility to pass the reporter value as a path along with the package name. such as,

"reporter": "../../node_modules/cypress-mochawesome-reporter",

Config file

see the cypress.json file set up here

{
    "fileServerFolder": ".",
    "fixturesFolder": "./src/fixtures",
    "integrationFolder": "./src/integration",
    "modifyObstructiveCode": false,
    "pluginsFile": "./src/plugins/index",
    "supportFile": "./src/support/index.ts",
    "video": false,
    "videosFolder": "../../cypress-reports/videos",
    "screenshotsFolder": "../../cypress-reports/screenshots",
    "chromeWebSecurity": false,
    "reporter": "../../node_modules/cypress-mochawesome-reporter",
    "reporterOptions": {
        "reportDir": "../../cypress-reports",
        "embeddedScreenshots": true,
        "overwrite": false,
        "charts": true,
        "showSkipped": true,
        "saveJson": true
    }
}

Relevant log output

cypress-mochawesome-reporter is not the active reporter, ignore before run hook.

cypress-mochawesome-reporter is not the active reporter, ignore after run hook.

Anything else?

It should not be failing if we pass the path of the package as reporter.

jinisha commented 2 years ago

I am having a similar problem.

Env:-

cypress.json setup

"reporter": "../../../node_modules/cypress-multi-reporters", "reporterOptions": { "configFile": "reporter-config.json" },

reporter-config.json { "reporterEnabled": "cypress-mochawesome-reporter", "cypressMochawesomeReporterReporterOptions": { "reportDir": "cypress/reports", "embeddedScreenshots": true, "charts": true, "inlineAssets": true } }

When I start running the tests, it throws cypress-mochawesome-reporter is not the active reporter, ignore before run hook error. When its almost done running the tests, it throws "cypress-mochawesome-reporter is not the active reporter, ignore after run hook".

Tried both options in plugins/index file Add to cypress/plugins/index.js module.exports = (on, config) => { require('cypress-mochawesome-reporter/plugin')(on); }; or (cypress-mochawesome-reporter >= 2.2.0)

const { beforeRunHook, afterRunHook } = require('cypress-mochawesome-reporter/lib');

module.exports = (on) => { on('before:run', async (details) => { console.log('override before:run'); await beforeRunHook(details); });

on('after:run', async () => { console.log('override after:run'); await afterRunHook(); }); };

Its generating the json files but its not generating html report. Please advise!

LironEr commented 2 years ago

Should be fixed in v3.1.0.