LironEr / cypress-mochawesome-reporter

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

Video path formatted incorrectly #143

Closed marymhart closed 1 year ago

marymhart commented 1 year ago

Environment

- OS: Mac
- Node: 14, 16
- cypress-mochawesome-reporter: 3.4.0
- cypress: 10.4.0

What happened?

The video path is incorrect when the parsed video filename includes a leading separator. For example, for the string src/integration/systemAlert/systemAlert.spec.js, the baseFolder is parsed as src/integration/systemAlert so createVideoContext returns videos//systemAlert.spec.js.mp4 as the value. This happens with or without defining the videosFolder in the config. The linked PR fixes this issue with path.normalize.

function createVideoContext(video, mochawesomeOptions, baseFolder) {
  video = video.replace(baseFolder, '').concat('.mp4');
  return {
    title: 'Spec video recording',
    value: encodeMediaPath(`videos/${video})
  };
}

Config file

const { defineConfig } = require('cypress');
const setupNodeEvents = require('../src/plugins/index');

module.exports = defineConfig({
  reporter: 'cypress-mochawesome-reporter',
  video: true,
  e2e: {
    baseUrl: '***',
    chromeWebSecurity: false,
    defaultCommandTimeout: 20000,
    taskTimeout: 120000,
    requestTimeout: 10000,
    fixturesFolder: 'src/fixtures',
    specPattern: 'src/integration',
    setupNodeEvents,
    screenshotsFolder: 'reports/media/screenshots',
    supportFile: 'src/support/index.js',
    videosFolder: 'reports/media/videos',
    viewportHeight: 800,
    viewportWidth: 1280,
    reporterOptions: {
      reportDir: 'reports',
      overwrite: false,
      charts: true,
      reportFilename: 'mochawesome.html',
      embeddedScreenshots: true,
      saveAllAttempts: false,
      ignoreVideos: false,
    },
    env: {},
  },
});

Relevant log output

No response

Anything else?

No response

LironEr commented 1 year ago

Released in v3.5.0