jaredpalmer / cypress-image-snapshot

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

cy.task('Matching image snapshot') failed with the following error #235

Open lasithdilshan20 opened 2 years ago

lasithdilshan20 commented 2 years ago

Hi, I'm using image snapshot lib and I got the following issue with it.

image

mersanuzun commented 2 years ago

I faced the same issue. Which cypres version do you use? I use cypress: 10.1.0 so that I added following code to my cypress.config.ts file and it was solved for me.

// cypress.config.ts
import {addMatchImageSnapshotPlugin} from 'cypress-image-snapshot/plugin';

export default defineConfig({
    ...restConfigs
    setupNodeEvents(on, config) {
        addMatchImageSnapshotPlugin(on, config);
    },
    ...restConfigs
});
believer-ufa commented 1 year ago

Little addition: you need to set setupNodeEvents inside e2e or component config sections as described in Cypress documentation.

jxe142 commented 1 year ago

Has this been resolved? I am using Cypress 9 and still have this issue

believer-ufa commented 1 year ago

that's not an issue. you just need properly configure your plugin, instructions already given above.

robbertvancaem commented 1 year ago

I ran into this as well and thought it might help to share the full cypress.config.js I have:

const { defineConfig } = require('cypress')
const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin')

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
      addMatchImageSnapshotPlugin(on, config)
    },
  }
})

As you can see, there's no need to create a plugins folder with configuration anymore.

Cypress version: 10.3.1

Estherokafor05 commented 1 year ago

Kudos, this just fixed my error

Pavel-Y96 commented 1 year ago

Thanks you so much! )) (c)0990. 4599===2sd