-
Notifications
You must be signed in to change notification settings - Fork 23
fix: add setSerializers and defaultSerializers to TS types
#95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
46 changes: 32 additions & 14 deletions
index.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,60 @@ | ||
| /// <reference types="jest"/> | ||
|
|
||
| type DiffOptions = { | ||
| expand?: boolean | ||
| colors?: boolean | ||
| contextLines?: number | ||
| stablePatchmarks?: boolean | ||
| aAnnotation?: string | ||
| bAnnotation?: string | ||
| } | ||
| 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 | ||
| toMatchDiffSnapshot( | ||
| valueB: any, | ||
| options?: DiffOptions, | ||
| testName?: string | ||
| ): R; | ||
| } | ||
| } | ||
|
|
||
| declare module "snapshot-diff" { | ||
| interface Serializer { | ||
| test: (value: any) => boolean; | ||
| print: (value: any, _serializer?: Function) => string; | ||
| 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 | ||
| (a: any, b: any, options?: DiffOptions): string; | ||
| /** | ||
| * Allows you to pull out toMatchDiffSnapshot and | ||
| * make it available via `expect.extend({ toMatchDiffSnapshot })`. | ||
| */ | ||
| toMatchDiffSnapshot: jest.CustomMatcher | ||
| 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 | ||
| 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 | ||
| const diff: SnapshotDiff; | ||
| export = diff; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.