jaredpalmer / cypress-image-snapshot

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

BDD-like .not #90

Open hex22a opened 5 years ago

hex22a commented 5 years ago

Hey! I've just realised something that might me interesting.

I'm working in a very specific visual effect so i've decided that i want to test that screenshots actually do not match. Apperantaley when I do this

  it('police', () => {
    cy.get('[data-testid=police]').not.matchImageSnapshot();
  });

i'm getting this error in cypress runner

TypeError: cy.get(...).not.matchImageSnapshot is not a function

Workaround

However, we still can do "not" with this syntax

  it('police', () => {
    cy.get('[data-testid=police]').not('matchImageSnapshot');
  });

Also i've noticed that when i use .not snapshots are not being captured.

Screenshot 2019-06-09 at 20 36 08

Do you want me to dive into this problem and prob. submit a PR?

jackjocross commented 5 years ago

@hex22a sorry for the late response, have been on vacation.

If you want to dive into the problem that would be great. Reading over Cypress' not docs it seems that it might only work for checking if the DOM node exists? To support the behavior you described we might need a command like toNotMatchImageSnapshot.

hex22a commented 5 years ago

should I also add toMatchImageSnapshot as an alias to matchImageSnapshot just for consistency? this is also what jest-image-snapshot does