forked from jaredpalmer/cypress-image-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
95 lines (92 loc) · 3.08 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/// <reference types="cypress" />
interface SnapshotOptions {
/**
* If set to true, the build will not fail when the screenshots to compare have different sizes.
* @default false
*/
allowSizeMismatch?: boolean;
/**
* The method by which images are compared.
* `pixelmatch` does a pixel by pixel comparison, whereas `ssim` does a structural similarity comparison.
* @default 'pixelmatch'
*/
comparisonMethod?: 'pixelmatch' | 'ssim';
/**
* Custom config passed to 'pixelmatch' or 'ssim'
*/
customDiffConfig?: {
readonly threshold?: number;
readonly includeAA?: boolean;
};
/**
* Custom snapshots directory.
* 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. When a function is provided
* it is called with an object containing testPath, currentTestName, counter and defaultIdentifier as its first
* argument. The function must return an identifier to use for the snapshot.
*/
customSnapshotIdentifier?:
| ((
parameters: {
testPath: string;
currentTestName: string;
counter: number;
defaultIdentifier: string;
}
) => string)
| string;
/**
* Changes diff image layout direction.
* @default 'horizontal'
*/
diffDirection?: 'horizontal' | 'vertical';
/**
* 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.
* @default false
*/
dumpDiffToConsole?: boolean;
/**
* Removes coloring from the console output, useful if storing the results to a file.
* @default false.
*/
noColors?: boolean;
/**
* Sets the threshold that would trigger a test failure based on the failureThresholdType selected. This is different
* to the customDiffConfig.threshold above - the customDiffConfig.threshold is the per pixel failure threshold, whereas
* this is the failure threshold for the entire comparison.
* @default 0.
*/
failureThreshold?: number;
/**
* Sets the type of threshold that would trigger a failure.
* @default 'pixel'.
*/
failureThresholdType?: 'pixel' | 'percent';
/**
* Updates a snapshot even if it passed the threshold against the existing one.
* @default false.
*/
updatePassedSnapshot?: boolean;
/**
* Applies Gaussian Blur on compared images, accepts radius in pixels as value. Useful when you have noise after
* scaling images per different resolutions on your target website, usually setting its value to 1-2 should be
* enough to solve that problem.
* @default 0.
*/
blur?: number;
/**
* Runs the diff in process without spawning a child process.
* @default false.
*/
runInProcess?: boolean;
}
export interface Options
extends Partial<Cypress.ScreenshotOptions & SnapshotOptions> {}