forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phantomcss.d.ts
144 lines (128 loc) · 4.77 KB
/
phantomcss.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Type definitions for PhantomCSS 0.11.1
// Project: https://github.com/Huddle/PhantomCSS
// Definitions by: Amaury Bauzac <https://github.com/abauzac>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../casperjs/casperjs.d.ts" />
/// <reference path="../resemblejs/resemblejs.d.ts" />
declare namespace PhantomCSS {
interface PhantomCSS {
init(options: PhantomCSSOptions): void;
update(options: PhantomCSSOptions): void;
/**
* Take a screenshot of the targeted HTML element
* FileName is required if addIteratorToImage option is set to false
*/
screenshot(target: string, fileName?: string): void;
/**
* Take a screenshot of the targeted HTML element
* FileName is required if addIteratorToImage option is set to false
*/
screenshot(target: ClipRect, fileName?: string): void;
/**
* Take a screenshot of the targeted HTML element
* FileName is required if addIteratorToImage option is set to false
*/
screenshot(target: string, timeToWait: number, hideSelector: string, fileName?: string): void;
compareAll(exclude: string): void;
compareAll(exclude: string, diffList: string[], include: string): void;
compareMatched(match: string, exclude: string): void;
compareMatched(match: RegExp, exclude: RegExp): void;
/**
* Explicitly define what files you want to compare
*/
compareExplicit(list: string[]): void;
/**
* Compare image diffs generated in this test run only
*/
compareSession(list?: any[]): void;
compareFiles(baseFile: string, diffFiles: string): PhantomCSSTest;
waitForTests(tests: PhantomCSSTest[]): void;
done(): void;
/**
* Turn off CSS transitions and jQuery animations
*/
turnOffAnimations(): void;
getExitStatus(): number;
/**
* Get a list of image diffs generated in this test run
*/
getCreatedDiffFiles(): Array<string>;
}
interface PhantomCSSTest {
filename?: string;
error?: boolean;
fail?: boolean;
success?: boolean;
failFile?: string;
mismatch?: any;
}
interface PhantomCSSOptions {
/**
Rebase is useful when you want to create new baseline
images without manually deleting the files
casperjs demo/test.js --rebase
*/
rebase?: any;
/**
A reference to a particular Casper instance. Required for SlimerJS.
*/
casper?: Casper;
/**
libraryRoot is relative to this file and must point to your phantomcss folder (not lib or node_modules). If you are using NPM, this will be './node_modules/phantomcss'.
*/
libraryRoot?: string;
screenshotRoot?: string;
/**
By default, failure images are put in the './failures' folder.
If failedComparisonsRoot is set to false a separate folder will
not be created but failure images can still be found alongside
the original and new images.
*/
failedComparisonsRoot?: string;
/**
You might want to keep master/baseline images in a completely
different folder to the diffs/failures. Useful when working
with version control systems. By default this resolves to the
screenshotRoot folder.
*/
comparisonResultRoot?: string;
/**
Don't add count number to images. If set to false (default), a filename is
required when capturing screenshots.
*/
addIteratorToImage: boolean;
/**
Remove results directory tree after run. Use in conjunction
with failedComparisonsRoot to see failed comparisons.
*/
cleanupComparisonImages?: boolean;
/**
* Don't add label to generated failure image
*/
addLabelToFailedImage?: boolean;
/**
* Change the output screenshot filenames for your specific
* integration
*/
fileNameGetter?: (rootPath: string, fileName?: string) => string;
/**
Mismatch tolerance defaults to 0.05%. Increasing this value
will decrease test coverage
*/
mismatchTolerance?: number;
onPass?: (test: PhantomCSSTest) => void;
onFail?: (test: PhantomCSSTest) => void;
onTimeout?: (test: PhantomCSSTest) => void;
onComplete?: (tests: PhantomCSSTest[], noOfFails: number, noOfErrors: number) => void;
/**
Called when creating new baseline images
*/
onNewImage?: (test: PhantomCSSTest) => void;
/**
Prefix the screenshot number to the filename, instead of suffixing it
*/
prefixCount?: boolean;
hideElements?: string;
outputSettings?: Resemble.OutputSettings;
}
}