DefinitelyTyped/types/jest-image-snapshot/jest-image-snapshot-tests.ts
Janeene Beeforth 5b327cf997 [jest-image-snapshot]: Update to fix #32760.
* Add new options to MatchImageSnapshotOptions
* toMatchImageSnapshot can be given options directly instead of needing
   to use configureToMatchImageSnapshot for specifying the options.
2019-02-05 10:38:19 +11:00

43 lines
1.2 KiB
TypeScript

// Typescript Version: 2.3
import { toMatchImageSnapshot, configureToMatchImageSnapshot, MatchImageSnapshotOptions } from 'jest-image-snapshot';
it('should be able to use toMatchImageSnapshot in a test', () => {
expect.extend({ toMatchImageSnapshot });
expect(400).toMatchImageSnapshot();
});
it('should be able to use configureToMatchImageSnapshot in a test', () => {
const matchFn = configureToMatchImageSnapshot({
noColors: true,
customDiffConfig: {
threshold: 5,
includeAA: false
},
failureThreshold: 10,
failureThresholdType: 'percent'
});
expect.extend({ toMatchImageSnapshot: matchFn });
expect('Me').toMatchImageSnapshot();
});
it('Should be able to use configuration directly in toMatchImageSnapshot', () => {
expect.extend({ toMatchImageSnapshot });
const options: MatchImageSnapshotOptions = {
noColors: true,
customDiffConfig: {
threshold: 5,
includeAA: false
},
customDiffDir: './diffs',
diffDirection: 'vertical',
updatePassedSnapshot: true,
failureThreshold: 10,
failureThresholdType: 'percent'
};
expect('Me').toMatchImageSnapshot(options);
});