1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

Add mask option to regression tests

This commit is contained in:
Sergey Panteleev
2024-08-20 09:53:39 +03:00
parent c632d199d1
commit 12e45386e8
2 changed files with 14 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ export type TestPageOptions = {
path: string
options?: object
evaluate?: () => any
mask?: string[]
}
const items: TestPageOptions[] = [
@@ -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',
@@ -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 ?? {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB