2021-12-02 00:41:56 +00:00
|
|
|
import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';
|
|
|
|
|
2021-12-17 02:13:54 +00:00
|
|
|
// make matchImageSnapshot() call the real implementation only if CYPRESS_imageSnaphots is set
|
|
|
|
// otherwise it calls a noop
|
|
|
|
if (Cypress.env('imageSnaphots')) {
|
2021-12-22 12:23:42 -03:00
|
|
|
addMatchImageSnapshotCommand({
|
|
|
|
failureThreshold: 0.001,
|
|
|
|
failureThresholdType: 'percent',
|
|
|
|
});
|
2021-12-17 02:13:54 +00:00
|
|
|
} else {
|
|
|
|
Cypress.Commands.add(
|
|
|
|
'matchImageSnapshot',
|
|
|
|
{
|
|
|
|
prevSubject: ['optional', 'element', 'window', 'document'],
|
|
|
|
},
|
|
|
|
() => Promise.resolve(),
|
|
|
|
);
|
|
|
|
}
|
2021-12-21 18:05:03 +00:00
|
|
|
|
|
|
|
// https://www.cypress.io/blog/2020/02/12/working-with-iframes-in-cypress/
|
2022-07-12 18:58:11 -07:00
|
|
|
Cypress.Commands.add('getIframeBody', () =>
|
|
|
|
cy.get('iframe').its('0.contentDocument.body').should('not.be.empty').then(cy.wrap),
|
|
|
|
);
|