Migrate from Cypress to Playwright.

Move a Cypress suite to Playwright Test: cy.get, cy.intercept, fixtures, custom commands, sessions, retries and parallel runs mapped to Playwright code, with a checklist, gotchas and live numbers for both tools.

Cypress (live data): 51,046 GitHub stars. 7,668,984 weekly npm downloads (cypress), +31% over 4 weeks. 5 GitHub releases in the last 60 days, latest v15.21.2. last GitHub activity 2026-11-23

Playwright (live data): 100,863 GitHub stars. 138,786,046 weekly npm downloads (@playwright/test), +68% over 4 weeks. 4 GitHub releases in the last 60 days, latest v1.65.1. last GitHub activity 2026-11-22

Select an element: Cypress: cy.get('[data-test=email]') → Playwright Test: page.locator('[data-test=email]') // preferred: page.getByRole / getByLabel / getByTestId (Playwright recommends user-facing locators over CSS. Locators are strict: an action throws if more than one element matches.)

Find by text: Cypress: cy.contains('Log in') → Playwright Test: page.getByText('Log in') (Both match a substring by default. cy.contains is case-sensitive by default and prefers buttons and links; use { exact: true } on getByText for a full match.)

Visit a page: Cypress: cy.visit('/login') → Playwright Test: await page.goto('/login') (Relative paths resolve against baseUrl in Cypress and use.baseURL in Playwright.)

Type and click: Cypress: cy.get('#email').type('a@b.co') cy.get('button').click() → Playwright Test: await page.locator('#email').fill('a@b.co') await page.locator('button').click() (fill sets the value in one go. Use pressSequentially only when the page handles each key press.)

Assert visible: Cypress: cy.contains('Welcome').should('be.visible') → Playwright Test: await expect(page.getByText('Welcome')).toBeVisible()

Assert text: Cypress: cy.get('p').should('have.text', 'Hello World') cy.get('p').should('contain', 'Hello') → Playwright Test: await expect(page.locator('p')).toHaveText('Hello World') await expect(page.locator('p')).toContainText('Hello')

Assert count, value, URL: Cypress: cy.get('li').should('have.length', 3) cy.get('input').should('have.value', 'Jane') cy.url().should('include', '/dashboard') → Playwright Test: await expect(page.locator('li')).toHaveCount(3) await expect(page.locator('input')).toHaveValue('Jane') await expect(page).toHaveURL(/\/dashboard/)

Retry and auto-wait: Cypress: // queries and assertions retry // defaultCommandTimeout: 4000 (ms) → Playwright Test: // actions wait for actionability checks // expect: { timeout: 5000 } in the config (Cypress retries queries with their assertions for 4 s by default. Playwright actions wait until the element is visible, stable, enabled and receives events; web-first assertions retry for 5 s by default.)

Stub a network response: Cypress: cy.intercept('GET', '/api/users', { fixture: 'users.json' }) → Playwright Test: await page.route('**/api/users', route => route.fulfill({ path: 'fixtures/users.json' })) (cy.intercept uses minimatch globs. A Playwright glob must match the entire URL, hence the leading **. route.fulfill also takes status, body or json.)

Wait for a request: Cypress: cy.intercept('GET', '/api/users').as('getUsers') cy.contains('Update').click() cy.wait('@getUsers') → Playwright Test: const responsePromise = page.waitForResponse('**/api/users') await page.getByText('Update').click() const response = await responsePromise (Start waiting before the action that sends the request.)

Fixture files (test data): Cypress: cy.fixture('users').then((users) => { // use users }) → Playwright Test: // no cy.fixture: read the file in Node import fs from 'fs' import path from 'path' const users = JSON.parse( fs.readFileSync(path.join(__dirname, 'fixtures/users.json'), 'utf8')) (In Playwright, "fixtures" means test.extend setup objects (next row), not data files.)

Custom commands: Cypress: Cypress.Commands.add('login', (email, pw) => { // ... }) cy.login('user@example.com', 'password123') → Playwright Test: export const test = base.extend<{ loggedInPage: Page }>({ loggedInPage: async ({ page }, use) => { await page.goto('/login') // fill the form await use(page) }, }) (A fixture can set up before use() and clean up after it. A plain async helper function also works.)

Reuse a login: Cypress: cy.session(username, () => { cy.visit('/login') // fill the form }) → Playwright Test: // auth.setup.ts, run once as a setup project await page.context().storageState({ path: authFile }) // config: use: { storageState: 'playwright/.auth/user.json' } (cy.session caches cookies, localStorage and sessionStorage. A Playwright setup project logs in once and the other projects load the saved state.)

Call an API directly: Cypress: cy.request('/api/users').then((response) => { expect(response.status).to.eq(200) }) → Playwright Test: test('users', async ({ request }) => { const response = await request.get('/api/users') expect(response.ok()).toBeTruthy() })

Config file: Cypress: // cypress.config.js module.exports = defineConfig({ e2e: { baseUrl: 'http://localhost:3000' }, }) → Playwright Test: // playwright.config.ts export default defineConfig({ testDir: 'tests', use: { baseURL: 'http://localhost:3000' }, }) (Runner options (testDir, retries, workers) are top-level; browser options go in use.)

Retries: Cypress: retries: { runMode: 2, openMode: 0 } → Playwright Test: retries: process.env.CI ? 2 : 0 (Both default to 0. Playwright reports a test that passes on retry as "flaky".)

Parallel runs: Cypress: cypress run --record --key=abc123 --parallel → Playwright Test: npx playwright test --workers 4 npx playwright test --shard=1/3 (Cypress parallelization needs Cypress Cloud recording. Playwright runs files in parallel on one machine by default; fullyParallel also splits tests inside a file.)

Component testing: Cypress: cy.mount(<Stepper />) → Playwright Test: test('stepper', async ({ mount }) => { const component = await mount('components/Stepper/Default') }) (Playwright mounts a "story" by id from a gallery page your dev server serves. The old experimental-ct packages are no longer published.)

Reading a value: Cypress: cy.get('h1').then(($h1) => { const text = $h1.text() }) → Playwright Test: const text = await page.locator('h1').textContent() (Cypress commands are queued and cannot be awaited. Every Playwright call returns a promise.)

Checked against: cypress 16.2.1, @playwright/test 1.65.0 (npm registry, 2026-11-10)