intermediate
Synthetic tests
Run repeatable lab checks for pages, APIs, or flows to catch regressions before or after deployment.
Synthetic tests run scripted checks from controlled environments—Lighthouse CI, Playwright timings, k6 smoke, or uptime pings—to catch regressions before users do. They are **repeatable** but may not match real devices and networks.
| Use case | Tooling examples | |----------|------------------| | Web vitals budget | Lighthouse CI, SpeedCurve | | API latency smoke | k6, Artillery, cron + curl | | Critical journey | Playwright with performance marks | | Deploy gate | Fail CI if LCP budget exceeded |
performance.mark('start');
await page.goto('/checkout');
performance.measure('checkout-load', 'start');
Run synthetics on **staging that mirrors production** config (CDN, compression, SSR). Store history to diff builds. Complement—not replace—field data.
On interviews: lab vs field; flaky synthetic causes; what to gate in CI vs monitor only; synthetic geography choices.
Common pitfalls: testing localhost without CDN; single-run Lighthouse scores; ignoring variance between runs.
The trade-off is early regression detection versus maintenance of realistic test environments.
Checklist:
- Budget key routes in CI.
- Run multiple samples; use medians.
- Match production caching and CDN.
- Pair with RUM for validation.