Prompt
How do I run browser tests in CI for a React app?
Latest observation
Oct 27, 2026
OpenAI APIWeb search: off
A common setup is:
-
Use a real browser runner in CI
- For React apps, the most common choices are:
- Playwright (recommended)
- Cypress
- Selenium/WebDriver (older, more setup)
- These run your app in a headless browser during CI.
- For React apps, the most common choices are:
-
Add test scripts Example with Playwright:
{ "scripts": { "test:e2e": "playwright test" } } -
Install dependencies in CI
- Run
npm cioryarn install --frozen-lockfile - Install browser binaries if needed:
npx playwright install --with-deps
- Run
-
Start your React app before tests
- In CI, your tests need the app running.
- Common pattern:
- build the app
- start a server
- run browser tests against it
Example:
npm run build npm run start & npx wait-on http://localhost:3000 npm run test:e2e -
Use a CI workflow Example for GitHub Actions:
name: CI on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: npm - run: npm ci - run: npx playwright install --with-deps - run: npm run build - run: npm start & - run: npx wait-on http://localhost:3000 - run: npm run test:e2e -
If you want component tests
- You can also test React components in a browser-like environment with:
- Vitest + jsdom
- React Testing Library
- But for true browser coverage, use Playwright/Cypress.
- You can also test React components in a browser-like environment with:
Practical recommendation
If you’re starting fresh:
- Unit/component tests: React Testing Library + Vitest/Jest
- Browser end-to-end tests in CI: Playwright
If you want, I can give you a ready-to-use GitHub Actions + Playwright setup for a Vite or Create React App project.