Set threshold for cypress-image-snapshot

This commit is contained in:
Matias Arriola 2021-12-22 12:23:42 -03:00
parent 5e66f1f160
commit 86780ed0e9
3 changed files with 12 additions and 5 deletions

View File

@ -3,7 +3,10 @@ import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';
// make matchImageSnapshot() call the real implementation only if CYPRESS_imageSnaphots is set // make matchImageSnapshot() call the real implementation only if CYPRESS_imageSnaphots is set
// otherwise it calls a noop // otherwise it calls a noop
if (Cypress.env('imageSnaphots')) { if (Cypress.env('imageSnaphots')) {
addMatchImageSnapshotCommand(); addMatchImageSnapshotCommand({
failureThreshold: 0.001,
failureThresholdType: 'percent',
});
} else { } else {
Cypress.Commands.add( Cypress.Commands.add(
'matchImageSnapshot', 'matchImageSnapshot',

View File

@ -3,7 +3,10 @@ import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';
// make matchImageSnapshot() call the real implementation only if CYPRESS_imageSnaphots is set // make matchImageSnapshot() call the real implementation only if CYPRESS_imageSnaphots is set
// otherwise it calls a noop // otherwise it calls a noop
if (Cypress.env('imageSnaphots')) { if (Cypress.env('imageSnaphots')) {
addMatchImageSnapshotCommand(); addMatchImageSnapshotCommand({
failureThreshold: 0.001,
failureThresholdType: 'percent',
});
} else { } else {
Cypress.Commands.add( Cypress.Commands.add(
'matchImageSnapshot', 'matchImageSnapshot',

View File

@ -1,12 +1,13 @@
import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command'; import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';
import '@testing-library/cypress/add-commands'; import '@testing-library/cypress/add-commands';
addMatchImageSnapshotCommand();
// make matchImageSnapshot() call the real implementation only if CYPRESS_imageSnaphots is set // make matchImageSnapshot() call the real implementation only if CYPRESS_imageSnaphots is set
// otherwise it calls a noop // otherwise it calls a noop
if (Cypress.env('imageSnaphots')) { if (Cypress.env('imageSnaphots')) {
addMatchImageSnapshotCommand(); addMatchImageSnapshotCommand({
failureThreshold: 0.001,
failureThresholdType: 'percent',
});
} else { } else {
Cypress.Commands.add( Cypress.Commands.add(
'matchImageSnapshot', 'matchImageSnapshot',