{"id":10679,"date":"2026-10-18T11:54:42","date_gmt":"2026-10-18T09:54:42","guid":{"rendered":"https:\/\/betterqa.co\/?p=10679"},"modified":"2026-10-18T11:54:42","modified_gmt":"2026-10-18T09:54:42","slug":"how-to-migrate-cypress-to-playwright","status":"publish","type":"post","link":"https:\/\/betterqa.co\/how-to-migrate-cypress-to-playwright\/","title":{"rendered":"How to migrate Cypress to Playwright without breaking CI"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"10679\" class=\"elementor elementor-10679 elementor-bc-flex-widget\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-9b287a3 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"9b287a3\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-9d3c116\" data-id=\"9d3c116\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-edb8e40 elementor-widget elementor-widget-html\" data-id=\"edb8e40\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<style>\n.bqa-article{--ink:#0C1726;--body:#33404d;--dim:#5f6b78;--line:#d3e0e0;--purple:#9152DE;--deep:#5F29A1;--paper:#DDE9E9;--wash:#f4f8f8;font-family:'Roboto',sans-serif;color:var(--body);line-height:1.7;background:#fff}\n.bqa-article *,.bqa-article *::before,.bqa-article *::after{box-sizing:border-box}\n.bqa-article h1,.bqa-article h2,.bqa-article h3{font-family:'Jost',sans-serif;color:var(--ink);font-weight:600;text-transform:none!important;letter-spacing:0;line-height:1.25;margin:0}\n.bqa-art-wrap{max-width:760px;margin:0 auto;padding:0 24px}\n.bqa-art-label{font-family:'JetBrains Mono',ui-monospace,monospace;font-size:.6875rem;font-weight:500;color:var(--deep);text-transform:uppercase;letter-spacing:.15em;display:flex;align-items:center;gap:10px;margin-bottom:14px}\n.bqa-art-label::before{content:'';width:20px;height:1px;background:var(--purple)}\n.bqa-art-hero{background:var(--paper);padding:44px 0 40px}\n.bqa-art-hero .bqa-art-wrap{max-width:1120px;display:grid;grid-template-columns:minmax(0,1fr) 400px;gap:48px;align-items:center}\n.bqa-art-back{font-family:'JetBrains Mono',ui-monospace,monospace;font-size:.75rem;text-transform:uppercase;letter-spacing:.06em;color:var(--dim)!important;text-decoration:none;display:inline-block;margin-bottom:18px}\n.bqa-article h1{font-size:clamp(1.8rem,3.6vw,2.6rem);margin-bottom:14px}\n.bqa-art-meta{font-size:.875rem;color:var(--dim);margin:0 0 16px}\n.bqa-article p.bqa-art-lead{font-size:1.0625rem;color:var(--ink);margin:0}\n.bqa-art-hero picture,.bqa-art-hero img{display:block;width:100%;height:auto;border-radius:12px}\n.bqa-art-hero img{aspect-ratio:1600\/1065;object-fit:cover}\n.bqa-art-hero figcaption{font-size:.75rem;color:var(--dim);margin-top:6px}\n.bqa-art-hero figure{margin:0}\n.bqa-art-sec{padding:44px 0;border-bottom:1px solid #e6e9ee}\n.bqa-art-sec.alt{background:var(--wash)}\n.bqa-article h2{font-size:clamp(1.35rem,2.4vw,1.75rem);margin-bottom:14px}\n.bqa-article h3{font-size:1.0625rem;margin:22px 0 6px}\n.bqa-article p{margin:0 0 14px;font-size:1rem}\n.bqa-article p:last-child{margin-bottom:0}\n.bqa-article a{color:var(--deep)}\n.bqa-article a:focus-visible{outline:2px solid var(--purple);outline-offset:3px}\n.bqa-article strong{color:var(--ink);font-weight:600}\n.bqa-article code{font-family:'JetBrains Mono',ui-monospace,monospace;font-size:.85em;background:#eef2f4;border-radius:4px;padding:1px 5px;color:var(--ink)}\n.bqa-art-key{border:1px solid var(--line);border-left:3px solid var(--purple);border-radius:10px;background:#fff;padding:18px 22px}\n.bqa-art-key h2{font-size:1.0625rem!important;margin-bottom:8px!important}\n.bqa-art-key ul{margin:0;padding-left:18px}\n.bqa-art-key li{margin:4px 0;font-size:.9688rem}\n.bqa-art-steps{list-style:none;margin:16px 0 0;padding:0;counter-reset:st;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}\n.bqa-art-steps li{counter-increment:st;position:relative;border:1px solid #e6e9ee;border-radius:12px;background:#fff;padding:16px 18px 16px 58px;font-size:.9375rem;line-height:1.55}\n.bqa-art-steps li::before{content:counter(st);position:absolute;left:18px;top:16px;width:28px;height:28px;border-radius:50%;background:var(--ink);color:#fff;font-family:'Jost',sans-serif;font-weight:600;font-size:.8125rem;display:flex;align-items:center;justify-content:center}\n.bqa-art-steps li strong{display:block;font-family:'Jost',sans-serif;font-size:1rem;margin-bottom:2px}\n.bqa-art-table{width:100%;border-collapse:collapse;font-size:.9063rem;background:#fff;border:1px solid #e6e9ee;margin:14px 0 0}\n.bqa-art-table th,.bqa-art-table td{text-align:left;vertical-align:top;padding:10px 14px;border-top:1px solid #e6e9ee;line-height:1.5}\n.bqa-art-table thead th{background:var(--wash);font-family:'JetBrains Mono',ui-monospace,monospace;font-size:.6875rem;font-weight:500;color:var(--dim);text-transform:uppercase;letter-spacing:.1em;border-top:0}\n.bqa-art-quote{font-family:'Jost',sans-serif;font-size:1.25rem;line-height:1.4;color:var(--deep);border-left:3px solid var(--purple);padding:4px 0 4px 18px;margin:18px 0}\n.bqa-art-cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin-top:16px}\n.bqa-art-card{border:1px solid #e6e9ee;border-radius:12px;background:#fff;padding:16px 18px}\n.bqa-article .bqa-art-card h3{margin:0 0 6px;font-size:1rem}\n.bqa-article .bqa-art-card p{font-size:.9063rem;line-height:1.55;margin:0}\n.bqa-art-wide{max-width:1000px}\n.bqa-faq-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:16px}\n.bqa-faq-item{border:1px solid #e6e9ee;border-radius:12px;padding:16px 18px;background:#fff}\n.bqa-article .bqa-faq-question{font-size:1rem!important;margin:0 0 6px!important}\n.bqa-article .bqa-faq-answer{display:block!important;max-height:none!important;opacity:1!important;overflow:visible!important}\n.bqa-article .bqa-faq-answer p{margin:0;font-size:.9063rem;line-height:1.55}\n.bqa-art-cta{padding:40px 0 48px}\n.bqa-art-ctacard{border:1px solid #c9dcdc;border-radius:14px;background:var(--paper);padding:26px 28px;display:flex;gap:22px;align-items:center;justify-content:space-between;flex-wrap:wrap}\n.bqa-article .bqa-art-ctacard h2{font-size:1.375rem;margin-bottom:6px}\n.bqa-article .bqa-art-ctacard p{margin:0;color:var(--ink);max-width:520px}\n.bqa-art-btn{display:inline-flex;align-items:center;padding:12px 22px;border-radius:8px;background:var(--ink);color:#fff!important;font-family:'Jost',sans-serif;font-weight:500;text-decoration:none!important}\n.bqa-art-btn:hover{background:var(--deep)}\n.bqa-art-foot{font-size:.875rem;color:var(--dim);border-top:1px solid #e6e9ee;padding-top:16px;margin-top:22px}\n@media (max-width:960px){.bqa-art-hero .bqa-art-wrap{grid-template-columns:1fr;gap:24px}.bqa-art-cards{grid-template-columns:1fr}}\n@media (max-width:760px){.bqa-art-hero{padding:32px 0}.bqa-art-sec{padding:32px 0}.bqa-art-steps,.bqa-faq-list{grid-template-columns:1fr}.bqa-art-hero img{aspect-ratio:16\/9}}\n@media (max-width:640px){.bqa-art-table thead{display:none}.bqa-art-table,.bqa-art-table tbody,.bqa-art-table tr,.bqa-art-table td{display:block;width:100%}.bqa-art-table tr{border-top:1px solid #e6e9ee;padding:8px 14px}.bqa-art-table td{border:0;padding:3px 0}.bqa-art-table td:first-child{font-weight:600;color:var(--ink)}}\n@media (max-width:380px){.bqa-art-wrap{padding:0 16px}.bqa-art-btn{width:100%;justify-content:center}}\n\n.bqa-art-hero .bqa-art-wrap{display:block;max-width:760px}.bqa-art-hero{padding:28px 0 24px}\n<\/style>\n<div class=\"bqa-article\">\n\n<section class=\"bqa-art-hero\"><div class=\"bqa-art-wrap\">\n<p class=\"bqa-art-lead\">A Cypress to Playwright migration has four steps: convert every spec in bulk, review what the conversion got wrong, run both suites side by side, then cut over. The conversion is the fast part. Trust is what takes the weeks.<\/p>\n<\/div><\/section>\n\n<section class=\"bqa-art-sec\"><div class=\"bqa-art-wrap\">\n<div class=\"bqa-art-key\"><h2>Key takeaways<\/h2><ul>\n<li>Convert the whole suite at once into a separate folder. Delete nothing yet.<\/li>\n<li>Custom commands, network mocks and login are where conversions go wrong. Review those by hand.<\/li>\n<li>Run Cypress and Playwright on the same commits until Playwright matches or beats Cypress.<\/li>\n<li>Remove Cypress only after Playwright has gated several green production deployments.<\/li>\n<\/ul><\/div><div class=\"bqa-pointer\" style=\"box-sizing:border-box;margin:24px 0;padding:16px 20px;border-left:4px solid #9152DE;border-radius:8px;background:rgba(145,82,222,.09);color:inherit;line-height:1.6;text-align:left\"><p style=\"margin:0 0 6px;font-weight:700;color:inherit;font-size:1.0625rem\">We do this for you<\/p><p style=\"margin:0;color:inherit\">Short on time to run both suites side by side? We handle the conversion, the review and the parallel CI run, then hand over a Playwright suite your team can trust. See our <a href=\"\/software-testing-services\/cypress-to-playwright-migration\/\" style=\"color:inherit;font-weight:600;text-decoration:underline\">Cypress to Playwright migration service<\/a>.<\/p><\/div>\n<\/div><\/section>\n\n<section class=\"bqa-art-sec\"><div class=\"bqa-art-wrap\">\n<h2>Why teams move, and why a straight rewrite stalls<\/h2>\n<p>The reasons we hear are practical. Playwright drives Chromium, Firefox and WebKit from one API, handles several tabs and origins natively, and its trace viewer makes a failed run much easier to read. Teams with a few hundred Cypress tests want those things without stopping work for a quarter.<\/p>\n<p>The usual first attempt is a rewrite by hand, a few files a week alongside feature work. It rarely finishes. The old suite keeps changing while the new one is written, two suites drift apart, and after a month nobody can say which one is telling the truth. A migration needs a plan where the new suite proves itself against the old one on the same code, before anyone switches the old one off.<\/p>\n<\/div><\/section>\n\n<section class=\"bqa-art-sec alt\"><div class=\"bqa-art-wrap\">\n<h2>The four steps<\/h2>\n<p>This is the plan we use, condensed. For 100 to 300 tests it typically runs six to eight weeks, and about half of it is the parallel run and the cutover, not the conversion.<\/p>\n<ol class=\"bqa-art-steps\">\n<li><strong>Convert in bulk<\/strong>A script reads every <code>.cy.js<\/code> and <code>.cy.ts<\/code> file, converts it under fixed rules and writes Playwright TypeScript to a new <code>tests\/<\/code> folder, with a report of which files converted cleanly.<\/li>\n<li><strong>Review by hand<\/strong>Run the converted tests in Playwright's UI mode, sort the failures by cause, and fix custom commands, fixtures and authentication.<\/li>\n<li><strong>Run both in CI<\/strong>Both suites run on the same commits. Compare pass rates, run times and flake rates, and investigate every disagreement.<\/li>\n<li><strong>Cut over<\/strong>Make Playwright the CI gate. Keep Cypress as a fallback for two weeks, and remove it after five green production deployments.<\/li>\n<\/ol>\n<\/div><\/section>\n\n<section class=\"bqa-art-sec\"><div class=\"bqa-art-wrap\">\n<h2>The conversion rules that matter<\/h2>\n<p>Whether you convert with a script, an AI model or by hand, write the rules down first so every file comes out the same way. These are the ones we enforce:<\/p>\n<table class=\"bqa-art-table\">\n<thead><tr><th>Cypress<\/th><th>Playwright<\/th><\/tr><\/thead>\n<tbody>\n<tr><td><code>cy.get('.btn-primary')<\/code><\/td><td>Role, label or test id first: <code>page.getByRole('button', { name: 'Save' })<\/code>, CSS only as a last resort<\/td><\/tr>\n<tr><td><code>cy.wait(2000)<\/code><\/td><td>An assertion that waits for the real condition, such as <code>await expect(row).toBeVisible()<\/code><\/td><\/tr>\n<tr><td><code>cy.intercept()<\/code><\/td><td><code>page.route()<\/code> with <code>route.fulfill()<\/code>, or a recorded HAR file<\/td><\/tr>\n<tr><td>Login in <code>before()<\/code><\/td><td>A global setup that logs in once and saves <code>storageState<\/code><\/td><\/tr>\n<tr><td><code>cy.fixture('user')<\/code><\/td><td>Import the JSON directly, or a Playwright fixture<\/td><\/tr>\n<tr><td><code>cy.login()<\/code> and other custom commands<\/td><td>Helper functions or Playwright fixtures<\/td><\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-top:14px\">Playwright's own docs on <a href=\"https:\/\/playwright.dev\/docs\/locators\" rel=\"noopener nofollow\" target=\"_blank\">locators<\/a>, <a href=\"https:\/\/playwright.dev\/docs\/mock\" rel=\"noopener nofollow\" target=\"_blank\">mocking<\/a> and <a href=\"https:\/\/playwright.dev\/docs\/auth\" rel=\"noopener nofollow\" target=\"_blank\">authentication<\/a> cover each pattern in detail.<\/p>\n<\/div><\/section>\n\n<section class=\"bqa-art-sec alt\"><div class=\"bqa-art-wrap\">\n<h2>Where conversions go wrong<\/h2>\n<p><strong>Custom commands.<\/strong> <code>cy.login()<\/code> or <code>cy.seedDatabase()<\/code> have no direct equivalent. Turn each one into a helper or a fixture, and write down the new pattern so the team stops reaching for the old one.<\/p>\n<p><strong>Heavy network mocking.<\/strong> Intercepts with dynamic responses convert badly line by line. Recording a HAR file for the API is usually cleaner than rebuilding each handler.<\/p>\n<p><strong>Plugins.<\/strong> List the Cypress plugins the suite depends on and decide for each one: a Playwright alternative, a small rewrite, or no longer needed.<\/p>\n<p><strong>Multi-origin workarounds.<\/strong> Tests that jumped through hoops to cross domains can usually lose the hoops, because Playwright handles several origins and tabs on its own.<\/p>\n<\/div><\/section>\n\n<section class=\"bqa-art-sec\"><div class=\"bqa-art-wrap\">\n<h2>How to know the migration worked<\/h2>\n<p>Agree the gates before you start, or the cutover becomes a matter of opinion. Ours are a pass rate of 95% or more on the converted suite, no test that passes in Cypress and fails in Playwright, and each test run ten times with a flake rate and run time at or below Cypress. The last gate is human: your developers should be able to write a new Playwright test without help.<\/p>\n<p>If the two suites disagree on a commit, one of them is wrong. Find out which before you cut over.<\/p>\n<\/div><\/section>\n\n<section class=\"bqa-art-sec alt\"><div class=\"bqa-art-wrap\">\n<h2>Common questions<\/h2>\n<div class=\"bqa-faq-list\">\n<div class=\"bqa-faq-item\"><h3 class=\"bqa-faq-question\">Can I use AI to convert Cypress tests to Playwright?<\/h3><div class=\"bqa-faq-answer\"><p>Yes, and it is the fastest way to get a first draft of every file. Give the model fixed conversion rules, then review each result. Custom commands and mocks still need an engineer.<\/p><\/div><\/div>\n<div class=\"bqa-faq-item\"><h3 class=\"bqa-faq-question\">Should the new suite be TypeScript?<\/h3><div class=\"bqa-faq-answer\"><p>We recommend it. Types catch a whole class of mistakes in fixtures and helpers before a test ever runs.<\/p><\/div><\/div>\n<div class=\"bqa-faq-item\"><h3 class=\"bqa-faq-question\">Can Playwright MCP do the migration?<\/h3><div class=\"bqa-faq-answer\"><p>Not on its own. It drives a live browser, which helps after conversion to check flows and fix selectors, but it does not batch-convert Cypress files.<\/p><\/div><\/div>\n<div class=\"bqa-faq-item\"><h3 class=\"bqa-faq-question\">When can we delete Cypress?<\/h3><div class=\"bqa-faq-answer\"><p>After Playwright has been the CI gate for a while. We keep Cypress as a fallback for two weeks and remove it after five green production deployments.<\/p><\/div><\/div>\n<\/div>\n<\/div><\/section>\n\n<section class=\"bqa-art-cta\"><div class=\"bqa-art-wrap\">\n<div class=\"bqa-art-ctacard\"><div><h2>Want this done for you?<\/h2><p>Our <a href=\"\/software-testing-services\/cypress-to-playwright-migration\/\">Cypress to Playwright migration service<\/a> follows exactly this plan, at a fixed price set in the proposal.<\/p><\/div><a class=\"bqa-art-btn\" href=\"\/software-testing-services\/cypress-to-playwright-migration\/\">See the service<\/a><\/div>\n<p class=\"bqa-art-foot\">Written by the <a href=\"\/about-us-software-testing-company\/\">BetterQA team<\/a>. <a href=\"https:\/\/betterqa.co\/\">BetterQA<\/a> is a software testing company in Cluj-Napoca, founded in 2018, with 50+ engineers. Related: <a href=\"\/organising-existing-playwright-tests\/\">organising existing Playwright tests<\/a>.<\/p>\n<\/div><\/section>\n\n\n<\/div>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>A Cypress to Playwright migration has four steps: convert every spec in bulk, review what the conversion got wrong, run both suites side by side, then cut over. The conversion is the fast part. Trust is what takes the weeks. Key takeaways Convert the whole suite at once into a separate folder. Delete nothing yet. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":10637,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1016],"tags":[],"class_list":["post-10679","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guides-and-tutorials"],"acf":[],"_links":{"self":[{"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/posts\/10679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/comments?post=10679"}],"version-history":[{"count":1,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/posts\/10679\/revisions"}],"predecessor-version":[{"id":10695,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/posts\/10679\/revisions\/10695"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/media\/10637"}],"wp:attachment":[{"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/media?parent=10679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/categories?post=10679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/tags?post=10679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}