forked from jest-community/snapshot-diff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
60 lines (56 loc) · 1.69 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
/// <reference types="jest"/>
type DiffOptions = {
expand?: boolean;
colors?: boolean;
contextLines?: number;
stablePatchmarks?: boolean;
aAnnotation?: string;
bAnnotation?: string;
};
declare namespace jest {
interface Matchers<R, T> {
/**
* Compare the difference between the actual in the `expect()`
* vs the object inside `valueB` with some extra options.
*/
toMatchDiffSnapshot(
valueB: any,
options?: DiffOptions,
testName?: string
): R;
}
}
interface Serializer {
test: (value: any) => boolean;
print: (value: any, _serializer?: any) => any;
diffOptions?: (valueA: any, valueB: any) => DiffOptions;
}
declare module 'snapshot-diff' {
interface SnapshotDiff {
/**
* Compare the changes from a, to b
*/
(a: any, b: any, options?: DiffOptions): string;
/**
* Allows you to pull out toMatchDiffSnapshot and
* make it available via `expect.extend({ toMatchDiffSnapshot })`.
*/
toMatchDiffSnapshot: jest.CustomMatcher;
/**
* By default Jest adds extra quotes around strings so it makes diff
* snapshots of objects too noisy. To fix this – snapshot-diff comes
* with custom serializer.
*/
getSnapshotDiffSerializer: () => jest.SnapshotSerializerPlugin;
/**
* Add new serializers for unsupported data types, or to set a different
* serializer for React components. If you want to keep the default React
* serializer in place, don't forget to add the default serializers to your
* list of serializers.
*/
setSerializers: (serializers: Array<Serializer>) => void;
defaultSerializers: Array<Serializer>;
}
const diff: SnapshotDiff;
export = diff;
}