jest-image-snapshot icon indicating copy to clipboard operation
jest-image-snapshot copied to clipboard

Always generate diff snapshots

Open Tarasikee opened this issue 1 year ago • 1 comments

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

Tarasikee avatar Jun 13 '23 11:06 Tarasikee

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");
  }
};

wilkuintheair avatar Mar 22 '24 08:03 wilkuintheair