LironEr / cypress-mochawesome-reporter

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

the function named convertImageToBase64(screenshotsDir, imagePath) from enhanceReport.js is not finding the screenshots #165

Closed A035790 closed 8 months ago

A035790 commented 10 months ago

Environment

- OS: windows 11
- Node: 18.13.0
- cypress-mochawesome-reporter: ^3.6.1
- cypress: 12.14.0

What happened?

image

when enhancing the report, the function named convertImageToBase64(screenshotsDir, imagePath) from enhanceReport.js is not finding the screenshots because the path contains cypress/screenshots/cypress/screenshots.

line 149 in enhanceReport.js is causing the bug image

Config file

import {defineConfig} from 'cypress';
import {createJiraTicketForEachFailedTest, renameScreenshot} from './cypress/support/jiraApiClient';
import allureWriter from '@shelex/cypress-allure-plugin/writer';

export default defineConfig({
  env: {},
  reporter: 'cypress-mochawesome-reporter',
  reporterOptions: {
    charts: true,
    reportPageTitle: 'custom-title',
    embeddedScreenshots: true,
    inlineAssets: true,
    ignoreVideos: false,
    videoOnFailOnly: false,
    quiet: false,
    saveAllAttempts: true,
    debug: false
  },
  defaultCommandTimeout: 14000,
  fixturesFolder: 'cypress/fixtures',
  e2e: {
    setupNodeEvents(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) {

      on('before:browser:launch', function (browser: Cypress.Browser | undefined, launchOptions: Cypress.BrowserLaunchOptions) {});

      on('before:spec', function (spec: Cypress.Spec) {});

      on('before:run', function (details: Cypress.BeforeRunDetails) {});

      on('after:screenshot', (details: Cypress.ScreenshotDetails) => renameScreenshot(details));

      on('after:run', async function (result: CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult) {
          if (config.env.enable_jira_tickets === true) {
            const cypressRunResult = result as CypressCommandLine.CypressRunResult;
            await createJiraTicketForEachFailedTest(cypressRunResult, config.env.jira);
          }
        }
      );

      on('after:spec', function (spec: Cypress.Spec, results: CypressCommandLine.RunResult) {});

      on('task', {
        log(message: string) {
          console.log(message);
          return null;
        }
      });

      require('cypress-mochawesome-reporter/plugin')(on);
      allureWriter(on, config);
      return config;
    },
    baseUrl: 'http://localhost:8080',
    specPattern: 'cypress/e2e/ci/**/*.cy.{js,jsx,ts,tsx}',
    excludeSpecPattern: '**/util/*.ts'
  }
});

Relevant log output

No response

Anything else?

No response

joakim-sch commented 10 months ago

Thanks for the bugreport @A035790 You seem to have a good grasp of the problem, could you create a PR to fix it?

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.