|
@@ -69,20 +69,27 @@ interface CheckFormMatchOptions {
|
|
|
subTitle?: string
|
|
|
type?: string
|
|
|
wrapperSelector?: string
|
|
|
+ assertion?: (subject: JQuery<HTMLElement>) => void
|
|
|
}
|
|
|
|
|
|
-export const checkFormMatchesSnapshot = (options?: CheckFormMatchOptions) => {
|
|
|
+export const checkFormMatchesSnapshot = (
|
|
|
+ options: CheckFormMatchOptions = {},
|
|
|
+) => {
|
|
|
const title = options?.subTitle
|
|
|
? `${Cypress.currentTest.title} - ${options.subTitle}`
|
|
|
: Cypress.currentTest.title
|
|
|
const wrapperSelector = options?.wrapperSelector || '.formkit-outer'
|
|
|
|
|
|
return cy.wrap(document.fonts.ready).then(() => {
|
|
|
- cy.get(wrapperSelector).matchImage({
|
|
|
- title,
|
|
|
- imagesDir: options?.type
|
|
|
- ? `__image_snapshots__/${options.type}`
|
|
|
- : undefined,
|
|
|
+ cy.wrap(new Promise((resolve) => setTimeout(resolve))).then(() => {
|
|
|
+ cy.get(wrapperSelector)
|
|
|
+ .should(options?.assertion || (() => {}))
|
|
|
+ .matchImage({
|
|
|
+ title,
|
|
|
+ imagesDir: options?.type
|
|
|
+ ? `__image_snapshots__/${options.type}`
|
|
|
+ : undefined,
|
|
|
+ })
|
|
|
})
|
|
|
})
|
|
|
}
|