Prompt
I'm building a CI pipeline for frontend tests and want something that runs reliably
Latest observation
Oct 12, 2026
OpenAI APIWeb search: off
For a frontend CI pipeline, the most reliable setup is usually:
-
Run tests in a clean, reproducible environment
- Use a pinned Node version.
- Install dependencies from lockfiles only.
- Prefer containerized runners or fixed CI images.
-
Split checks into stages
- Lint / typecheck
- Unit tests
- Component tests
- E2E tests
- Build verification
-
Make tests deterministic
- Avoid real network calls in unit/component tests.
- Mock time, dates, random values, and APIs.
- Seed any randomized test data.
- Use stable selectors in UI tests, like
data-testid.
-
Use browser automation carefully
- For Playwright/Cypress, run in headless mode in CI.
- Allocate enough resources; flaky failures often come from low CPU/memory.
- Retry only the few known flaky E2E tests, not the whole suite.
-
Cache smartly
- Cache package manager artifacts, not
node_modulesunless you know it’s safe. - Keep cache keys tied to lockfiles and Node version.
- Cache package manager artifacts, not
-
Parallelize
- Run tests across workers/shards to keep CI fast.
- Make sure parallelism doesn’t introduce shared-state issues.
-
Add failure diagnostics
- Save screenshots, videos, logs, and traces on test failure.
- Upload artifacts so you can debug without rerunning locally.
-
Control external dependencies
- Use mocks or test doubles for third-party services.
- For integration tests, use ephemeral test environments.
A solid default stack for reliability is:
- Vitest/Jest for unit tests
- Playwright for E2E tests
- GitHub Actions/GitLab CI with pinned Node and cached package manager store
If you want, I can help you design a specific CI workflow for your stack, like:
- GitHub Actions + Playwright
- GitLab CI + Jest
- monorepo setup with caching and sharding