jaredpalmer / cypress-image-snapshot

Catch visual regressions in Cypress
MIT License
888 stars 160 forks source link

Image was NaN% different from saved snapshot with undefined different pixels #120

Open nani554 opened 4 years ago

nani554 commented 4 years ago

Getting this issue when i am using cypress-image-snapshot plugin and after screenshot event, one after the other Eg:

const fs = require('fs');
const path = require('path');
const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin');
const _ = require('lodash');
const getImageName = require('../fixtures/common-functions').getImageName;

module.exports = (on, config) => {
  on('after:screenshot', (details) => {
    if (details.testFailure) {
      let folders = details.specName.split('\\');
      let pathArray = details.path.split('\\');
      let imageName = getImageName(true, pathArray[pathArray.length - 1])
      const newPath = path.resolve(__dirname, `../reports/mochawesome-report/reporter-assets/${folders[0]}/${folders[1]}/${imageName}`)
      fs.renameSync(details.path, newPath)
      return { path: newPath }
    }
  })
  addMatchImageSnapshotPlugin(on, config);
}

note: Tried with rename async. still not resolved

version using:

cypress: 3.8.3 cypress-image-snapshot: 3.1.1

nani554 commented 4 years ago

Later tried with cypress: 4.1.0, still not fixed, it would be a big help if its solved, thank you

nani554 commented 4 years ago

Please look into this issue opened in cypress to get more clarity on the issue. https://github.com/cypress-io/cypress/issues/6648