Skip to content

Commit f30e781

Browse files
committed
feat(tools): add visual regression testing with playwright and more
- Introduced visual regression tests for the home page, header, and log-in page using Playwright. - Configured snapshot path template in `playwright.config.ts`. - Updated `pre-push` hook to include `npm audit`. - Added `serve` package and removed deprecated `http-serve`. - Updated scripts in `package.json` to support snapshot updates
1 parent 881985f commit f30e781

9 files changed

Lines changed: 838 additions & 210 deletions

File tree

.husky/pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm run knip && npm run lint && npm run test:coverage
1+
npm run knip && npm audit && npm run lint && npm run test:coverage

e2e/fixtures/base.fixture.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ type AppFixtures = {
66
};
77

88
export const test = base.extend<AppFixtures>({});
9+
10+
export { expect } from '@playwright/test';
9.64 KB
Loading

e2e/tests/snapshots/home-page.png

154 KB
Loading
59.4 KB
Loading

e2e/tests/visual.spec.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { expect, test } from '../fixtures/base.fixture';
2+
import { HomePage } from '../pages/home.po';
3+
4+
test.describe('Visual Regression Testing', () => {
5+
let home: HomePage;
6+
7+
test.beforeEach(async ({ page }) => {
8+
home = new HomePage(page);
9+
await home.goto();
10+
});
11+
12+
test('home page should match snapshot', async ({ page }) => {
13+
await home.expectLoaded();
14+
15+
await page.waitForTimeout(1000);
16+
17+
await expect(page).toHaveScreenshot('home-page.png', {
18+
fullPage: true,
19+
mask: [],
20+
});
21+
});
22+
23+
test('header should match snapshot', async ({ page }) => {
24+
await home.expectLoaded();
25+
26+
const header = page.locator('app-header');
27+
await expect(header).toHaveScreenshot('header-component.png');
28+
});
29+
30+
test('log-in page should match snapshot', async ({ page }) => {
31+
await home.header.signInLink.click();
32+
await page.waitForURL('**/auth/log-in');
33+
34+
await expect(page.locator('form')).toBeVisible();
35+
36+
await expect(page).toHaveScreenshot('log-in-page.png', { fullPage: true });
37+
});
38+
});

0 commit comments

Comments
 (0)