Skip to content

Commit

Permalink
🤖 Merge PR #63501 [jest-image-snapshot] add onlyDiff option added i…
Browse files Browse the repository at this point in the history
…n version 6.1.0 by @Ayc0

* [jest-image-snapshot] add `onlyDiff` option

Add changes introduced in americanexpress/jest-image-snapshot#317 to the types

* [jest-image-snapshot] update version reference

* [jest-image-snapshot] add reference to author Ayc0

* [jest-image-snapshot] add tests for onlyDiff
  • Loading branch information
Ayc0 committed Dec 6, 2022
1 parent e242a3a commit 1ac821e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion types/jest-image-snapshot/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Type definitions for jest-image-snapshot 5.1
// Type definitions for jest-image-snapshot 6.1
// Project: https://github.com/americanexpress/jest-image-snapshot#readme
// Definitions by: Janeene Beeforth <https://github.com/dawnmist>
// erbridge <https://github.com/erbridge>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Ayc0 <https://github.com/Ayc0>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 4.3

Expand Down Expand Up @@ -65,6 +66,12 @@ export interface MatchImageSnapshotOptions {
* @default 'horizontal'
*/
diffDirection?: 'horizontal' | 'vertical' | undefined;
/**
* Either only include the difference between the baseline and the received image in the diff image, or include
* the 3 images (following the direction set by `diffDirection`).
* @default false
*/
onlyDiff?: boolean | undefined;
/**
* Will output base64 string of a diff image to console in case of failed tests (in addition to creating a diff image).
* This string can be copy-pasted to a browser address string to preview the diff for a failed test.
Expand Down
2 changes: 2 additions & 0 deletions types/jest-image-snapshot/jest-image-snapshot-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ it('should be able to use configureToMatchImageSnapshot in a test', () => {
threshold: 5,
includeAA: false,
},
onlyDiff: false,
failureThreshold: 10,
failureThresholdType: 'percent',
});
Expand All @@ -41,6 +42,7 @@ it('Should be able to use configuration directly in toMatchImageSnapshot', () =>
storeReceivedOnFailure: true,
customReceivedDir: '/usr/local/__received_output__',
diffDirection: 'vertical',
onlyDiff: false,
dumpInlineDiffToConsole: true,
updatePassedSnapshot: true,
failureThreshold: 10,
Expand Down

0 comments on commit 1ac821e

Please sign in to comment.