|
1 | 1 | /// <reference types="jest"/>
|
2 | 2 |
|
3 | 3 | type DiffOptions = {
|
4 |
| - expand?: boolean |
5 |
| - colors?: boolean |
6 |
| - contextLines?: number |
7 |
| - stablePatchmarks?: boolean |
8 |
| - aAnnotation?: string |
9 |
| - bAnnotation?: string |
10 |
| -} |
| 4 | + expand?: boolean; |
| 5 | + colors?: boolean; |
| 6 | + contextLines?: number; |
| 7 | + stablePatchmarks?: boolean; |
| 8 | + aAnnotation?: string; |
| 9 | + bAnnotation?: string; |
| 10 | +}; |
11 | 11 |
|
12 | 12 | declare namespace jest {
|
13 | 13 | interface Matchers<R, T> {
|
14 | 14 | /**
|
15 | 15 | * Compare the difference between the actual in the `expect()`
|
16 | 16 | * vs the object inside `valueB` with some extra options.
|
17 | 17 | */
|
18 |
| - toMatchDiffSnapshot(valueB: any, options?: DiffOptions, testName?: string): R |
| 18 | + toMatchDiffSnapshot( |
| 19 | + valueB: any, |
| 20 | + options?: DiffOptions, |
| 21 | + testName?: string |
| 22 | + ): R; |
19 | 23 | }
|
20 | 24 | }
|
21 | 25 |
|
22 |
| -declare module "snapshot-diff" { |
| 26 | +interface Serializer { |
| 27 | + test: (value: any) => boolean; |
| 28 | + print: (value: any, _serializer?: Function) => string; |
| 29 | + diffOptions: (valueA: any, valueB: any) => DiffOptions; |
| 30 | +} |
| 31 | + |
| 32 | +declare module 'snapshot-diff' { |
23 | 33 | interface SnapshotDiff {
|
24 | 34 | /**
|
25 | 35 | * Compare the changes from a, to b
|
26 | 36 | */
|
27 |
| - (a: any, b: any, options?: DiffOptions): string |
| 37 | + (a: any, b: any, options?: DiffOptions): string; |
28 | 38 | /**
|
29 | 39 | * Allows you to pull out toMatchDiffSnapshot and
|
30 | 40 | * make it available via `expect.extend({ toMatchDiffSnapshot })`.
|
31 | 41 | */
|
32 |
| - toMatchDiffSnapshot: jest.CustomMatcher |
| 42 | + toMatchDiffSnapshot: jest.CustomMatcher; |
33 | 43 | /**
|
34 | 44 | * By default Jest adds extra quotes around strings so it makes diff
|
35 | 45 | * snapshots of objects too noisy. To fix this – snapshot-diff comes
|
36 | 46 | * with custom serializer.
|
37 | 47 | */
|
38 |
| - getSnapshotDiffSerializer: () => jest.SnapshotSerializerPlugin |
| 48 | + getSnapshotDiffSerializer: () => jest.SnapshotSerializerPlugin; |
| 49 | + /** |
| 50 | + * Add new serializers for unsupported data types, or to set a different |
| 51 | + * serializer for React components. If you want to keep the default React |
| 52 | + * serializer in place, don't forget to add the default serializers to your |
| 53 | + * list of serializers. |
| 54 | + */ |
| 55 | + setSerializers: (serializers: Array<Serializer>) => void; |
| 56 | + defaultSerializers: Array<Serializer>; |
39 | 57 | }
|
40 |
| - const diff: SnapshotDiff |
41 |
| - export = diff |
| 58 | + const diff: SnapshotDiff; |
| 59 | + export = diff; |
42 | 60 | }
|
0 commit comments