Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 32 additions & 14 deletions index.d.ts
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;
}