LironEr / cypress-mochawesome-reporter

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

HTML Report screenshot link has backward slash in the front #156

Closed Alfy102 closed 1 year ago

Alfy102 commented 1 year ago

Environment

- OS: Windows 11
- Node: v18.16.1
- cypress-mochawesome-reporter: 3.5.1
- cypress: 12.17.3

What happened?

Broken screenshot link. image

Upon checking page inspect: image

From the html document, removing the backward slash infront of the screenshot path in href and src fixed it. image image

Config file

reporterOptions: {
    reportDir: 'cypress/reports/872023133359/',
    reportFilename: '[name]',
    overwrite: false,
    html: true,
    json: false,
    code: false,
    reportPageTitle: 'RCP E2E Test Suite',
    embeddedScreenshots: true,
    inlineAssets: true
  }

Relevant log output

No response

Anything else?

Trying to figure out why the HTML report puts that backward slash there.

Alfy102 commented 1 year ago

Resolve by removing the async from setupNodeEvents in cypress.config.js Causing Issue:

async setupNodeEvents(on, config) {
      require('cypress-mochawesome-reporter/plugin')(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();
      });

      require('cypress-terminal-report/src/installLogsPrinter')(on, options);
      await preprocessor.addCucumberPreprocessorPlugin(on, config);

Fix:

setupNodeEvents(on, config) {
      require('cypress-mochawesome-reporter/plugin')(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();
      });

      require('cypress-terminal-report/src/installLogsPrinter')(on, options);
      preprocessor.addCucumberPreprocessorPlugin(on, config);