Skip to content
Tutorials Center
My learning

Topics

Lesson 3 of 35 ยท Getting Started

Cypress vs Playwright

Compare Cypress and Playwright: in-browser runner versus out-of-process protocol, languages, browsers, speed, tabs, iframes and ecosystem, and how to choose.

Cypress and Playwright solve the same problem, running automated tests against a real browser, but they are built on opposite ideas. Knowing that difference explains almost everything else about them: why one has a famous visual test runner, why the other handles several tabs with ease, why their commands look different, and why each has its own list of limitations.

This lesson compares them honestly. Neither is "the best". Both are mature, free and open source at their core, and both are used by large teams. Your goal is to understand the trade-offs so you can pick one on purpose, and to be comfortable reading the other, because you will meet both.

Product details change between releases. This lesson sticks to the stable, well-known differences and avoids version numbers and benchmarks. Check each project's current documentation before making a decision for a real team.

Two architectures

Cypress runs your test code inside the browser, in the same page environment as your application (in a browser frame next to the app's frame). Your commands talk to the app's DOM directly, and a companion Node.js process handles the things a browser cannot do, such as reading files and proxying network traffic. The result is very fast feedback about the page, a rich interactive runner, and a programming model with a command queue (How Cypress Commands Really Work covers it in detail).

Playwright runs your test code in a separate Node.js process (or a Python, Java or .NET process) and controls the browser from outside through a protocol: a stream of messages such as "find this element", "click here" and "give me the text". The browser is just another program being driven. This design makes it natural to control several pages, tabs and even several browsers at once.

flowchart LR
  subgraph CY["Cypress"]
    direction TB
    CB["Browser"]
    CT["Test code and app<br/>in the same browser"]
    CN["Node.js helper<br/>files, proxy"]
    CB --- CT
    CT <--> CN
  end
  subgraph PW["Playwright"]
    direction TB
    PT["Test process<br/>Node, Python, Java or .NET"]
    PB["Browser<br/>Chromium, Firefox, WebKit"]
    PT -->|"protocol messages"| PB
  end

Cypress executes tests inside the browser; Playwright sends commands to the browser from a separate process.

Side by side

Topic Cypress Playwright
Where tests run Inside the browser, next to the app In a separate process, driving the browser
Languages JavaScript and TypeScript JavaScript, TypeScript, Python, Java and .NET
Browsers Chrome-family, Edge, Firefox, Electron; WebKit support is experimental Chromium, Firefox and WebKit (the engine behind Safari)
Style Chained commands with no await Normal async and await
Waiting Retries queries and assertions automatically Auto-waits for elements to be ready before each action; assertions retry
Tabs and windows One tab per test; new tabs are a known limitation Multiple pages, tabs and browser contexts in one test
Iframes Reachable, with extra steps First-class support through frame locators
Cross-origin pages Needs cy.origin() to visit a second origin in one test No special handling
Parallel runs Typically needs Cypress Cloud or a third-party tool for smart splitting Built-in workers and sharding
Debugging Famous interactive runner with time travel UI mode, trace viewer, inspector and code generator
Component testing Built in Experimental

Treat the table as a map, not a verdict. Each cell has caveats, and both projects keep closing gaps.

The same test, two ways

Here is one test, written for each tool. The first runs a search and checks the first result.

JavaScript
// Cypress (read-only)
it('finds a lesson', () => {
  cy.visit('/')
  cy.get('[data-cy=search]').type('closures')
  cy.contains('li', 'Closures in JavaScript').should('be.visible')
})
TypeScript
// Playwright (read-only)
import { test, expect } from '@playwright/test';

test('finds a lesson', async ({ page }) => {
  await page.goto('/');
  await page.getByPlaceholder('Search').fill('closures');
  await expect(page.getByRole('listitem').filter({ hasText: 'Closures in JavaScript' })).toBeVisible();
});

Differences to notice:

  • Cypress has one global cy object. You never write await, because Cypress queues the commands and runs them one after another.
  • Playwright hands each test a page object. Every step is awaited, so ordinary JavaScript control flow (if, for, try) works exactly as you would expect.
  • Cypress states how to wait inside the assertion (should). Playwright checks that an element is ready before it acts and retries expect(...) assertions.

What the architecture means in practice

Control and flexibility

Because Playwright sits outside the page, it can open a second browser context (a clean, isolated profile) in the same test. That is ideal for scenarios such as "User A sends a chat message and User B sees it", which need two logged-in sessions at once. In Cypress you would normally cover that with two tests, or by driving one side through an API.

Closeness to the app

Because Cypress runs next to the app, it can read and stub things in the page directly, and its runner shows the app and a command log side by side as you work. Many developers find this the friendliest way to learn and to write a test while building a feature.

Speed and scale

Both are fast enough for most apps. Playwright's built-in parallel workers and sharding make large suites easy to spread across machines (Parallel Runs, Sharding and Speed). Cypress achieves similar results through its paid cloud service or other tooling.

Browser coverage

If you must support Safari, Playwright's WebKit builds are a significant advantage. If your users are overwhelmingly on Chrome-family browsers, the gap matters less.

Modeling both architectures

The runnable stand-ins below are not Cypress or Playwright. They are small models of the two ideas, so you can see why the programming styles differ.

In the first, the "test" and the "app" live in the same environment. A command can read the app's state immediately because they share memory, and the runner queues commands before running them.

JS Model: the test runs inside the page

Press Run (or Ctrl + Enter) to see the console output here.

No output.

In the second, the "test" is a separate program that can only send messages across a channel and wait for replies. Every action is a request and a response, which is why Playwright code uses await on every line.

JS Model: the test drives the page by messages

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The first model shows the Cypress idea honestly: queued commands, no await, and a runner that executes them later. The second shows the Playwright idea: the script is a client of the browser and every step crosses a boundary. Real Cypress also communicates with a Node process, and real Playwright speaks protocols such as the Chrome DevTools Protocol, so these are simplifications, but the shapes are right.

How to choose

Ask these questions in order:

  1. Do you need languages other than JavaScript or TypeScript? Playwright supports Python, Java and .NET too.
  2. Do you need Safari (WebKit) coverage, multiple tabs, or several users in one test? Playwright fits these naturally.
  3. Is the team new to testing, and do you value a very visual, interactive runner while writing tests? Cypress is excellent for that.
  4. Do you want component tests today? Cypress has mature support.
  5. Is there an existing suite? A working suite in one tool is usually worth keeping; rewriting for fashion rarely pays.

If none of those decide it, either choice will serve you. This tutorial teaches both side by side, so the skills transfer: selecting elements, waiting, network control and structure are the same ideas in two dialects.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Where does Cypress run your test code?

    Cypress executes tests in the browser alongside the app, with a Node.js helper process for files and networking.
  2. 2. Which statement about Playwright is correct?

    Playwright drives browsers from outside the page, supports Chromium, Firefox and WebKit, offers several languages and uses async and await.
  3. 3. A test needs two logged-in users interacting at the same time. Which tool fits most naturally?

    Playwright can create several isolated contexts in one test. Cypress runs a single tab per test, so such scenarios are usually split up.
  4. 4. Why does Cypress code not use await on each command?

    Cypress commands add steps to a queue. The runner executes the queue in order, so you describe the steps and do not await them.

Summary

  • Cypress runs inside the browser next to your app; Playwright drives the browser from a separate process.
  • Playwright supports more languages and has WebKit, multi-tab and multi-context features built in.
  • Cypress offers a very visual runner and mature component testing; Playwright offers strong parallelism and tooling such as the trace viewer.
  • Cypress uses chained commands with no await; Playwright uses normal async and await.
  • Choose by language, browser needs, scenarios and team habits, and keep a working suite instead of rewriting it.
  • The stand-ins model the two architectures; they are not the real tools.

Next: Your First Cypress Test