mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[jest-image-snapshot] Fix string not assignable to customSnapshotIdentifier fields in MatchImageSnapshotOptions (#41118)
This commit is contained in:
parent
57bd61b26b
commit
a2fb19e08d
14
types/jest-image-snapshot/index.d.ts
vendored
14
types/jest-image-snapshot/index.d.ts
vendored
@ -36,12 +36,14 @@ export interface MatchImageSnapshotOptions {
|
||||
* it is called with an object containing testPath, currentTestName, counter and defaultIdentifier as its first
|
||||
* argument. The function must return an identifier to use for the snapshot.
|
||||
*/
|
||||
customSnapshotIdentifier?: (parameters: {
|
||||
testPath: string;
|
||||
currentTestName: string;
|
||||
counter: number;
|
||||
defaultIdentifier: string;
|
||||
}) => string | string;
|
||||
customSnapshotIdentifier?:
|
||||
| ((parameters: {
|
||||
testPath: string;
|
||||
currentTestName: string;
|
||||
counter: number;
|
||||
defaultIdentifier: string;
|
||||
}) => string)
|
||||
| string;
|
||||
/**
|
||||
* Changes diff image layout direction, default is horizontal.
|
||||
*/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// Typescript Version: 2.3
|
||||
import { toMatchImageSnapshot, configureToMatchImageSnapshot, MatchImageSnapshotOptions } from 'jest-image-snapshot';
|
||||
import { configureToMatchImageSnapshot, MatchImageSnapshotOptions, toMatchImageSnapshot } from 'jest-image-snapshot';
|
||||
|
||||
it('should be able to use toMatchImageSnapshot in a test', () => {
|
||||
expect.extend({ toMatchImageSnapshot });
|
||||
@ -40,3 +40,19 @@ it('Should be able to use configuration directly in toMatchImageSnapshot', () =>
|
||||
|
||||
expect('Me').toMatchImageSnapshot(options);
|
||||
});
|
||||
|
||||
it('Should be able to use string as customSnapshotIdentifier', () => {
|
||||
const options: MatchImageSnapshotOptions = {
|
||||
customSnapshotIdentifier: 'string identifier',
|
||||
};
|
||||
|
||||
expect('Me').toMatchImageSnapshot(options);
|
||||
});
|
||||
|
||||
it('Should be able to use callback as customSnapshotIdentifier', () => {
|
||||
const options: MatchImageSnapshotOptions = {
|
||||
customSnapshotIdentifier: () => 'string identifier',
|
||||
};
|
||||
|
||||
expect('Me').toMatchImageSnapshot(options);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user