mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Merge pull request #32766 from dawnmist/update/jest-image-snapshot
[jest-image-snapshot]: Update to fix #32760 & for library updates
This commit is contained in:
18
types/jest-image-snapshot/index.d.ts
vendored
18
types/jest-image-snapshot/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for jest-image-snapshot 2.4
|
||||
// Type definitions for jest-image-snapshot 2.8
|
||||
// Project: https://github.com/americanexpress/jest-image-snapshot#readme
|
||||
// Definitions by: Janeene Beeforth <https://github.com/dawnmist>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -26,10 +26,18 @@ export interface MatchImageSnapshotOptions {
|
||||
* Absolute path of a directory to keep the snapshot in.
|
||||
*/
|
||||
customSnapshotsDir?: string;
|
||||
/**
|
||||
* A custom absolute path of a directory to keep this diff in
|
||||
*/
|
||||
customDiffDir?: string;
|
||||
/**
|
||||
* A custom name to give this snapshot. If not provided, one is computed automatically.
|
||||
*/
|
||||
customSnapshotIdentifier?: string;
|
||||
/**
|
||||
* Changes diff image layout direction, default is horizontal.
|
||||
*/
|
||||
diffDirection?: 'horizontal' | 'vertical';
|
||||
/**
|
||||
* Removes coloring from the console output, useful if storing the results to a file.
|
||||
* Defaults to false.
|
||||
@@ -47,6 +55,10 @@ export interface MatchImageSnapshotOptions {
|
||||
* Defaults to 'pixel'.
|
||||
*/
|
||||
failureThresholdType?: 'pixel' | 'percent';
|
||||
/**
|
||||
* Updates a snapshot even if it passed the threshold against the existing one, defaults to false.
|
||||
*/
|
||||
updatePassedSnapshot?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +67,7 @@ export interface MatchImageSnapshotOptions {
|
||||
* import { toMatchImageSnapshot } from 'jest-image-snapshot';
|
||||
* expect.extend({ toMatchImageSnapshot });
|
||||
*/
|
||||
export function toMatchImageSnapshot(): { message(): string; pass: boolean; };
|
||||
export function toMatchImageSnapshot(options?: MatchImageSnapshotOptions): { message(): string; pass: boolean; };
|
||||
|
||||
/**
|
||||
* Configurable function that can be passed to jest's expect.extend.
|
||||
@@ -69,7 +81,7 @@ export function configureToMatchImageSnapshot(options: MatchImageSnapshotOptions
|
||||
declare global {
|
||||
namespace jest {
|
||||
interface Matchers<R> {
|
||||
toMatchImageSnapshot(): R;
|
||||
toMatchImageSnapshot(options?: MatchImageSnapshotOptions): R;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Typescript Version: 2.3
|
||||
import { toMatchImageSnapshot, configureToMatchImageSnapshot } from 'jest-image-snapshot';
|
||||
import { toMatchImageSnapshot, configureToMatchImageSnapshot, MatchImageSnapshotOptions } from 'jest-image-snapshot';
|
||||
|
||||
it('should be able to use toMatchImageSnapshot in a test', () => {
|
||||
expect.extend({ toMatchImageSnapshot });
|
||||
@@ -21,3 +21,22 @@ it('should be able to use configureToMatchImageSnapshot in a test', () => {
|
||||
|
||||
expect('Me').toMatchImageSnapshot();
|
||||
});
|
||||
|
||||
it('Should be able to use configuration directly in toMatchImageSnapshot', () => {
|
||||
expect.extend({ toMatchImageSnapshot });
|
||||
|
||||
const options: MatchImageSnapshotOptions = {
|
||||
noColors: true,
|
||||
customDiffConfig: {
|
||||
threshold: 5,
|
||||
includeAA: false
|
||||
},
|
||||
customDiffDir: './diffs',
|
||||
diffDirection: 'vertical',
|
||||
updatePassedSnapshot: true,
|
||||
failureThreshold: 10,
|
||||
failureThresholdType: 'percent'
|
||||
};
|
||||
|
||||
expect('Me').toMatchImageSnapshot(options);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user