Guide
Playwright vs Cypress vs Puppeteer: E2E Testing in 2026



Compare Playwright, Cypress, and Puppeteer for end-to-end testing. Speed, DX, parallel execution, browser support, and which E2E testing framework to choose.
Contents
Contents
TL;DR
Use Playwright Test for E2E suites that need Chromium, Firefox, and WebKit projects with built-in workers and trace capture. Choose Cypress if your team relies on its interactive runner or wants component and E2E tests in the same workflow. Use Puppeteer when the job is browser automation such as screenshots or PDF generation.
Key Takeaways
- Playwright lets you run the same test in browser projects and inspect failures in Trace Viewer.
- Cypress has an interactive runner and a component testing workflow. Check browser support separately for each kind of test.
- Puppeteer automates Chrome and Firefox. Pair it with a test runner if you also need assertions and reports.
Download Trends
These npm counts cover the week of November 23–29, 2026. The Playwright row counts the test runner package separately from the browser automation library.
| npm package | Downloads in the period |
|---|---|
@playwright/test | 130,528,297 |
cypress | 6,938,056 |
puppeteer | 14,307,169 |
CI installs and transitive dependencies can contribute to these totals. Use the counts as package activity signals, and choose the tool based on the browsers and workflow you need.
Playwright
Playwright provides a common automation API for Chromium, Firefox, and WebKit. Playwright Test adds browser projects, assertions, and trace capture.
// playwright.config.ts
import { defineConfig, devices } from "@playwright/test"
export default defineConfig({
testDir: "./tests/e2e",
fullyParallel: true, // All tests run in parallel by default
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 4 : undefined,
reporter: [["html", { open: "never" }]],
use: {
baseURL: "http://localhost:3000",
trace: "on-first-retry", // Capture trace on failure
screenshot: "only-on-failure",
video: "on-first-retry",
},
projects: [
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
{ name: "firefox", use: { ...devices["Desktop Firefox"] } },
{ name: "webkit", use: { ...devices["Desktop Safari"] } },
{ name: "Mobile Chrome", use: { ...devices["Pixel 5"] } },
{ name: "Mobile Safari", use: { ...devices["iPhone 13"] } },
],
webServer: {
command: "npm run dev",
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
},
})
Writing Playwright tests:
import { test, expect } from "@playwright/test"
test.describe("Package search", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/")
})
test("searches for a package and shows results", async ({ page }) => {
// Auto-waits for elements — no explicit waits needed:
await page.getByPlaceholder("Search packages...").fill("react")
await page.getByRole("button", { name: "Search" }).click()
// Assertions auto-wait for the condition:
await expect(page.getByTestId("results-list")).toBeVisible()
await expect(page.getByText("react")).toBeVisible()
await expect(page.locator(".result-count")).toContainText("results")
})
test("navigates to package comparison page", async ({ page }) => {
await page.goto("/compare/react-vs-vue")
await expect(page).toHaveTitle(/React vs Vue/)
await expect(page.getByRole("heading", { level: 1 })).toContainText("React vs Vue")
// Check comparison table exists:
await expect(page.getByRole("table")).toBeVisible()
})
test("handles API errors gracefully", async ({ page }) => {
// Mock network requests:
await page.route("**/api/packages/**", (route) => {
route.fulfill({ status: 500, body: "Internal Server Error" })
})
await page.goto("/packages/react")
await expect(page.getByTestId("error-message")).toBeVisible()
await expect(page.getByText("Something went wrong")).toBeVisible()
})
})
Playwright Trace Viewer:
When a test fails, Playwright captures a full trace:
- Network requests with request/response
- Console logs
- DOM snapshots at each step
- Screenshots and video
npx playwright show-trace test-results/trace.zip
Playwright UI Mode:
npx playwright test --ui
Opens a browser-based interactive runner showing tests in real-time — similar to Cypress's interactive mode.
Page Object Model in Playwright:
// tests/pages/PackagePage.ts
import { Page, Locator } from "@playwright/test"
export class PackagePage {
readonly page: Page
readonly heading: Locator
readonly downloadChart: Locator
readonly compareButton: Locator
constructor(page: Page) {
this.page = page
this.heading = page.getByRole("heading", { level: 1 })
this.downloadChart = page.getByTestId("download-chart")
this.compareButton = page.getByRole("button", { name: /compare/i })
}
async goto(packageName: string) {
await this.page.goto(`/packages/${packageName}`)
}
async addToComparison() {
await this.compareButton.click()
return this.page.waitForURL(/\/compare\//)
}
}
// Usage in test:
test("package page shows download chart", async ({ page }) => {
const pkgPage = new PackagePage(page)
await pkgPage.goto("react")
await expect(pkgPage.downloadChart).toBeVisible()
})
Cypress
Cypress remains excellent for its interactive debugging experience and component testing integration:
// cypress.config.ts
import { defineConfig } from "cypress"
export default defineConfig({
e2e: {
baseUrl: "http://localhost:3000",
specPattern: "cypress/e2e/**/*.cy.ts",
supportFile: "cypress/support/e2e.ts",
},
component: {
devServer: {
framework: "next",
bundler: "webpack",
},
specPattern: "**/*.cy.tsx",
},
video: false,
screenshotOnRunFailure: true,
})
Cypress E2E test:
// cypress/e2e/package-search.cy.ts
describe("Package search", () => {
beforeEach(() => {
cy.visit("/")
})
it("searches and returns results", () => {
cy.findByPlaceholderText("Search packages...").type("react")
cy.findByRole("button", { name: "Search" }).click()
cy.findByTestId("results-list").should("be.visible")
cy.contains("react").should("be.visible")
})
it("intercepts API and stubs response", () => {
// Cypress's network interception:
cy.intercept("GET", "/api/packages/react", { fixture: "react-package.json" }).as("getPackage")
cy.visit("/packages/react")
cy.wait("@getPackage")
cy.get("h1").should("contain", "react")
})
})
Mounting a component in Cypress:
// components/PackageCard.cy.tsx
import { PackageCard } from "./PackageCard"
describe("PackageCard", () => {
it("renders package information", () => {
cy.mount(
<PackageCard
name="react"
downloads={25000000}
version="18.2.0"
/>
)
cy.get("[data-testid='package-name']").should("have.text", "react")
cy.get("[data-testid='downloads']").should("contain", "25,000,000")
cy.get("[data-testid='version']").should("have.text", "18.2.0")
})
it("calls onCompare when button clicked", () => {
const onCompare = cy.stub().as("onCompare")
cy.mount(<PackageCard name="react" onCompare={onCompare} />)
cy.findByRole("button", { name: "Compare" }).click()
cy.get("@onCompare").should("have.been.calledWith", "react")
})
})
Cypress component tests run in the real browser with your actual dev server — same environment as E2E tests.
Puppeteer
Puppeteer is a browser automation library, not a test framework. The distinction matters:
import puppeteer from "puppeteer"
// Puppeteer use case 1: Screenshot generation
async function captureOGImage(url: string): Promise<Buffer> {
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage()
await page.setViewport({ width: 1200, height: 630 })
await page.goto(url, { waitUntil: "networkidle0" })
const screenshot = await page.screenshot({ type: "png" })
await browser.close()
return screenshot
}
// Puppeteer use case 2: PDF generation
async function generatePDF(html: string): Promise<Buffer> {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.setContent(html, { waitUntil: "networkidle0" })
const pdf = await page.pdf({ format: "A4", printBackground: true })
await browser.close()
return pdf
}
// Puppeteer use case 3: Web scraping
async function scrapeNpmDownloads(packageName: string): Promise<number> {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto(`https://www.npmjs.com/package/${packageName}`)
const downloads = await page.$eval(
"[data-testid='weekly-downloads']",
(el) => parseInt(el.textContent?.replace(/,/g, "") ?? "0")
)
await browser.close()
return downloads
}
Waiting for a result in Puppeteer and Playwright Test
Puppeteer locators wait for action prerequisites. If a results panel appears after a click, a lower-level selector wait can check visibility explicitly. Your test runner controls retries of the entire test. Puppeteer page interactions
// Puppeteer
await page.locator('button[type="submit"]').click()
await page.waitForSelector('.results', { visible: true })
// Playwright Test
await page.locator('button[type="submit"]').click()
await expect(page.locator('.results')).toBeVisible()
Performance Comparison
| Tool | Parallel CI setup | What to measure |
|---|---|---|
| Playwright Test | Uses workers and supports sharding across CI jobs | Whether slow spec files leave some shards idle |
| Cypress | Split specs in your CI matrix or use Cypress Cloud to distribute recorded runs | Whether the slowest batch determines wall-clock time |
| Puppeteer with a test runner | Use the runner to schedule tests and own browser startup and cleanup | Whether fresh browser launches dominate runtime |
Compare the same tests and browser targets on the same CI runner. Record total runner time as well as elapsed time. Additional jobs can shorten the wait for results while increasing total compute.
Feature Comparison
| Feature | Playwright | Cypress | Puppeteer |
|---|---|---|---|
| Browser support | Chromium, Firefox, WebKit | Chrome-family browsers and Firefox, with experimental WebKit | Chrome, Firefox |
| Parallel execution | Workers and sharding in Playwright Test | CI spec splitting or Cypress Cloud orchestration | Configured in a separate test runner |
| Waiting | Locators wait for actions and web assertions retry | Queries and assertions retry | Locators wait for action prerequisites |
| Component testing | Built-in mount fixture opens a story in a browser | Component Testing in Cypress | Set up in a separate test runner |
| Visual testing | ✅ (screenshots) | ✅ (plugins) | ✅ |
| Network mocking | ✅ | ✅ | ✅ |
| Failure artifacts | Trace Viewer and configurable trace capture | Screenshots and optional video | Capture artifacts with your automation code |
| TypeScript | ✅ First-class | ✅ | ✅ |
| Multiple tabs or windows | Browser contexts can hold multiple pages | Additional tabs on Chromium via @cypress/puppeteer | Browser can open multiple pages |
| Mobile emulation | ✅ | ⚠️ Limited | ✅ |
| Interactive runner | ✅ UI Mode | ✅ Cypress App | ❌ |
Production CI Configuration and Flakiness Management
Use retries to collect diagnostics for intermittent failures. Playwright can capture a trace on retry. In Cypress, query and assertion retrying covers many DOM timing issues. For a test whose next step depends on a request, register the intercept before triggering that request and wait for the alias.
Visual Regression Testing Integration
Visual regression testing — capturing screenshots and comparing them against baselines — catches unintended UI changes that functional tests miss. Playwright has a built-in toHaveScreenshot() assertion that captures screenshots and compares them pixel-by-pixel with configurable thresholds. The screenshots are committed to the repository as baselines and updated explicitly when intentional visual changes occur. Cypress's visual testing story relies on third-party plugins: Percy (commercial, now deprecated), Applitools, or community solutions. This gives Playwright an advantage for teams wanting visual regression testing without additional service subscriptions. For component-level visual testing, Storybook's Chromatic service (owned by the Storybook maintainers) integrates with both Playwright and Cypress and provides excellent component-level visual diffs on every PR. The combination of Playwright E2E tests plus Chromatic for component visual testing is emerging as the production standard for design-system-driven React applications in 2026.
TypeScript Integration and Code Quality
All three tools support TypeScript, but the quality of TypeScript support differs. Playwright's TypeScript types are maintained as first-class — every API method, option, and return value is precisely typed, providing excellent IDE autocomplete. The page object model pattern in TypeScript with Playwright compiles cleanly and integrates with standard TypeScript tooling. Cypress's TypeScript support works well but has historically required additional type declaration management and some community-maintained types for specific Cypress commands. Puppeteer's types are bundled with the package and are comprehensive. For code quality tooling, ESLint plugins for Playwright (eslint-plugin-playwright) and Cypress (eslint-plugin-cypress) enforce best practices — flagging uses of page.waitForTimeout() (which should be replaced with proper auto-waits) and other patterns that indicate brittle tests. Running these linters in CI as part of the test quality gate prevents flaky pattern introduction before tests are merged.
CI Cost Optimization and Test Parallelization
Use Playwright's --shard to split the suite across CI jobs. If you run Cypress without Cloud orchestration, assign spec lists to the CI jobs and review their timings when the suite grows. Track browser setup and application startup separately so you can see whether changing the workers or shards helps.
Testing Strategy: Where E2E Fits in the Test Pyramid
Reserve full browser journeys for behavior that crosses application boundaries, such as sign-in, checkout, or saving a change and seeing it after reload. Use unit and integration tests to cover edge cases beneath those journeys. Component tests can exercise a complex widget in a browser without running the whole app. Cypress provides a dedicated component runner. In Playwright Test, serve a gallery of component stories from your dev server and pass a story ID to the built-in mount fixture. Playwright component testing
Migration: Cypress → Playwright
// Cypress:
cy.intercept("GET", "/api/npm/*", { fixture: "npm-data.json" })
cy.visit("/packages/react")
cy.get("[data-testid='download-chart']").should("be.visible")
// Playwright equivalent:
await page.route("/api/npm/*", (route) => route.fulfill({ path: "fixtures/npm-data.json" }))
await page.goto("/packages/react")
await expect(page.getByTestId("download-chart")).toBeVisible()
Register the intercept before navigation so it can answer the request the page makes on load. When porting a test, check that the fixture drives the visible state you assert.
When to Use Each
Choose Playwright if:
- Starting a new E2E suite and want a runner with browser projects and traces
- You need WebKit coverage alongside Chromium and Firefox
- You want CI sharding you can schedule in your existing CI jobs
- You need to exercise multiple tabs in Firefox or WebKit
Choose Cypress if:
- You want Cypress’s dedicated component runner and interactive debugging alongside your E2E suite
- Your team values the interactive debugging experience
- Your existing Cypress suite can cover a multi-tab flow on Chromium using
@cypress/puppeteer
Use Puppeteer for:
- Screenshot/OG image generation
- PDF generation from HTML
- Web scraping
- Chrome DevTools Protocol automation
For a Puppeteer-based test suite, budget time to choose and configure your assertions, reporting, and parallel execution separately.
Methodology
The download table uses the npm Downloads API for a single calendar week and the exact package names shown. The workflow comparison uses each project's documentation. To compare speed, run your own representative spec set on matching CI runners and browser targets.
Compare testing library packages on PkgPulse →
See also: Playwright vs Puppeteer and Cypress vs Playwright, Best JavaScript Testing Frameworks Compared (2026).