Playwright CI Pipeline Smoke Tests
Run Playwright smoke flows inside a CI pipeline with a dedicated job, browser binary caching, retries for flaky steps, and artifact traces.
Code
// e2e/smoke.spec.ts
import { test, expect } from '@playwright/test';
test('visitor can search and open a result', async ({ page }) => {
await page.goto('/search');
await page.getByLabel('Search').fill('rate limiting');
await page.getByRole('button', { name: 'Search' }).click();
await expect(page.getByRole('listitem')).not.toHaveCount(0);
await page.getByRole('link', { name: /rate/i }).first().click();
await expect(page).toHaveURL(/\/examples\//);
});
test('health endpoint is green', async ({ request }) => {
const res = await request.get('/healthz');
expect(res.ok()).toBeTruthy();
expect(await res.json()).toMatchObject({ status: 'up' });
});
// .github/workflows/smoke.yml(节选)
// smoke:
// runs-on: ubuntu-latest
// steps:
// - uses: actions/checkout@v4
// - run: corepack enable
// - run: pnpm install --frozen-lockfile
// - run: pnpm exec playwright install --with-deps chromium
// env:
// PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.cache/ms-playwright
// - run: pnpm exec playwright test --project=chromium --retries=2
// - uses: actions/upload-artifact@v4
// if: failure()
// with:
// name: traces
// path: test-results/Report a problem with this exampleOpens a pre-filled issue on GitHub.