cypress-mochawesome-reporter icon indicating copy to clipboard operation
cypress-mochawesome-reporter copied to clipboard

Failed screenshots not getting attached to html report

Open soma-tf opened this issue 1 year ago • 5 comments

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

soma-tf avatar Nov 06 '23 16:11 soma-tf

reporterOptions: {
    charts: true,
    reportPageTitle:  'Test Report',
    embeddedScreenshots: true,
    inlineAssets: true,
    saveAllAttempts: false
  },

I used this and it work properly.

frankind avatar Dec 01 '23 02:12 frankind

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

Thanks.

LironEr avatar Dec 01 '23 15:12 LironEr

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.

stale[bot] avatar Feb 02 '24 06:02 stale[bot]

I was having the same issue.

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

bayu01 avatar Feb 09 '24 23:02 bayu01

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
    },
  },
});

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.

stale[bot] avatar May 13 '24 21:05 stale[bot]