americanexpress / jest-image-snapshot

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

feat: allow storing received screenshot on failure #298

Closed ablok closed 2 years ago

ablok commented 2 years ago

Description

Currently, when a screenshot test fails, the actual (received) image is not stored, other than in a diff image. This PR allows users to set 2 variables: storeReceivedOnFailure and customReceivedDir. When a test fails, and storeReceivedOnFailure is set to true, the received image will also be stored. You can optionally specify a custom location where to store these images by setting customReceivedDir. Not really sure about the naming. Could also use actual instead of received. The feature is currently an addition, but could also be a toggle between storing the composed diff image or storing seperate images. 🤷‍♂️

Motivation and Context

This fixes #260 . This is useful when running in CI. If a screenshot test fails. you can get a new baseline image directly from the build and commit it as the new baseline if the change is as expected.

How Has This Been Tested?

Added unit tests. Tested it locally.

Types of Changes

Checklist:

What is the Impact to Developers Using Jest-Image-Snapshot?

Impact should be none. Use of this feature is optional.

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

ablok commented 2 years ago

Feedback why this is a good/bad idea would be appreciated.

ablok commented 2 years ago

@Matthew-Mallimo could you check the changes I made?

oneamexbot commented 2 years ago

:tada: This PR is included in version 5.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: