-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisual-regression.spec.ts
More file actions
42 lines (33 loc) · 1.46 KB
/
visual-regression.spec.ts
File metadata and controls
42 lines (33 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { test, expect } from '@playwright/test';
test.describe('Visual Regression @visual', () => {
test('homepage layout matches snapshot', async ({ page }) => {
await page.goto('/');
await expect(page.getByTestId('record-card').first()).toBeVisible();
await page.waitForLoadState('networkidle');
// First run creates the baseline. Subsequent runs compare against it.
// Failed comparisons generate diff images — these get uploaded to Checkly.
await expect(page).toHaveScreenshot('homepage-full.png', {
fullPage: true,
maxDiffPixelRatio: 0.05,
});
});
test('record detail modal layout matches snapshot', async ({ page }) => {
await page.goto('/');
await expect(page.getByTestId('record-card').first()).toBeVisible();
await page.getByTestId('record-card').first().click();
await expect(page.getByTestId('modal-title')).toBeVisible();
await expect(page.getByTestId('record-modal')).toHaveScreenshot('record-modal.png', {
maxDiffPixelRatio: 0.05,
});
});
test('empty search state layout matches snapshot', async ({ page }) => {
await page.goto('/');
await expect(page.getByTestId('record-card').first()).toBeVisible();
await page.getByTestId('search-input').fill('xyznonexistent');
await page.waitForTimeout(500);
await expect(page.getByTestId('empty-state')).toBeVisible();
await expect(page).toHaveScreenshot('empty-search.png', {
maxDiffPixelRatio: 0.05,
});
});
});