americanexpress / jest-image-snapshot

✨ Jest matcher for image comparisons. Most commonly used for visual regression testing.
Apache License 2.0
3.84k stars 200 forks source link

Always generate diff snapshots #335

Open Tarasikee opened 1 year ago

Tarasikee commented 1 year ago

Is there a way to generate diff snapshot even if tests haven't failed?

wilkuintheair commented 8 months ago

Simple try/catch worked for me:

import { expect as jestExpect } from "@jest/globals";

export const expectToMatchSnapshot = async (screenName) => {
  try {
    await jestExpect(screenName).toMatchImageSnapshot();
  } catch (e) {
    console.log("not matching snapshot");
  }
};