americanexpress / jest-image-snapshot

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

Feature: Add `runtimeHooksPath` options with `onBeforeWriteToDiscPath` in it #337

Closed Ayc0 closed 10 months ago

Ayc0 commented 1 year ago

Description

Add a new top level option runtimeHooksPath that contains a potential path to a JS file. This file can contain multiple hooks when diffSnapshot is called, like onBeforeWriteToDiscPath (to be able to inject EXIF data to PNGs without building this feature into this library).

The reason why I exposed that via a path to a JS file instead of exposing a function, is because diffSnapshot is sometimes called from a worker, and we cannot serialize properly functions.

For now there is only onBeforeWriteToDiscPath but I made that generic enough to be able to add more features to it in the future.

Motivation and Context

Fixes: https://github.com/americanexpress/jest-image-snapshot/issues/332

How Has This Been Tested?

I added unit tests for this feature

Types of Changes

Checklist:

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

It shouldn't impact them at all as long as they don't use this new feature

Ayc0 commented 1 year ago

@code-forger what do you think about this new feature?

Ayc0 commented 10 months ago

FYI, due to bade294, the command npm run test:git-history seems to be failing:

image image
oneamexbot commented 10 months ago

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

The release is available on:

Your semantic-release bot :package::rocket: