Migrate Cypress to Playwright
QualityMax automation scripts use Playwright. Cypress suites are migrated in the repository: inventory the suite, establish consistent mappings, convert shared setup before leaf tests, and run both suites until coverage and behavior match.
Start with a migration inventory
Section titled “Start with a migration inventory”Record Cypress spec counts, test counts, custom commands, fixtures, plugins, browser targets, CI jobs, and skipped tests. Choose one representative flow first. Keep Cypress installed until the Playwright suite passes on the same supported browsers and CI environment.
Before: Cypress
Section titled “Before: Cypress”describe('sign in', () => { it('opens the dashboard', () => { cy.visit('/login'); cy.get('[data-testid="password"]').type('example-password'); cy.contains('button', 'Sign in').click(); cy.url().should('include', '/dashboard'); });});After: runnable Playwright
Section titled “After: runnable Playwright”import { test, expect } from '@playwright/test';
test('opens the dashboard', async ({ page }) => { await page.goto('/login'); await page.getByTestId('password').fill('example-password'); await page.getByRole('button', { name: 'Sign in' }).click(); await expect(page).toHaveURL(/\/dashboard/);});Run with npx playwright test. Store real credentials outside source control; the example values are placeholders.
Map the suite, not only selectors
Section titled “Map the suite, not only selectors”- Replace
cy.intercept()withpage.route()or response waits. - Replace custom commands with Playwright fixtures or helpers.
- Replace
cy.session()with a reviewedstorageStatesetup. - Prefer role, label, and test-id locators over generated CSS or positional selectors.
- Remove fixed waits where a web-first assertion can express the actual readiness condition.
Add the converted tests to the appropriate QualityMax project after they pass locally. Compare test intent, assertions, fixtures, screenshots, retries, browser coverage, and CI artifacts before removing Cypress.
See CLI and local agent for repository workflows and self-healing for locator maintenance.