LironEr / cypress-mochawesome-reporter

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

Screenshot doesn't appear to be embedded as base64 string, just a link to the file #100

Closed ajling closed 2 years ago

ajling commented 2 years ago

Environment

- OS: Windows 11
- Node: 16.16
- cypress-mochawesome-reporter: 3.2.2
- cypress: 10.6.0

What happened?

When a test fails and the HTML report is generated, even when the reporter option 'embeddedScreenshots' is set to true the image in the HTML report is just a link. I was under the impression that the screenshot would be added to the HTML report file as a Base64 string.

Let me know if there is any other information you need. Thanks

If using my project, run yarn install then run yarn cy:runExample

See example report: report_file_example.zip

Here is the full example project if it's any help: CypressE2Ev10-Example.zip

Config file

cypress.config.js contents:

const { defineConfig } = require('cypress');
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor");
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
const createEsbuildPlugin = require("@badeball/cypress-cucumber-preprocessor/esbuild");

async function setupNodeEvents(on, config) {

  await preprocessor.addCucumberPreprocessorPlugin(on, config);
  on(
    "file:preprocessor",
    createBundler({
      plugins: [createEsbuildPlugin.default(config)],
    })
  )

  require('cypress-mochawesome-reporter/plugin')(on);
  return config;
}

module.exports = defineConfig({
  e2e: {
    setupNodeEvents,
    specPattern: '**/*.feature',
    excludeSpecPattern: '*.js',
    supportFile: 'cypress/support/e2e.{js,jsx,ts,tsx}',
    watchForFileChanges: true,
    baseUrl: 'https://www.npmjs.com/',
    fullUrl: 'https://www.npmjs.com/package/cypress-mochawesome-reporter'
  },
  reporter: 'cypress-multi-reporters',
  reporterOptions: {
    reporterEnabled: "cypress-mochawesome-reporter, spec, mocha-junit-reporter",
    cypressmochawesomereporterOptions: {
      reportDir: "cypress/reports/html",
      charts: true,
      reportPageTitle: "Cypress E2E Tests",
      embeddedScreenshots: true,
      inlineAssets: true,
      saveAllAttempts: false,
      saveHtml: true,
      reportTitle: "Cypress E2E Tests"
    },
    mochaJunitReporterReporterOptions: {
      mochaFile: "test-report-xml/results-[hash].xml"
    }
  },
  chromeWebSecurity: false,
  experimentalSourceRewriting: false,
  video: false,
  screenshotsFolder: 'cypress/reports/html/screenshots',
  modifyObstructiveCode: true,
  pageLoadTimeout: 120000,
  defaultCommandTimeout: 30000,
});

Relevant log output

No response

Anything else?

No response

LironEr commented 2 years ago

You have a typo in your reporterOptions cypressmochawesomereporterOptions should be cypressMochawesomeReporterReporterOptions

ajling commented 2 years ago

@LironEr thank you and sorry for the trouble, didn't even think to check that. It works perfectly, closing this issue now.