DefinitelyTyped/types/jest-image-snapshot/jest-image-snapshot-tests.ts
2019-02-14 12:40:39 -06: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);
});