Skip to content

Commit

Permalink
Add mask option to regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saundefined committed Aug 20, 2024
1 parent c632d19 commit 12e4538
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/Visual/SmokeTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export type TestPageOptions = {
path: string
options?: object
evaluate?: () => any
mask?: string[]
}

const items: TestPageOptions[] = [
Expand All @@ -12,7 +13,12 @@ const items: TestPageOptions[] = [
evaluate: () => {
const selector = document.querySelector('.elephpants');
selector.remove()
}
},
options: {
fullPage: true,
timeout: 10000,
},
mask: ['.hero-versions'],
},
{
path: 'archive/1998.php',
Expand Down Expand Up @@ -52,6 +58,13 @@ for (const item of items) {
await page.evaluate(item.evaluate)
}

if (typeof item.mask === 'object') {
item.options = {
...item.options,
mask: item.mask.map((selector) => page.locator(selector))
}
}

await expect(page).toHaveScreenshot(
`tests/screenshots/${item.path}.png`,
item.options ?? {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 12e4538

Please sign in to comment.