meinaart / cypress-plugin-snapshots

Plugin for snapshot tests in Cypress.io
MIT License
491 stars 116 forks source link

The Argument of toMatchImageSnapshot() needs "imageConfig" key. #116

Closed hisomura closed 3 years ago

hisomura commented 4 years ago

@wolfi3b reported this in https://github.com/meinaart/cypress-plugin-snapshots/issues/54#issuecomment-555974108

If you change toMatchImageSnapshot() setting According to README.md and toMatchImageSnapshot.spec.js, you would write code like below.

cy.visit('/static/stub.html').then(() => {
  cy.document().toMatchImageSnapshot({
    createDiffImage: false,
    threshold: 10000,
    thresholdType: 'pixel',
    name: 'foobar'
  });
});

But it never works as expected. Actually the real implementation needs "imageConfig" key. The Following works expectedly.

cy.visit('/static/stub.html').then(() => {
  cy.document().toMatchImageSnapshot({
    imageConfig: {
      createDiffImage: false,
      threshold: 10000,
      thresholdType: 'pixel',
    },
    name: 'foobar'
  });
});