Prompt
How do I test a React app across Chrome Firefox and Safari
Latest observation
To test a React app across Chrome, Firefox, and Safari, use a mix of automated browser testing and manual cross-browser checks.
1) Use a cross-browser end-to-end testing tool
The most common choice is Playwright. It can run tests in:
- Chrome / Chromium
- Firefox
- Safari-like browser via WebKit (closest automated option to Safari)
Example setup with Playwright
npm init playwright@latest
Then in playwright.config.ts:
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
{ name: 'webkit', use: { ...devices['Desktop Safari'] } },
],
});
Run:
npx playwright test
2) Add browser support checks in CI
Run your test suite on every pull request in CI so issues are caught early:
- GitHub Actions
- GitLab CI
- CircleCI
- Azure DevOps
A common workflow:
- Install dependencies
- Build the app
- Run unit tests
- Run Playwright tests in Chromium, Firefox, WebKit
3) Use BrowserStack or Sauce Labs for real device/browser coverage
WebKit is good, but Safari quirks can still differ from actual Safari on macOS/iOS. For high confidence, test on:
- real Safari on macOS
- Safari on iPhone/iPad
- older browser versions if needed
Services like:
- BrowserStack
- Sauce Labs
- LambdaTest
let you run tests on real browsers and devices remotely.
4) Use unit/integration tests for React logic
For component-level testing:
- Jest or Vitest
- React Testing Library
These don’t replace browser testing, but they help catch logic issues before browser runs.
5) Manually verify browser-specific behavior
Some issues require manual checks, especially:
- CSS layout differences
- scrolling behavior
- file uploads
- video/audio playback
- clipboard access
- auth redirects
- Safari-specific bugs
6) Common browser compatibility tools
Make sure your build targets modern browsers properly:
- Babel / TypeScript
- Autoprefixer
browserslistinpackage.json- polyfills only where needed
Example browserslist:
{
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
]
}
Recommended approach
If you want the simplest solid setup:
- Playwright for automated cross-browser E2E tests
- React Testing Library for component tests
- BrowserStack/Sauce Labs for real Safari/iOS coverage
- Run everything in CI
If you want, I can give you:
- a step-by-step Playwright setup for a React app
- a GitHub Actions workflow
- or a full example test suite for Chrome/Firefox/Safari