LironEr / cypress-mochawesome-reporter

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

Failed screenshots not getting attached to html report #166

Closed soma-tf closed 3 months ago

soma-tf commented 9 months ago

Environment

- OS: Mac
- Node: v18.16.1
- cypress-mochawesome-reporter: "^3.6.1"
- cypress: "^12.16.0"

What happened?

According to the documentation if a test fails , cypress-mochawesome-reporter it should take screenshot and attach it to html report. But actual behaviour is , its taking screenshot and saving it inside a folder.

Config file

const { defineConfig } = require("cypress");

// Create a timestamp
const currentDate = new Date().toLocaleString('en-US', {
  year: 'numeric',
  month: '2-digit',
  day: '2-digit',
  hour: '2-digit',
  minute: '2-digit',
  second: '2-digit',
  hour12: false,
  timeZoneName: 'short',
}).replace(/[,/:]/g, '-');

module.exports = defineConfig({
  pageLoadTimeout: 300000,
  modifyObstructiveCode: false,
  responseTimeout: 10000,
  requestTimeout: 10000,
  defaultCommandTimeout: 20000,
  failOnStatusCode: false,
  experimentalSourceRewriting: true, 
  experimentalCspAllowList: true,
  reporter: 'cypress-mochawesome-reporter',
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
      require('cypress-mochawesome-reporter/plugin')(on);

    },
    supportFile: "cypress/support/B2B_Common_Intercepts.js",
    baseUrl: "http://10.88.35.162", //We can't use "http://tf101webappstg" failed DNS lookup
  },
  video: false,
});

Relevant log output

No error as such

Anything else?

No response

frankind commented 9 months ago
reporterOptions: {
    charts: true,
    reportPageTitle:  'Test Report',
    embeddedScreenshots: true,
    inlineAssets: true,
    saveAllAttempts: false
  },

I used this and it work properly.

LironEr commented 9 months ago

Please create a repo with the problem and steps to reproduce the issue so I can have a look.

Thanks.

stale[bot] commented 7 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.

bayu01 commented 6 months ago

I was having the same issue.

Have you added import 'cypress-mochawesome-reporter/register'; to the cypress/support/e2e.js file?

PandharabaleAniketJohnDeere commented 6 months ago

I am also getting the same error. I will create a repo and will push from my personal account. But what I did was write a failed test with following steps:

  1. Open terminal in new folder.
  2. npm init -y
  3. npm install cypress --save-dev
  4. npm i --save-dev cypress-mochawesome-reporter
  5. in cypress/support/e2e/js, I added import 'cypress-mochawesome-reporter/register';
  6. I did not add require('cypress-mochawesome-reporter/plugin')(on);, as it gives error in console for npx cypress run
  7. in cypress.config.js, I added
    
    const { defineConfig } = require("cypress");

module.exports = defineConfig({ reporter: 'cypress-mochawesome-reporter', reporterOptions: { charts: true, reportPageTitle: 'custom-title', embeddedScreenshots: true, inlineAssets: true, saveAllAttempts: false, }, e2e: { setupNodeEvents(on, config) { // implement node event listeners here }, }, });

stale[bot] commented 3 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.