<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Wei-Wei Wu</title>
    <description>The latest articles on DEV Community by Wei-Wei Wu (@wuweiweiwu).</description>
    <link>https://dev.to/wuweiweiwu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4218743%2Ff24fc2d2-8734-42dd-baa9-5cf659b2f0de.jpg</url>
      <title>DEV Community: Wei-Wei Wu</title>
      <link>https://dev.to/wuweiweiwu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wuweiweiwu"/>
    <language>en</language>
    <item>
      <title>Web Application Testing with AI: A Step-by-Step Guide</title>
      <dc:creator>Wei-Wei Wu</dc:creator>
      <pubDate>Tue, 24 Nov 2026 16:00:00 +0000</pubDate>
      <link>https://dev.to/wuweiweiwu/web-application-testing-with-ai-a-step-by-step-guide-4h4i</link>
      <guid>https://dev.to/wuweiweiwu/web-application-testing-with-ai-a-step-by-step-guide-4h4i</guid>
      <description>&lt;p&gt;What’s involved with AI-driven web application testing, practically speaking?&lt;/p&gt;

&lt;p&gt;You might be relieved to hear that the fundamental approach to web app testing probably &lt;em&gt;doesn’t differ all that much&lt;/em&gt; from what you’re doing currently. Code, test, correct, repeat.&lt;/p&gt;

&lt;p&gt;What AI does affect is the &lt;strong&gt;efficiency&lt;/strong&gt; and the &lt;strong&gt;efficacy&lt;/strong&gt; of this process.&lt;/p&gt;

&lt;p&gt;AI test creation and self-healing tools help you eliminate creation and maintenance backlogs, making things more efficient. Meanwhile, the analytical capabilities of &lt;a href="https://momentic.ai/blog/agentic-testing-guide" rel="noopener noreferrer"&gt;agentic AI&lt;/a&gt; help reduce production errors, making testing more effective.&lt;/p&gt;

&lt;p&gt;Here’s our step-by-step guide to web application testing, so that you can see where AI fits in.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI in Web Application Testing: Why It’s Essential
&lt;/h2&gt;

&lt;p&gt;It’s difficult to understate just how transformational AI tools can be in your web application testing process. We’re not just talking minor convenience wins – we’re talking hours of valuable time saved per week &lt;em&gt;and&lt;/em&gt; better product quality overall.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://momentic.ai/customers/gptzero" rel="noopener noreferrer"&gt;Just ask GPTZero&lt;/a&gt;, who &lt;strong&gt;accelerated its release cycle by 80%&lt;/strong&gt; using AI testing tools, whilst seeing an &lt;strong&gt;89% decrease in defect escape rate&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Those numbers are pretty eye-catching, right? Here’s how the technology saves you so much time whilst boosting quality:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Your engineers can create tests much faster&lt;/strong&gt;, thanks to natural language test creation tools – simply describe what you want to test and let the AI take care of the rest&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-healing features use intent-based locators&lt;/strong&gt; to &lt;a href="https://momentic.ai/blog/how-self-healing-test-automation-reduces-maintenance" rel="noopener noreferrer"&gt;adapt tests to UI updates&lt;/a&gt; – you save hours otherwise spent fixing flaky tests caused by brittle CSS/XPath selectors&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agentic AI tools can explore your app&lt;/strong&gt;, identifying gaps in coverage, missed edge cases, and high-risk areas, so your team can eliminate any blind spots&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI tools help you execute tests across multiple environments&lt;/strong&gt; at scale, so that testing cycles don’t slow down as your app scales&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integration into CI/CD pipelines&lt;/strong&gt; accelerates feedback loops – engineers receive faster feedback on deployments, allowing issues to be resolved earlier&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The economics of this are too compelling for engineering teams not to adopt it. As teams get smaller and budgets tighten, AI will pick up the slack where human teams would otherwise be looking at major resource shortages.&lt;/p&gt;

&lt;p&gt;And, if you’re using AI to write some of your code, any efficiency gains will be void unless you have a way to test that code quickly and efficiently. Already, we’re seeing &lt;a href="https://momentic.ai/blog/the-slop-is-out-of-the-bottle" rel="noopener noreferrer"&gt;decreases in product quality&lt;/a&gt; thanks to teams’ inability to keep up with verifying AI code. AI testing tools allow you to maintain the speed of AI code creation without sacrificing quality.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Step-by-Step Guide to AI-Powered Web Application Testing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Define Your Testing Priorities and Goals
&lt;/h3&gt;

&lt;p&gt;Successful AI-powered web application testing starts with identifying key business and engineering goals. It’s no different from traditional web app testing in this respect.&lt;/p&gt;

&lt;p&gt;Ask yourself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which user journeys are most business-critical&lt;/li&gt;
&lt;li&gt;Where defects most commonly occur&lt;/li&gt;
&lt;li&gt;Which testing bottlenecks slow releases&lt;/li&gt;
&lt;li&gt;Which areas generate the most maintenance work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, an eCommerce platform may prioritize checkout reliability and payment processing features, whereas a SaaS platform might focus on user onboarding, dashboard functionality, and core feature flows.&lt;/p&gt;

&lt;p&gt;Once you’ve identified these journeys, break them into individual user actions. This gives you a clear structure for building your first AI-powered web application tests. For example, a checkout flow may include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search for a product&lt;/li&gt;
&lt;li&gt;Add product to basket&lt;/li&gt;
&lt;li&gt;Open cart&lt;/li&gt;
&lt;li&gt;Enter delivery information&lt;/li&gt;
&lt;li&gt;Complete payment&lt;/li&gt;
&lt;li&gt;Verify order confirmation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You should also determine the scope of what you’re testing. Which environments are you going to test, for example, and what would you consider to be your acceptable performance thresholds?&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Save Time on Test Creation With AI Testing Tools
&lt;/h3&gt;

&lt;p&gt;Once you’ve identified your target workflows, use your chosen AI tool to create the test.&lt;/p&gt;

&lt;p&gt;Without AI, you’d need to spend a chunk of time writing and checking the code for the automation script. &lt;a href="https://momentic.ai/blog/low-code-test-automation-tools" rel="noopener noreferrer"&gt;Save yourself the effort&lt;/a&gt; with either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Natural language test creation tools that allow you to describe what you want to test in plain English and have the AI take care of the rest&lt;/li&gt;
&lt;li&gt;A reliable record-and-playback tool, where the AI creates a test by recording you interacting with the app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This accelerates the test creation phase significantly. So, you both test quicker and give your team time back to expand coverage and focus on other high-value activities.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Use Stable, User-Focused Assertions
&lt;/h3&gt;

&lt;p&gt;One of the most common automation mistakes is validating fragile frontend details instead of outcomes that actually mean anything. This both decenters users from your testing experience (bad theoretically) and makes your tests more liable to breaking when you update the UI (bad practically).&lt;/p&gt;

&lt;p&gt;So, make sure your assertions are based on what the user experiences. For example, instead of validating:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A particular &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; exists&lt;/li&gt;
&lt;li&gt;A CSS class is present&lt;/li&gt;
&lt;li&gt;An exact XPath matches&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use AI testing tools to validate outcomes such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The user was redirected correctly&lt;/li&gt;
&lt;li&gt;The correct data was displayed&lt;/li&gt;
&lt;li&gt;The workflow completed successfully&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Build Tests Around Reusable Components
&lt;/h3&gt;

&lt;p&gt;As your app expands and test coverage grows, avoid creating isolated one-off workflows for every scenario. This is a surefire way to increase maintenance workloads and slow down execution times.&lt;/p&gt;

&lt;p&gt;Instead, break repeated actions into reusable components, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logging in&lt;/li&gt;
&lt;li&gt;Creating test users&lt;/li&gt;
&lt;li&gt;Navigating to dashboards&lt;/li&gt;
&lt;li&gt;Adding products to carts&lt;/li&gt;
&lt;li&gt;Resetting account settings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows teams to update shared workflows once rather than maintaining duplicate logic across dozens of tests. Your web application testing will be significantly more scalable if you establish strong processes here.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Test Dynamic Content Using Realistic Conditions
&lt;/h3&gt;

&lt;p&gt;Modern web applications rely heavily on dynamic rendering, asynchronous loading, and API-driven updates.&lt;/p&gt;

&lt;p&gt;This means that, to create AI-powered tests that reflect real-world conditions, you’ll need to build workflows that account for real application behavior. So, make sure to use realistic loading conditions, test interactions after state changes, and include scenarios involving delayed responses.&lt;/p&gt;

&lt;p&gt;For example, when testing a dashboard:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Log in to the application&lt;/li&gt;
&lt;li&gt;Wait for the account data to load fully&lt;/li&gt;
&lt;li&gt;Verify charts and widgets render correctly&lt;/li&gt;
&lt;li&gt;Apply filters&lt;/li&gt;
&lt;li&gt;Confirm results update dynamically&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Run the Same Test Across Multiple Browsers
&lt;/h3&gt;

&lt;p&gt;Momentic web tests run on Chromium and Chrome. Use additional tooling when your browser coverage requires other engines.&lt;/p&gt;

&lt;p&gt;Even modern frontend applications can behave differently depending on rendering engines, extensions, or &lt;a href="https://momentic.ai/blog/browser-testing-strategy" rel="noopener noreferrer"&gt;browser-specific behavior&lt;/a&gt;. Once a workflow is stable, you should check that it works across the browsers and across which your users are likely to interact with it.&lt;/p&gt;

&lt;p&gt;Some web application features are particularly susceptible to this – pay special attention to any workflows involving:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript-heavy interactions&lt;/li&gt;
&lt;li&gt;Responsive layouts&lt;/li&gt;
&lt;li&gt;File uploads&lt;/li&gt;
&lt;li&gt;Authentication flows&lt;/li&gt;
&lt;li&gt;Payment integrations&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Add Your Tests to the CI/CD Pipeline
&lt;/h3&gt;

&lt;p&gt;Why validate your releases manually when you can add your AI web application tests to your CI/CD pipelines and have them run automatically on every commit?&lt;/p&gt;

&lt;p&gt;Decide which tests you want to run when, then integrate them into CI/CD workflows accordingly. For example, you might want to run smoke tests on every pull request or before merging branches, or full regression suites after major frontend updates.&lt;/p&gt;

&lt;p&gt;Here’s what a practical workflow might look like for CI/CD-triggered tests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Developer submits code changes&lt;/li&gt;
&lt;li&gt;CI pipeline triggers automatically&lt;/li&gt;
&lt;li&gt;Critical automated tests execute&lt;/li&gt;
&lt;li&gt;Required CI status checks can gate merges; configure deployment gates separately&lt;/li&gt;
&lt;li&gt;Successful builds continue to staging or production&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Our tip: keep regular CI/CD suites focused and fast. Running too many slow tests frequently will slow down your release cycles and cause frustration among your engineering team.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Expand Your Coverage Sustainably
&lt;/h3&gt;

&lt;p&gt;You’ve successfully automated your high-priority workflows with AI. Now, it’s time to expand your &lt;a href="https://momentic.ai/blog/test-coverage-vs-code-coverage" rel="noopener noreferrer"&gt;test coverage&lt;/a&gt; and roll the approach out across your application.&lt;/p&gt;

&lt;p&gt;The keyword here is ‘sustainably’. You do not need to switch everything over immediately if that doesn’t work for you. Take a strategic approach, working your way through negative test scenarios, permission-based workflows, multi-user interactions, and mobile-specific behavior rather than trying to identify and automate every single edge case ever.&lt;/p&gt;

&lt;p&gt;Of course, given how easy it is to create and run tests with AI, you might find that ‘sustainably’ expanding your test suite comes much more quickly than you might have thought! With Momentic, for example, &lt;a href="https://momentic.ai/customers/quora" rel="noopener noreferrer"&gt;Quora managed to create 100% of critical tests in just one month&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Continuously Refine and Maintain Your Test Suite
&lt;/h3&gt;

&lt;p&gt;It’s tempting to think of AI testing as a ‘set it and leave it’ process that will run completely autonomously with minimal human input.&lt;/p&gt;

&lt;p&gt;That might become a reality in the not-too-distant future. Currently, however, even the most advanced agentic AI software requires some level of human supervision to run effectively.&lt;/p&gt;

&lt;p&gt;The good news? You will need to spend significantly fewer hours doing this compared to overseeing and maintaining a ‘traditional’ (read ‘non AI-driven’) test suite. Schedule regular review cycles to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remove obsolete tests&lt;/li&gt;
&lt;li&gt;Consolidate duplicate coverage&lt;/li&gt;
&lt;li&gt;Update outdated workflows&lt;/li&gt;
&lt;li&gt;Improve execution speed&lt;/li&gt;
&lt;li&gt;Analyze flaky behaviour&lt;/li&gt;
&lt;li&gt;Prioritise unstable areas of the application&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The even better news? This is something that &lt;a href="https://momentic.ai/blog/ai-agents-and-the-return-of-engineering-discipline" rel="noopener noreferrer"&gt;agentic AI tools&lt;/a&gt; do really well. To gain even more hours back, let them explore your app autonomously and flag duplicate and obsolete tests (or, on the other hand, identify gaps in code coverage to decrease the risk of errors slipping through to production).&lt;/p&gt;

&lt;h2&gt;
  
  
  Momentic: AI-Driven Web Application Testing That Delivers
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;“Momentic helped us solve the core problem we were struggling with. By using AI to keep tests reliable as our flows change, we can focus on building instead of worrying about regressions slipping through.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Hari Muthakana — Software Engineer, Nuvo&lt;/p&gt;

&lt;p&gt;A great AI testing tool should save your engineers time, empower your team to release faster, and be intuitive enough to use straight out of the box.&lt;/p&gt;

&lt;p&gt;Momentic’s natural language test creation, self-healing tests, and autonomous agentic AI allowed digital trade platform Nuvo to scale to 80% frontend test coverage in three days, end-to-end test creation accelerating by 90%.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://momentic.ai/blog/ai-web-application-testing-step-by-step" rel="noopener noreferrer"&gt;momentic.ai&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>ai</category>
      <category>webdev</category>
      <category>qa</category>
    </item>
    <item>
      <title>Migrating from Cypress to Playwright: a step-by-step guide</title>
      <dc:creator>Wei-Wei Wu</dc:creator>
      <pubDate>Thu, 19 Nov 2026 16:00:00 +0000</pubDate>
      <link>https://dev.to/wuweiweiwu/migrating-from-cypress-to-playwright-a-step-by-step-guide-22h6</link>
      <guid>https://dev.to/wuweiweiwu/migrating-from-cypress-to-playwright-a-step-by-step-guide-22h6</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://momentic.ai/blog/migrate-cypress-playwright" rel="noopener noreferrer"&gt;Momentic blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run Cypress and Playwright in separate CI jobs during the migration. Keep Cypress coverage until the converted specs pass reliably.&lt;/li&gt;
&lt;li&gt;Convert specs file by file, starting with tests that cover your most important user flows.&lt;/li&gt;
&lt;li&gt;Expect more work than a command-by-command rewrite. Cypress queues chained commands, while Playwright requires &lt;code&gt;await&lt;/code&gt;. Review assertions carefully because the frameworks retry them differently.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cypress to Playwright command mapping
&lt;/h2&gt;

&lt;p&gt;Use this table to translate common commands, then check the surrounding test logic. Playwright actions return promises, so the converted spec must &lt;code&gt;await&lt;/code&gt; them.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cypress&lt;/th&gt;
&lt;th&gt;Playwright&lt;/th&gt;
&lt;th&gt;Migration note&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;cy.get('[data-testid="save"]')&lt;/td&gt;
&lt;td&gt;page.locator('[data-testid="save"]')&lt;/td&gt;
&lt;td&gt;Await the action on the locator, such as await locator.click().&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cy.intercept('GET', '/api/users', response)&lt;/td&gt;
&lt;td&gt;await page.route('**/api/users', handler)&lt;/td&gt;
&lt;td&gt;Register the route before the request starts.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cy.visit('/dashboard')&lt;/td&gt;
&lt;td&gt;await page.goto('/dashboard')&lt;/td&gt;
&lt;td&gt;Relative URLs require a configured baseURL.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cy.fixture('users.json')&lt;/td&gt;
&lt;td&gt;Import JSON or expose data through a Playwright test fixture&lt;/td&gt;
&lt;td&gt;A Playwright fixture supplies data to a test rather than queuing a command.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cypress.Commands.add(...)&lt;/td&gt;
&lt;td&gt;Playwright test fixtures or page-object helpers&lt;/td&gt;
&lt;td&gt;Move shared setup into fixtures and reusable interactions into helpers.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cy.session('user', login)&lt;/td&gt;
&lt;td&gt;test.use({ storageState: 'playwright/.auth/user.json' })&lt;/td&gt;
&lt;td&gt;Create the authenticated state first. storageState does not preserve sessionStorage.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;.should('be.visible')&lt;/td&gt;
&lt;td&gt;await expect(locator).toBeVisible()&lt;/td&gt;
&lt;td&gt;Use a Playwright assertion so the condition retries until its timeout.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A route handler needs to fulfill or continue the request. For example, this Playwright test registers a stub before opening the page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;shows the account name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;**/api/account&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;route&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;route&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fulfill&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;json&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ada&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http://localhost:3000/account&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ada&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBeVisible&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example assumes your app serves &lt;code&gt;/account&lt;/code&gt; locally and requests &lt;code&gt;/api/account&lt;/code&gt;. Replace those paths with your app’s routes.&lt;/p&gt;

&lt;h2&gt;
  
  
  The async model change: chained commands vs await
&lt;/h2&gt;

&lt;p&gt;Cypress queues commands and retries queries and assertions, so a chain can wait for the page to reach the expected state. Playwright runs asynchronous actions in sequence only when you &lt;code&gt;await&lt;/code&gt; them. Its actions wait for conditions such as visibility and readiness to receive a click, while &lt;code&gt;expect&lt;/code&gt; assertions retry until they pass or time out.&lt;/p&gt;

&lt;p&gt;With a base URL configured, the same search test looks like this in Cypress.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;shows search results&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;visit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/search&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input[name="query"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;invoice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button[type="submit"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#status&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;should&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;have.text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Results for invoice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Playwright, &lt;code&gt;fill()&lt;/code&gt; replaces the input value, and each action and assertion needs &lt;code&gt;await&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;shows search results&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/search&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;locator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input[name="query"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;locator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input[name="query"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;invoice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;locator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button[type="submit"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;locator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#status&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toHaveText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Results for invoice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A mechanical replacement can leave promises unhandled. If you omit &lt;code&gt;await&lt;/code&gt; before &lt;code&gt;click()&lt;/code&gt;, the test may start typing before the click finishes, causing a race condition. Replacing &lt;code&gt;should('have.text', ...)&lt;/code&gt; with a one-time &lt;code&gt;textContent()&lt;/code&gt; check creates a different problem. The check can read the old DOM before the result appears, while &lt;code&gt;await expect(locator).toHaveText(...)&lt;/code&gt; keeps checking within its timeout.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-by-step migration
&lt;/h2&gt;

&lt;p&gt;Migrating file by file lets you compare the new Playwright suite with the Cypress suite before removing either one. Start with a spec that covers an important user path, then carry its behavior, authentication, and CI checks across.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Install Playwright alongside Cypress
&lt;/h3&gt;

&lt;p&gt;Keep Cypress installed while you port specs. Add Playwright and its browser binaries without changing the existing Cypress scripts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; @playwright/test
npx playwright &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put new specs in &lt;code&gt;tests/playwright&lt;/code&gt; so Playwright does not discover Cypress files. Commit the Playwright dependency and configuration before converting tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Port the base URL and environment values
&lt;/h3&gt;

&lt;p&gt;Create &lt;code&gt;playwright.config.ts&lt;/code&gt;. Playwright reads environment variables through &lt;code&gt;process.env&lt;/code&gt;, so replace &lt;code&gt;Cypress.env('NAME')&lt;/code&gt; references with the corresponding &lt;code&gt;process.env.NAME&lt;/code&gt; references as you convert each spec.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;defineConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;testDir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./tests/playwright&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;use&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;baseURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;BASE_URL&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http://localhost:3000&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;retain-on-failure&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example assumes your app runs on port 3000. Start it before running either suite, or set &lt;code&gt;BASE_URL&lt;/code&gt; to the address your CI job uses. Keep secrets in CI environment variables rather than committing them to the config.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Convert one spec end to end
&lt;/h3&gt;

&lt;p&gt;Port the interaction and its assertion together. A Cypress chain queues commands, while a Playwright test must &lt;code&gt;await&lt;/code&gt; browser actions and assertions. Leaving out an &lt;code&gt;await&lt;/code&gt; can let the test finish before the browser completes the action.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Cypress&lt;/span&gt;
&lt;span class="nf"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;product search&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;shows matching results&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;visit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/products&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;[data-testid="search"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;keyboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;[data-testid="results"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;should&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;contain.text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;keyboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// tests/playwright/products.spec.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;product search shows matching results&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/products&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByTestId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;search&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;keyboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByTestId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;results&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toContainText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;keyboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the new spec against the same app as its Cypress counterpart.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx playwright &lt;span class="nb"&gt;test &lt;/span&gt;tests/playwright/products.spec.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace selectors when the existing ones depend on fragile DOM structure. Playwright's  &lt;a href="https://momentic.ai/blog/playwright-locators-guide" rel="noopener noreferrer"&gt;locator guide&lt;/a&gt;  covers the available locator strategies. In this example, &lt;code&gt;toContainText&lt;/code&gt; retries the assertion while results load. A one-time read of &lt;code&gt;textContent()&lt;/code&gt; would not provide that retry behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Convert custom commands into explicit helpers or fixtures
&lt;/h3&gt;

&lt;p&gt;Move a custom command's implementation when you move the specs that call it. A small command can become a helper that accepts &lt;code&gt;page&lt;/code&gt;, making its browser dependency visible at the call site.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// tests/playwright/helpers/catalog.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;openCatalog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/products&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;openCatalog&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./helpers/catalog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;openCatalog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use a Playwright fixture when the replacement must prepare state for many tests, and use a page object when several tests share interactions with the same page. Do not translate a custom command mechanically if it also hides network stubs or test data setup. Port those effects explicitly and check the resulting behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Replace &lt;code&gt;cy.session()&lt;/code&gt; with saved authentication state
&lt;/h3&gt;

&lt;p&gt;Playwright can save cookies and local storage after login, then load that state in authenticated specs. Create a setup test using your application's actual login fields and success condition.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// tests/playwright/auth.setup.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;save authenticated state&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/login&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByLabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Email&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;E2E_EMAIL&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByLabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;E2E_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Sign in&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toHaveURL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="sr"&gt;dashboard/&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;context&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;storageState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;playwright/.auth/user.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create the directory, run setup, and load the file only in specs that need authentication.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; playwright/.auth
npx playwright &lt;span class="nb"&gt;test &lt;/span&gt;tests/playwright/auth.setup.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// At the top of an authenticated spec&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;storageState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;playwright/.auth/user.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add &lt;code&gt;/playwright/.auth/&lt;/code&gt; to &lt;code&gt;.gitignore&lt;/code&gt;. Run the setup test before authenticated specs in CI, and regenerate the file when the session expires. Saved state does not reproduce every &lt;code&gt;cy.session()&lt;/code&gt; callback, so retain any test-specific setup separately.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Run both suites in CI until coverage matches
&lt;/h3&gt;

&lt;p&gt;Give Cypress and Playwright separate CI jobs against the same app build. The Playwright job needs browser installation and, if it runs authenticated specs, the authentication setup before the suite.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Cypress job&lt;/span&gt;
npx cypress run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Playwright job, after starting the app&lt;/span&gt;
npx playwright &lt;span class="nb"&gt;install
mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; playwright/.auth
npx playwright &lt;span class="nb"&gt;test &lt;/span&gt;tests/playwright/auth.setup.ts
npx playwright &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exclude &lt;code&gt;auth.setup.ts&lt;/code&gt; from the main Playwright run or configure it as a setup project, so it does not run again as an ordinary spec. Keep both jobs required while you compare the user paths and assertions they cover. Retire a Cypress spec after its Playwright replacement checks the same behavior, rather than after a fixed migration date. The  &lt;a href="https://momentic.ai/blog/playwright-ci-cd-guide" rel="noopener noreferrer"&gt;Playwright CI/CD guide&lt;/a&gt;  covers pipeline configuration in more detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  What breaks when you migrate
&lt;/h2&gt;

&lt;p&gt;Cypress assertions can pass while a direct Playwright translation flakes because the two frameworks retry different operations. Cypress retries a query and its chained assertion until the condition passes or times out. Playwright retries web-first assertions such as &lt;code&gt;toHaveText&lt;/code&gt;, but &lt;code&gt;expect(await locator.textContent()).toBe('Ready')&lt;/code&gt; compares one value captured at one moment. Use &lt;code&gt;await expect(locator).toHaveText('Ready')&lt;/code&gt; for DOM state, or &lt;code&gt;expect.poll&lt;/code&gt; when the value comes from a function rather than a locator. Playwright’s action auto-waiting does not make a later one-shot assertion retry.&lt;/p&gt;

&lt;p&gt;Iframe selectors need to start inside the frame. A Cypress test that reads an iframe’s document cannot replace &lt;code&gt;cy.get&lt;/code&gt; with &lt;code&gt;page.locator&lt;/code&gt;, because the page locator searches the parent document. Use &lt;code&gt;frameLocator&lt;/code&gt; to reach the element, then apply a web-first assertion.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;checkout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;frameLocator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iframe[name="checkout"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;checkout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Pay&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})).&lt;/span&gt;&lt;span class="nf"&gt;toBeVisible&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Component tests need a separate migration decision. Playwright’s component testing is experimental, and Cypress &lt;code&gt;mount&lt;/code&gt; helpers and their custom commands do not translate directly into Playwright component tests. If component tests make up a substantial part of your suite, keep them in Cypress while you migrate end-to-end specs. Evaluate Playwright’s component testing against your components and test helpers before retiring that suite.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running both suites during the migration
&lt;/h2&gt;

&lt;p&gt;Run Cypress and Playwright in separate CI jobs while you port specs. A hard cutover removes regression checks for behavior the new suite has not covered yet. During the overlap, keep the Cypress job required and add the Playwright job so you can investigate failures without losing the existing check.&lt;/p&gt;

&lt;p&gt;Both jobs should test the same commit against a comparable application environment. Give each job its own server process and port, or use separate test environments if they run concurrently. Keep framework-specific config, environment variables, and test artifacts separate so one job cannot overwrite the other’s results.&lt;/p&gt;

&lt;p&gt;Port specs in small batches and compare the behavior each suite verifies, not just the number of passing tests. Retire a Cypress spec when its Playwright replacement covers the same assertions and relevant browser configuration, and the new job runs reliably in CI. Remove the Cypress job only after the remaining Cypress coverage has a replacement or an explicit reason to drop it.&lt;/p&gt;

&lt;h2&gt;
  
  
  CI example: running Playwright in the pipeline
&lt;/h2&gt;

&lt;p&gt;Run Playwright in its own CI job while Cypress remains active. The job below installs the project’s locked dependencies and Playwright browsers, then uploads the HTML report and retained traces if a test fails.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Playwright&lt;/span&gt;

&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;pull_request&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;playwright&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v4&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/setup-node@v4&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;node-version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20&lt;/span&gt;
          &lt;span class="na"&gt;cache&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm ci&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx playwright install --with-deps&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx playwright test --trace retain-on-failure --reporter=html&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/upload-artifact@v4&lt;/span&gt;
        &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ failure() }}&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;playwright-failures&lt;/span&gt;
          &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
            &lt;span class="s"&gt;playwright-report/&lt;/span&gt;
            &lt;span class="s"&gt;test-results/&lt;/span&gt;
          &lt;span class="na"&gt;if-no-files-found&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ignore&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The test command assumes your Playwright config starts the application through &lt;code&gt;webServer&lt;/code&gt; or points tests at an accessible environment. Keep the Cypress job separate so a Playwright failure cannot hide a Cypress failure during the migration. For deployment environments and other pipeline patterns, see the  &lt;a href="https://momentic.ai/blog/playwright-ci-cd-guide" rel="noopener noreferrer"&gt;Playwright CI/CD guide&lt;/a&gt; .&lt;/p&gt;

&lt;h2&gt;
  
  
  How long migrating 500 tests actually takes
&lt;/h2&gt;

&lt;p&gt;A 500-test count cannot produce a credible migration time estimate on its own. A suite with shared custom commands and stable selectors takes different work than one with duplicated setup and flaky tests. Use a representative pilot to measure each path before committing to a deadline.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Path&lt;/th&gt;
&lt;th&gt;Planning estimate for 500 tests&lt;/th&gt;
&lt;th&gt;What to measure in the pilot&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Manual engineering&lt;/td&gt;
&lt;td&gt;Pilot hours per converted test × 500, plus shared setup and CI work&lt;/td&gt;
&lt;td&gt;Time spent replacing custom commands, debugging flakes, and reviewing coverage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Coding agent&lt;/td&gt;
&lt;td&gt;Pilot review and repair hours per converted test × 500, plus shared setup and CI work&lt;/td&gt;
&lt;td&gt;How often generated tests need corrections, especially around custom commands and existing flakes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Momentic&lt;/td&gt;
&lt;td&gt;Depends on how many user journeys the suite covers; there is no syntax conversion step&lt;/td&gt;
&lt;td&gt;Time to express the existing suite’s intent, have agents author and run tests, review repairs, and verify coverage&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The manual and coding-agent estimates depend heavily on custom command density and existing flake, not test count alone. For either path, sample simple and complex specs so one easy file does not set the schedule for the whole suite.&lt;/p&gt;

&lt;p&gt;Momentic’s path is a separate evaluation, not a faster syntax conversion. Its agents can author, run, and repair tests based on the behavior you want to verify, but you still need to check that the new tests cover the old suite’s important assertions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Momentic fits after the migration
&lt;/h2&gt;

&lt;p&gt;Playwright changes how you write and run browser tests, but you still own selector upkeep, flaky-test triage, and decisions about which behavior needs coverage. Keep those responsibilities visible after the Cypress suite retires.&lt;/p&gt;

&lt;p&gt;If you add Momentic as a verification layer beside Playwright, define which user behaviors each suite checks and review failures for useful signal. Keep existing Playwright tests until any replacement checks have demonstrated equivalent coverage. Engineers still weighing the framework choice can read  &lt;a href="https://momentic.ai/blog/cypress-alternatives" rel="noopener noreferrer"&gt;Cypress alternatives&lt;/a&gt;  and  &lt;a href="https://momentic.ai/blog/playwright-vs-cypress-pros-and-cons" rel="noopener noreferrer"&gt;Playwright vs. Cypress&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;To evaluate Momentic against your migrated suite,  &lt;a href="https://momentic.ai/" rel="noopener noreferrer"&gt;sign up&lt;/a&gt; .&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can Cypress and Playwright coexist in one repo long-term?
&lt;/h3&gt;

&lt;p&gt;Yes. Keep their configs and test directories separate, and run each suite in its own CI job. You will maintain two sets of dependencies and test infrastructure for as long as both remain.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens to Cypress plugins without a Playwright equivalent?
&lt;/h3&gt;

&lt;p&gt;Identify what each plugin does before replacing it. A plugin that creates test data may become a Node helper, while a plugin that changes browser behavior may require a different approach.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does the TypeScript config need to change?
&lt;/h3&gt;

&lt;p&gt;Not necessarily. If Cypress and Playwright types conflict, give each suite its own tsconfig.json with separate test-file includes.&lt;/p&gt;

&lt;h3&gt;
  
  
  How should I replace arbitrary &lt;code&gt;cy.wait()&lt;/code&gt; timeouts?
&lt;/h3&gt;

&lt;p&gt;Wait for the condition the test needs, such as a visible element with expect(locator).toBeVisible() or a specific response with page.waitForResponse(). A fixed delay can expire before the condition is ready or waste time after it is ready.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>playwright</category>
      <category>cypress</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Testing iOS and Android apps with Claude Code</title>
      <dc:creator>Wei-Wei Wu</dc:creator>
      <pubDate>Tue, 17 Nov 2026 16:00:00 +0000</pubDate>
      <link>https://dev.to/wuweiweiwu/testing-ios-and-android-apps-with-claude-code-3d3l</link>
      <guid>https://dev.to/wuweiweiwu/testing-ios-and-android-apps-with-claude-code-3d3l</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://momentic.ai/blog/claude-code-mobile-app-testing" rel="noopener noreferrer"&gt;Momentic blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Claude Code can run &lt;code&gt;xcrun simctl&lt;/code&gt; and &lt;code&gt;adb&lt;/code&gt; to boot a simulator or emulator, install an app, and capture output. Those commands alone do not provide reliable in-app assertions.&lt;/li&gt;
&lt;li&gt;Claude Code can write XCUITest and Espresso tests, but generated code still needs to compile against your project. Missing accessibility identifiers, waits, and device state can make a passing test flaky.&lt;/li&gt;
&lt;li&gt;A mobile MCP server can expose screenshots, element trees, and taps to Claude Code. The agent still needs a test definition and a way to reproduce failures.&lt;/li&gt;
&lt;li&gt;The Momentic mobile skill starts with &lt;code&gt;npx momentic-mobile skills --yes&lt;/code&gt; and lets the agent work with mobile tests. Momentic runs on local or hosted iOS simulators and Android emulators, not physical devices.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why mobile testing is a harder target for a coding agent than web
&lt;/h2&gt;

&lt;p&gt;Claude Code can run commands against a mobile simulator or emulator, but it cannot inspect and control an app through a browser DOM. In a  &lt;a href="https://momentic.ai/blog/claude-code-for-end-to-end-testing" rel="noopener noreferrer"&gt;browser test&lt;/a&gt; , Playwright can locate elements and act on them through a browser connection. Mobile testing requires Claude Code to work through an app build, a device runtime, and tools that expose what appears on screen.&lt;/p&gt;

&lt;p&gt;On iOS, Claude Code can call &lt;code&gt;xcrun simctl&lt;/code&gt; to boot a simulator, install an app, and capture a screenshot. On Android, it can use &lt;code&gt;adb&lt;/code&gt; to install an APK, start an activity, and inspect device output. Those commands give the agent useful access, but a successful install or launch does not verify that an in-app flow works. For repeatable interactions, Claude Code must use another interface or generate XCUITest or Espresso code that compiles in the app’s test target.&lt;/p&gt;

&lt;p&gt;Each layer adds a failure mode you need to separate from an app regression. A changed Xcode scheme or Android build configuration can stop the test before launch. A simulator that has not booted can reject an otherwise valid command. Once a test runs, a fixed wait may pass on one device and fail when rendering takes longer on another.&lt;/p&gt;

&lt;h2&gt;
  
  
  Driving xcrun simctl from Claude Code
&lt;/h2&gt;

&lt;p&gt;Claude Code can script an iOS simulator’s boot, app installation, launch, and evidence capture through &lt;code&gt;xcrun simctl&lt;/code&gt;. Before it runs those commands, confirm the simulator UDID and Xcode scheme. An agent can list both, but it cannot know which device or scheme you intend to test when a repo contains several.&lt;/p&gt;

&lt;p&gt;For an Xcode project named &lt;code&gt;Demo.xcodeproj&lt;/code&gt; with a shared &lt;code&gt;Demo&lt;/code&gt; scheme, the following sequence builds for the selected simulator and captures a screenshot and recent app logs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;xcrun simctl list devices available
xcodebuild &lt;span class="nt"&gt;-list&lt;/span&gt; &lt;span class="nt"&gt;-project&lt;/span&gt; Demo.xcodeproj

&lt;span class="nv"&gt;UDID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"PASTE-CONFIRMED-SIMULATOR-UDID"&lt;/span&gt;
xcrun simctl boot &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$UDID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
xcrun simctl bootstatus &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$UDID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-b&lt;/span&gt;

xcodebuild &lt;span class="nt"&gt;-project&lt;/span&gt; Demo.xcodeproj &lt;span class="nt"&gt;-scheme&lt;/span&gt; Demo &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-configuration&lt;/span&gt; Debug &lt;span class="nt"&gt;-sdk&lt;/span&gt; iphonesimulator &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-destination&lt;/span&gt; &lt;span class="s2"&gt;"platform=iOS Simulator,id=&lt;/span&gt;&lt;span class="nv"&gt;$UDID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-derivedDataPath&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PWD&lt;/span&gt;&lt;span class="s2"&gt;/build"&lt;/span&gt; build

&lt;span class="nv"&gt;APP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PWD&lt;/span&gt;&lt;span class="s2"&gt;/build/Build/Products/Debug-iphonesimulator/Demo.app"&lt;/span&gt;
&lt;span class="nv"&gt;BUNDLE_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;/usr/libexec/PlistBuddy &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="s1"&gt;'Print CFBundleIdentifier'&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$APP&lt;/span&gt;&lt;span class="s2"&gt;/Info.plist"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

xcrun simctl &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$UDID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$APP&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
xcrun simctl launch &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$UDID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BUNDLE_ID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; artifacts
xcrun simctl io &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$UDID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; screenshot artifacts/launch.png
xcrun simctl spawn &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$UDID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; log show &lt;span class="nt"&gt;--last&lt;/span&gt; 2m &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--style&lt;/span&gt; compact &lt;span class="nt"&gt;--predicate&lt;/span&gt; &lt;span class="s2"&gt;"process == &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Demo&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; artifacts/app.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the project and scheme names with those in your repo. If the simulator is already booted, skip &lt;code&gt;simctl boot&lt;/code&gt;. The screenshot shows what appeared after launch, and the log file gives Claude Code output to inspect when the app fails to start.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;simctl&lt;/code&gt; controls the simulator and the app lifecycle, but these commands do not tap an in-app button or assert that a screen works. For repeatable interaction with iOS UI elements, Claude Code needs another layer, such as XCUITest.&lt;/p&gt;

&lt;h2&gt;
  
  
  Driving adb from Claude Code
&lt;/h2&gt;

&lt;p&gt;Claude Code can use &lt;code&gt;adb&lt;/code&gt; to install, launch, and inspect an Android app when an emulator is already running. The commands below assume you have built a debug APK. Replace the serial with one shown by &lt;code&gt;adb devices&lt;/code&gt;, and use your app’s package name and launcher activity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb devices
&lt;span class="nv"&gt;SERIAL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;emulator-5554
&lt;span class="nv"&gt;APK&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;app/build/outputs/apk/debug/app-debug.apk

adb &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SERIAL&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$APK&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
adb &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SERIAL&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; shell am start &lt;span class="nt"&gt;-n&lt;/span&gt; com.example.app/.MainActivity
adb &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SERIAL&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; shell uiautomator dump /sdcard/window.xml
adb &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SERIAL&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; exec-out &lt;span class="nb"&gt;cat&lt;/span&gt; /sdcard/window.xml &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; window.xml
adb &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SERIAL&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; logcat &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; AndroidRuntime:E &lt;span class="s1"&gt;'*:S'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; crashes.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Claude Code can read the UI hierarchy in &lt;code&gt;window.xml&lt;/code&gt; and check &lt;code&gt;crashes.log&lt;/code&gt; after launch. You need to confirm the APK path and activity name against your build and manifest. If &lt;code&gt;adb devices&lt;/code&gt; shows no emulator, &lt;code&gt;emulator -list-avds&lt;/code&gt; can identify installed Android Virtual Devices, but a missing system image or unavailable hardware virtualization needs a functioning local Android setup before the test can run.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;adb&lt;/code&gt; controls the app process and exposes device state, but shell commands alone do not make a reliable in-app test. Claude Code can send coordinate taps with &lt;code&gt;adb shell input tap&lt;/code&gt;, yet a different screen size, keyboard state, or layout can move the target. Use UI-aware test tooling when the assertion depends on what a user can actually tap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing XCUITest with Claude Code: what compiles and what flakes
&lt;/h2&gt;

&lt;p&gt;Claude Code can generate a useful first XCUITest when you give it the app’s UI test target and the accessibility identifiers the app exposes. For an app that opens on an onboarding screen, a test can tap Continue and check that the home screen appears.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;XCTest&lt;/span&gt;

&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="kt"&gt;OnboardingUITests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;XCTestCase&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;testContinueOpensHome&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;XCUIApplication&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;launchArguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"-ui-testing"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"-reset-onboarding"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;launch&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;continueButton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buttons&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"onboarding.continue"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="kt"&gt;XCTAssertTrue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;continueButton&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitForExistence&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;continueButton&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tap&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;homeTitle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;staticTexts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"home.title"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="kt"&gt;XCTAssertTrue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;homeTitle&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitForExistence&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The app must assign those identifiers to the button and title, and it must handle the launch arguments that reset onboarding state. Claude Code can put the file in the UI test target and run it against a booted simulator. Replace the scheme and simulator ID with values from your project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;xcodebuild &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-scheme&lt;/span&gt; MyApp &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-destination&lt;/span&gt; &lt;span class="s1"&gt;'platform=iOS Simulator,id=YOUR_SIMULATOR_UDID'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-only-testing&lt;/span&gt;:MyAppUITests/OnboardingUITests/testContinueOpensHome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The standard &lt;code&gt;XCUIApplication&lt;/code&gt; queries and assertions are straightforward to generate, but compilation depends on the project’s target membership and test scheme. A compiling test can still fail intermittently. &lt;code&gt;waitForExistence&lt;/code&gt; does not guarantee that a button is ready to receive a tap after an animation or overlay, and a previous run may leave onboarding marked complete. Claude Code may also query an identifier that exists in its proposed test but not in the app.&lt;/p&gt;

&lt;p&gt;Give the agent the relevant view code and a failing test log so it can correct the first pass. As the UI changes, you still need someone or a separate testing system to keep the test’s identifiers, state reset, and wait conditions accurate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing Espresso tests with Claude Code: what compiles and what flakes
&lt;/h2&gt;

&lt;p&gt;Claude Code can generate an Espresso test that compiles, provided it uses the app’s actual resource IDs and the Android test dependencies already exist. For an app with a &lt;code&gt;continue_button&lt;/code&gt; that reveals a &lt;code&gt;welcome_message&lt;/code&gt;, a first pass could look like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.example.app&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;androidx.test.espresso.Espresso.onView&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;androidx.test.espresso.action.ViewActions.click&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;androidx.test.espresso.assertion.ViewAssertions.matches&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;androidx.test.espresso.matcher.ViewMatchers.withId&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;androidx.test.espresso.matcher.ViewMatchers.withText&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;androidx.test.ext.junit.runners.AndroidJUnit4&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.junit.Test&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.junit.runner.RunWith&lt;/span&gt;

&lt;span class="nd"&gt;@RunWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;AndroidJUnit4&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;WelcomeTest&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@Test&lt;/span&gt;
    &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;continueShowsWelcomeMessage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;onView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;withId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;continue_button&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;perform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
        &lt;span class="nf"&gt;onView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;withId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;welcome_message&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;check&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;withText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Welcome"&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a running emulator and the app’s debug test configuration in place, Claude Code can run the test through Gradle.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./gradlew connectedDebugAndroidTest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The generated test depends on details Claude Code must check in the repository. Both IDs must exist, and &lt;code&gt;welcome_message&lt;/code&gt; must display the asserted text. An unresolved &lt;code&gt;R.id&lt;/code&gt; fails compilation. A valid ID paired with the wrong screen or text compiles but fails at runtime.&lt;/p&gt;

&lt;p&gt;Espresso waits for the main thread to become idle, but it cannot infer when every background operation finishes. If the welcome message depends on an untracked network request, the assertion may run before the response updates the view. The app needs an appropriate &lt;code&gt;IdlingResource&lt;/code&gt; or another test-controlled way to wait for that work. RecyclerView tests need similar care because rows may be off-screen or recycled, and matching repeated row text can select the wrong view. Animations left enabled in test builds can also change when a view becomes available for an action.&lt;/p&gt;

&lt;p&gt;Claude Code can revise a failing assertion or add a missing dependency. A successful compile does not establish that the test will pass repeatedly across emulator runs and UI changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Giving Claude Code a mobile MCP server
&lt;/h2&gt;

&lt;p&gt;Claude Code needs observable app state to make an in-app interaction repeatable. The earlier &lt;code&gt;xcrun simctl&lt;/code&gt; and &lt;code&gt;adb&lt;/code&gt; commands can install and launch an app, but the agent still has to decide how to inspect the screen, locate a control, and confirm that a tap worked.&lt;/p&gt;

&lt;p&gt;A mobile MCP server can expose those operations as tool calls. If the server provides screenshots, accessibility element trees, and taps, Claude Code can inspect the current screen, choose an element, interact with it, and inspect the result. The element tree can provide a more stable target than screenshot coordinates, but the server’s actual tools and supported runtimes depend on its implementation. Check the tool definitions when configuring the server.&lt;/p&gt;

&lt;p&gt;Tool access still leaves test logic with the agent. Claude Code must decide what to assert, wait for the right state, and handle app data that changes between runs. An MCP connection makes simulator interaction easier to structure, but a repeatable test also needs explicit assertions and a controlled starting state.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running a Momentic mobile test from Claude Code
&lt;/h2&gt;

&lt;p&gt;Claude Code can write a mobile test without generating XCUITest or Espresso code. Install the Momentic mobile skill in the repository, then ask Claude Code to create a plain-English YAML test and run it against an available simulator or emulator. Unlike raw &lt;code&gt;simctl&lt;/code&gt; or &lt;code&gt;adb&lt;/code&gt; commands, the test records the behavior you want to verify in a file you can review and commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx momentic-mobile skills &lt;span class="nt"&gt;--yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, give Claude Code a task tied to a build it can access.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Use the installed Momentic mobile skill to test the login flow on the
available iOS simulator. Create a YAML test in this repository that opens
the app, signs in with the configured test account, and checks that the
home screen appears. Run the test and report the result and any failure
evidence. Do not report a pass unless the test ran.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Claude Code should use the installed skill’s instructions to author and run the test. The prompt does not substitute for a run result. Before committing the YAML, check the test’s account configuration, the simulator target, and the reported failure evidence. To run it again outside the agent, use &lt;code&gt;npx momentic-mobile run&lt;/code&gt;. The  &lt;a href="https://momentic.ai/docs/quickstart/ios" rel="noopener noreferrer"&gt;iOS quickstart&lt;/a&gt;  covers the test format.&lt;/p&gt;

&lt;p&gt;Momentic mobile tests run on local or hosted iOS simulators and Android emulators, not physical devices. A simulator or emulator gives CI a device runtime it can provision for repeatable runs, but you still need to control the app build and test data. Unlike a generated XCUITest or Espresso file, the Momentic test does not depend on Claude Code producing Swift or Kotlin test code that compiles against your current project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Local simulators vs. hosted ones
&lt;/h2&gt;

&lt;p&gt;A local iOS simulator or Android emulator gives Claude Code a device it can inspect during development. In CI, that same approach requires a runner with the right Xcode or Android toolchain, a booted device, and a built app. You also need to reset app state between runs and collect logs when a test fails.&lt;/p&gt;

&lt;p&gt;Hosted infrastructure moves device provisioning out of your CI runners and gives you capacity for parallel runs. Momentic can run the same tests on hosted iOS simulators and Android emulators, so CI does not need a Mac with Xcode or an Android SDK. Hosted capacity does not make a flaky test repeatable by itself. Your suite still needs controlled app state, reliable waits, and useful failure evidence.&lt;/p&gt;

&lt;p&gt;Choose local devices when you need fast feedback against a build on your machine. Consider hosted devices when CI needs parallel capacity without managing simulator and emulator runtimes on every runner. Momentic runs mobile tests on local or hosted simulators and emulators, not physical devices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparing the four approaches
&lt;/h2&gt;

&lt;p&gt;Claude Code can use all four approaches to check a mobile app, but they differ in what survives the next UI change. A successful run on a local simulator or emulator does not, by itself, give you a test you can trust in CI.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;What Claude Code automates&lt;/th&gt;
&lt;th&gt;What can still flake&lt;/th&gt;
&lt;th&gt;What maintains itself as the app changes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Raw xcrun simctl or adb&lt;/td&gt;
&lt;td&gt;Boots a simulator or emulator, installs and launches the app, and captures logs or screenshots.&lt;/td&gt;
&lt;td&gt;Device boot state, app startup, and shell scripts that cannot assert in-app behavior.&lt;/td&gt;
&lt;td&gt;Nothing. You update commands and checks.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Generated XCUITest or Espresso&lt;/td&gt;
&lt;td&gt;Writes native tests with element queries and assertions that you can run in CI.&lt;/td&gt;
&lt;td&gt;Missing accessibility identifiers, timing, animations, and test state left by earlier runs.&lt;/td&gt;
&lt;td&gt;Nothing automatically. You review and revise generated code when the UI changes.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="/blog/mobile-mcp-server-setup"&gt;Mobile MCP server&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Exposes device interaction through tool calls, so Claude Code can inspect and act on the app during a session.&lt;/td&gt;
&lt;td&gt;Device state and assertions the agent has not made repeatable.&lt;/td&gt;
&lt;td&gt;Tool access alone does not maintain a test suite.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Momentic mobile skill&lt;/td&gt;
&lt;td&gt;Lets Claude Code author and run Momentic YAML tests against local or hosted simulators and emulators. Momentic does not run these tests on physical devices.&lt;/td&gt;
&lt;td&gt;Environment failures and behavior changes that need engineering review.&lt;/td&gt;
&lt;td&gt;Momentic can repair tests as the UI changes. You still review whether a repaired test checks the intended behavior.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What a repeatable mobile test setup actually needs
&lt;/h2&gt;

&lt;p&gt;A test becomes repeatable when it controls app state, waits for the right UI condition, and records enough evidence to diagnose a failure. Claude Code can drive a simulator or emulator, but a successful tap in one session does not prove the same path will pass after the app changes. Keep the test in source control, run it in CI, and review failures before changing assertions to make them pass.&lt;/p&gt;

&lt;p&gt;To try the Momentic mobile skill from Claude Code, run the setup command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx momentic-mobile skills &lt;span class="nt"&gt;--yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For adjacent reading, see &lt;em&gt;Testing mobile apps in Cursor&lt;/em&gt; and &lt;em&gt;What tests look like with Claude Code&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can Claude Code test on a physical iPhone or Android device?
&lt;/h3&gt;

&lt;p&gt;The methods in this guide target simulators and emulators. Momentic mobile runs on local or hosted iOS simulators and Android emulators, not physical devices.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does Claude Code need Xcode or Android Studio installed?
&lt;/h3&gt;

&lt;p&gt;For local iOS testing with xcrun simctl, you need Xcode and a simulator runtime. For local Android testing, you need the Android SDK tools and an emulator image, but you do not necessarily need the Android Studio IDE. A hosted runner provides the device runtime instead.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can Claude Code fix a flaky XCUITest or Espresso test itself?
&lt;/h3&gt;

&lt;p&gt;Claude Code can inspect a failure, edit the test, and rerun it. A passing rerun does not prove the fix is repeatable. You still need to check whether the failure came from a missing accessibility identifier, a wait condition, or device state left by an earlier run.&lt;/p&gt;

&lt;h3&gt;
  
  
  What does the Momentic mobile skill require?
&lt;/h3&gt;

&lt;p&gt;Install the skill from your project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx momentic-mobile skills &lt;span class="nt"&gt;--yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run a mobile test, you also need an app build and a configured simulator or emulator target. Check the &lt;a href="https://momentic.ai/docs" rel="noopener noreferrer"&gt;Momentic documentation&lt;/a&gt; for project setup.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>ai</category>
      <category>ios</category>
      <category>android</category>
    </item>
    <item>
      <title>Real Device Cloud Testing: How to Test Mobile Apps on Devices Virtually</title>
      <dc:creator>Wei-Wei Wu</dc:creator>
      <pubDate>Mon, 09 Nov 2026 17:27:21 +0000</pubDate>
      <link>https://dev.to/wuweiweiwu/real-device-cloud-testing-how-to-test-mobile-apps-on-devices-virtually-27l5</link>
      <guid>https://dev.to/wuweiweiwu/real-device-cloud-testing-how-to-test-mobile-apps-on-devices-virtually-27l5</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://momentic.ai/blog/real-device-cloud-testing" rel="noopener noreferrer"&gt;Momentic blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It’s important to understand what real device cloud testing is and how it works. It’s also important to understand that it’s not the only way to test your app across a range of devices. In fact, in some instances it may well hold you back.&lt;/p&gt;

&lt;p&gt;This article guides you through the basics of real device testing and how it works, then discusses its pros and cons compared to alternatives. For teams that need to&lt;a href="https://momentic.ai/blog/how-to-build-qa" rel="noopener noreferrer"&gt;scale efficiently&lt;/a&gt; or maintain rapid release cycles, conducting most testing on emulators or simulators may be a more practical option.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary: Real Device Cloud Testing and Its Alternatives
&lt;/h3&gt;

&lt;p&gt;Here’s a quick summary of the key takeaways from this blog. We’ll cover each of these in more detail below.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Topic&lt;/th&gt;
&lt;th&gt;Key takeaway&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Real device testing&lt;/td&gt;
&lt;td&gt;Tests app functionality and performance on physical devices.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Real device clouds&lt;/td&gt;
&lt;td&gt;Provide remote access to physical devices without maintaining your own device farm.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Virtual testing&lt;/td&gt;
&lt;td&gt;Emulators and simulators provide virtual environments for testing across devices and OS versions.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Real vs. virtual&lt;/td&gt;
&lt;td&gt;Real devices capture hardware-specific behaviour; virtual devices offer scalable testing without physical hardware.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost &amp;amp; scale&lt;/td&gt;
&lt;td&gt;Real device testing can become costly and introduce device availability constraints as testing scales.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Emulators &amp;amp; simulators&lt;/td&gt;
&lt;td&gt;Useful for broad, routine and automated testing across a range of virtual environments.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Where real devices matter&lt;/td&gt;
&lt;td&gt;Physical devices remain useful for validating sensors, OEM-specific behaviour and other hardware-dependent issues.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modern QA&lt;/td&gt;
&lt;td&gt;Virtual testing can support high-volume, AI-driven testing and rapid release cycles.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Real device testing uses physical devices to verify whether your app works as intended. To test on real devices, you can either run your own device farm if you have the expertise and resources, or use a third-party real device cloud.&lt;/p&gt;

&lt;p&gt;Real device testing provides the most accurate picture of app performance, but may be slower and expensive to scale. For teams that this won’t work for, there are alternatives.&lt;a href="https://momentic.ai/blog/emulators-vs-simulators-in-mobile-testing" rel="noopener noreferrer"&gt;Emulators and simulators&lt;/a&gt; allow you to test most aspects of your app virtually; although there are OEM-specific behaviors you can’t verify, today’s options allow you to test to a high degree of accuracy without the need for extensive real device testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Real Device Testing?
&lt;/h2&gt;

&lt;p&gt;Real device testing is the process of verifying your apps’ functionality and performance on real devices.&lt;/p&gt;

&lt;p&gt;Thanks to a diversification of available combinations of devices, platforms, operating systems, screen sizes, and screen resolutions, your user base is likely to access your app on a broad range of devices. These will affect how your UI displays and how certain features work.&lt;/p&gt;

&lt;p&gt;To avoid alienating chunks of your workforce, you need to be sure that your app works equally well across likely device/platform/OS/screen combos. Some teams choose to test this on real devices because some issues are difficult to reproduce elsewhere, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Touch and physical interaction&lt;/li&gt;
&lt;li&gt;Network conditions&lt;/li&gt;
&lt;li&gt;Hardware-dependent bugs&lt;/li&gt;
&lt;li&gt;Real-world usability&lt;/li&gt;
&lt;li&gt;Some performance issues (frame drops, slow startup, memory pressure, battery drain)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What is a Real Device Cloud?
&lt;/h3&gt;

&lt;p&gt;A real device cloud is a service that lets you test your app on physical devices hosted remotely in a data centre.&lt;/p&gt;

&lt;p&gt;So, rather than maintaining a device farm as part of your own infrastructure, you can connect to a service that offers thousands of them through a web interface or testing API. This avoids the time/resource drain of device farm hardware maintenance.&lt;/p&gt;

&lt;p&gt;For example, using a real device cloud would allow you to&lt;a href="https://momentic.ai/android-testing" rel="noopener noreferrer"&gt;test a native Android app&lt;/a&gt; across Samsung, Google, and other Android phones across different Android versions, without having to actually own or maintain the devices yourself. You could similarly&lt;a href="https://momentic.ai/ios-testing" rel="noopener noreferrer"&gt;test iOS apps&lt;/a&gt; across different iPhones and iOS versions.&lt;/p&gt;

&lt;p&gt;There is a trade-off, however. Third-party real device clouds are paid-for services, and costs can increase significantly as you scale. You may also experience queues for the most in-demand device and platform combinations, slowing down your release cycles.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Does Real Device Cloud Testing Work?
&lt;/h3&gt;

&lt;p&gt;Here’s a quick, five-step overview of how you carry out real device cloud testing. The slowdowns mentioned above tend to happen between steps two and three; if other device farm users are already testing on the devices you need, you’ll have to wait your turn.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You upload your app&lt;/li&gt;
&lt;li&gt;The cloud gives you access to real devices&lt;/li&gt;
&lt;li&gt;You install/run the app on those devices&lt;/li&gt;
&lt;li&gt;You interact with the app remotely or run automated tests&lt;/li&gt;
&lt;li&gt;The service captures results such as screenshots, videos, logs, crashes, and performance data&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  When you need a real device, and when you don't
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Test needs&lt;/th&gt;
&lt;th&gt;Real device&lt;/th&gt;
&lt;th&gt;Simulator or emulator&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;UI flows, navigation, forms, login&lt;/td&gt;
&lt;td&gt;Not needed&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Layout across screen sizes and OS versions&lt;/td&gt;
&lt;td&gt;Not needed&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deep links, push notification handling (simulated)&lt;/td&gt;
&lt;td&gt;Not needed&lt;/td&gt;
&lt;td&gt;Yes, on recent iOS simulators and Android emulators&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Camera, NFC, Bluetooth, biometrics with real hardware&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No, or only mocked&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Carrier networks, SIM, SMS&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Battery, thermal throttling, real performance numbers&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OEM-specific Android skins and bugs (Samsung, Xiaomi)&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Partly, with vendor images&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Most teams run functional regression tests on simulators and emulators on every pull request, because they start faster and run in parallel cheaply. They keep a smaller real-device pass for hardware features and before major releases.&lt;/p&gt;

&lt;p&gt;For how the two virtual options differ, see&lt;a href="https://momentic.ai/blog/emulators-vs-simulators-in-mobile-testing" rel="noopener noreferrer"&gt;emulators vs simulators in mobile testing&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real device cloud providers compared
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Provider&lt;/th&gt;
&lt;th&gt;Devices&lt;/th&gt;
&lt;th&gt;Automation frameworks&lt;/th&gt;
&lt;th&gt;Pricing model&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;BrowserStack App Automate&lt;/td&gt;
&lt;td&gt;Real iOS and Android devices&lt;/td&gt;
&lt;td&gt;Appium, Espresso, XCUITest, Maestro, Flutter and others&lt;/td&gt;
&lt;td&gt;Subscription, priced by parallel sessions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sauce Labs&lt;/td&gt;
&lt;td&gt;Real devices plus emulators and simulators&lt;/td&gt;
&lt;td&gt;Appium, Espresso, XCUITest&lt;/td&gt;
&lt;td&gt;Subscription, priced by concurrency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LambdaTest&lt;/td&gt;
&lt;td&gt;Real devices plus emulators and simulators&lt;/td&gt;
&lt;td&gt;Appium, Espresso, XCUITest&lt;/td&gt;
&lt;td&gt;Subscription, priced by parallel sessions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AWS Device Farm&lt;/td&gt;
&lt;td&gt;Real devices&lt;/td&gt;
&lt;td&gt;Appium, Espresso, XCUITest&lt;/td&gt;
&lt;td&gt;Pay per device minute after a one-time free trial, or a flat monthly rate per unmetered device slot&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Firebase Test Lab&lt;/td&gt;
&lt;td&gt;Real and virtual Android devices, real iOS devices&lt;/td&gt;
&lt;td&gt;Espresso and other instrumentation tests, Robo, XCTest/XCUITest, Game Loop&lt;/td&gt;
&lt;td&gt;Free daily quota, then billed per device hour, per minute&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Firebase now labels Test Lab as deprecated in its product navigation, so we don't recommend it for new setups. For more options, see&lt;a href="https://momentic.ai/blog/browserstack-alternatives" rel="noopener noreferrer"&gt;BrowserStack alternatives&lt;/a&gt; and&lt;a href="https://momentic.ai/blog/ai-native-sauce-labs-alternatives" rel="noopener noreferrer"&gt;Sauce Labs alternatives&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Are There Alternatives to Real Device Testing?
&lt;/h2&gt;

&lt;p&gt;Yes. Instead of using a real device cloud for testing, you can test your apps virtually using emulators and simulators. These aim to recreate real device environments as closely as possible while providing a faster, lower-cost alternative to real device clouds that’s easier to scale.&lt;/p&gt;

&lt;p&gt;Some open-source emulators and simulators are free to use. They are also available as native functionality on some&lt;a href="https://momentic.ai/blog/mobile-testing-frameworks" rel="noopener noreferrer"&gt;mobile testing platforms&lt;/a&gt;, such as&lt;a href="https://momentic.ai/" rel="noopener noreferrer"&gt;Momentic&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use Virtual Device Testing Instead of Real Device Testing?
&lt;/h3&gt;

&lt;p&gt;It’s not simply a case of either/or. Many teams use emulators and simulators for bulk routine testing tasks, then use a limited amount of real device testing for final validation and OEM-specific behavior.&lt;/p&gt;

&lt;p&gt;Why? Extensive real device cloud testing isn’t always practical because it incurs high costs as you scale, and device queues slow your release cycles down. In the current landscape, where engineering teams are under pressure to accelerate release cycles while validating&lt;a href="https://momentic.ai/blog/the-slop-is-out-of-the-bottle" rel="noopener noreferrer"&gt;unprecedented amounts of AI-generated code&lt;/a&gt;, it’s not a strong fit for many teams.&lt;/p&gt;

&lt;p&gt;And as technology evolves, virtual device testing can replicate real device environments with an increasing degree of accuracy. For example, AI can synthesize realistic sensor inputs, such as GPS traces, motion patterns, and network fluctuations, then feed these into emulators to produce test conditions that mimic real-world usage.&lt;/p&gt;

&lt;p&gt;This makes them a natural companion for autonomous, AI-driven QA processes because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They can provide the realistic execution environment needed for AI tools to surface meaningful issues&lt;/li&gt;
&lt;li&gt;Agentic QA workflows help teams process the volume of results from emulator-based testing (particularly useful for testing reams of AI-generated product code)&lt;/li&gt;
&lt;li&gt;AI models can prioritize emulator test runs based on code changes, historical failures, and usage data&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Emulators and Simulators: How Do They Work?
&lt;/h2&gt;

&lt;p&gt;The terms ‘emulator’ and ‘simulator’ aren’t interchangeable (though many non-engineers use them that way).&lt;/p&gt;

&lt;p&gt;An emulator recreates the entire hardware and software environment of a real device as accurately as possible. It mimics the device’s CPU architecture, peripherals, firmware, and often the operating system behavior.&lt;/p&gt;

&lt;p&gt;A simulator reproduces the behavior of a device without modelling hardware specifics. Typically, it’ll run on a host machine’s CPU instructions to simulate system APIs and UI components rather than running the real device OS image.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Run Virtual Testing On Emulators and Simulators
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Choose a virtual device&lt;/li&gt;
&lt;li&gt;Launch the emulator or simulator on your machine or in a hosted environment&lt;/li&gt;
&lt;li&gt;Install your app&lt;/li&gt;
&lt;li&gt;Run tests (manual or automated)&lt;/li&gt;
&lt;li&gt;Capture results (automated testing platforms can collect screenshots, videos, logs, crashes, and test results for analysis)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Pros and Cons of Real Device Testing vs Testing on Emulators and Simulators
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Real devices&lt;/th&gt;
&lt;th&gt;Emulators&lt;/th&gt;
&lt;th&gt;Simulators&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hardware&lt;/td&gt;
&lt;td&gt;Runs on physical device hardware&lt;/td&gt;
&lt;td&gt;Recreates device hardware and software virtually&lt;/td&gt;
&lt;td&gt;Simulates device software and behaviour&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Real-world behaviour&lt;/td&gt;
&lt;td&gt;Uses actual sensors, peripherals and network conditions&lt;/td&gt;
&lt;td&gt;Can simulate sensors, peripherals and network conditions&lt;/td&gt;
&lt;td&gt;Simulates software-level behaviour&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;Measures performance on physical hardware&lt;/td&gt;
&lt;td&gt;Measures performance within a virtualised environment&lt;/td&gt;
&lt;td&gt;Measures software behaviour on the host machine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scale&lt;/td&gt;
&lt;td&gt;Requires access to individual physical devices&lt;/td&gt;
&lt;td&gt;Creates multiple virtual device environments&lt;/td&gt;
&lt;td&gt;Creates multiple simulated environments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Requires physical devices or access to a device cloud&lt;/td&gt;
&lt;td&gt;Can run locally or in the cloud&lt;/td&gt;
&lt;td&gt;Can run locally or in the cloud&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical use&lt;/td&gt;
&lt;td&gt;Hardware-specific and final validation&lt;/td&gt;
&lt;td&gt;Broad environment and automated testing&lt;/td&gt;
&lt;td&gt;UI and software-behaviour testing&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What real device testing costs
&lt;/h2&gt;

&lt;p&gt;Three costs grow with the suite: parallel sessions (most clouds price by how many tests can run at once), session time (real devices are slower to boot and reset than emulators), and queue time when the devices you want are busy. A suite that runs in 10 minutes on 20 parallel emulators can take much longer on 5 real devices. Price the parallelism you need, not the device catalogue.&lt;/p&gt;

&lt;p&gt;For Android tooling to run on emulators and devices, see the&lt;a href="https://momentic.ai/blog/best-android-testing-tools" rel="noopener noreferrer"&gt;best Android testing tools&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Virtual Device Testing: How Momentic Helps
&lt;/h2&gt;

&lt;p&gt;Momentic runs mobile tests on iOS simulators and Android emulators, locally or hosted. Tests are YAML files with natural-language steps, run with &lt;code&gt;npx momentic-mobile run&lt;/code&gt;, so the same suite runs on a laptop and in CI. Keep a real-device pass for camera, biometrics and carrier features.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploy Multiple Times a Day While Minimizing Defects
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;“We’ve been adamant about leaning on the best tools available to support our team as we scale. That’s why we use Momentic for testing.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Alex CuiCo-founder and CTO, GPTZero&lt;/p&gt;

&lt;p&gt;&lt;a href="https://momentic.ai/customers/gptzero" rel="noopener noreferrer"&gt;AI text identification platform GPTZero&lt;/a&gt; found that&lt;a href="https://momentic.ai/blog/cypress-alternatives" rel="noopener noreferrer"&gt;Cypress&lt;/a&gt; could not keep up with their demands as their product scaled. Instead of upping the engineering hours spent on QA, they chose to automate end-to-end tests with Momentic’s agentic testing platform.&lt;/p&gt;

&lt;p&gt;This resulted in an &lt;strong&gt;89% decrease in defect escape rate&lt;/strong&gt;, alongside &lt;strong&gt;80% faster release cycles&lt;/strong&gt; and an &lt;strong&gt;acceleration of 75% in test creation times&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://momentic.ai/sales" rel="noopener noreferrer"&gt;Get in touch&lt;/a&gt; to see what Momentic could do for your team.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is real device cloud testing?
&lt;/h3&gt;

&lt;p&gt;Real device cloud testing lets teams remotely test apps on physical devices hosted by a third-party provider.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a real device cloud?
&lt;/h3&gt;

&lt;p&gt;A real device cloud is a remotely hosted collection of physical smartphones and tablets used for app testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is real device testing better than emulators?
&lt;/h3&gt;

&lt;p&gt;Real devices are better for hardware-specific validation, while emulators are faster and easier to scale for routine testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the disadvantages of real device cloud testing?
&lt;/h3&gt;

&lt;p&gt;It can become expensive at scale and may involve waiting for popular devices to become available.&lt;/p&gt;

&lt;h3&gt;
  
  
  When should you use real devices instead of emulators?
&lt;/h3&gt;

&lt;p&gt;Use real devices when testing sensors, OEM-specific behavior, hardware performance, or other device-dependent issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is emulator testing enough?
&lt;/h3&gt;

&lt;p&gt;For most functional tests, yes. Use real devices for hardware features, carrier behaviour and performance numbers.&lt;/p&gt;

&lt;h3&gt;
  
  
  How much does a real device cloud cost?
&lt;/h3&gt;

&lt;p&gt;It depends on parallel sessions. Most providers charge a subscription per concurrent session; AWS Device Farm and Firebase Test Lab also charge per device minute or hour.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>mobile</category>
      <category>ios</category>
      <category>android</category>
    </item>
    <item>
      <title>AI Agents in QA Testing: Is 2026 The Year Everything Changes?</title>
      <dc:creator>Wei-Wei Wu</dc:creator>
      <pubDate>Mon, 09 Nov 2026 17:27:20 +0000</pubDate>
      <link>https://dev.to/wuweiweiwu/ai-agents-in-qa-testing-is-2026-the-year-everything-changes-141d</link>
      <guid>https://dev.to/wuweiweiwu/ai-agents-in-qa-testing-is-2026-the-year-everything-changes-141d</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://momentic.ai/blog/ai-agents-in-qa-testing" rel="noopener noreferrer"&gt;Momentic blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Is 2026 set to be the year of the AI agent?&lt;/p&gt;

&lt;p&gt;It certainly seems to be shaping up that way. With the cost and efficiency benefits of GenAI now firmly established,&lt;a href="https://www.mckinsey.com/capabilities/mckinsey-digital/our-insights/superagency-in-the-workplace-empowering-people-to-unlock-ais-full-potential-at-work" rel="noopener noreferrer"&gt;a recent McKinsey study&lt;/a&gt; suggests that 92% of businesses are planning to invest more in generative AI over the next three years.&lt;/p&gt;

&lt;p&gt;AI agents - in QA testing and across the workplace - are one of the fastest-growing iterations of this. Deloitte projects that&lt;a href="https://www.deloitte.com/global/en/about/press-room/deloitte-globals-2025-predictions-report.html" rel="noopener noreferrer"&gt;25% of all businesses&lt;/a&gt; investing in GenAI will deploy AI agents across 2026, rising to 50% in 2027. That's a staggering adoption rate for a technology that has only become viable in the past couple of years.&lt;/p&gt;

&lt;p&gt;Salesforce and Microsoft have both recently launched platforms to help engineers build their own AI agents. Meanwhile, Oracle has launched over 50 AI agents for enterprise use, with other vendors rapidly expanding their product suites accordingly.&lt;/p&gt;

&lt;p&gt;To keep you ahead of the game, here's what you need to know about the potential of AI agents in QA testing and what to expect this year.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI Agents in QA Testing: Where We Are in 2026?
&lt;/h2&gt;

&lt;p&gt;Unlike AI-based automation, which is rules-based and anchored around predefined workflows, AI agents are autonomous AIs that can make decisions, adjust to feedback, and adapt their approach to unexpected changes in conditions.&lt;/p&gt;

&lt;p&gt;Think of them as an autonomous digital coworker, rather than a smart (but ultimately process driven) bit of software.&lt;/p&gt;

&lt;p&gt;These are no longer 'the next big trend' or 'on-the-horizon technology' - they are used across businesses, right now, to make huge efficiency gains and generate valuable insights via analyzing vast swathes of data. For example, you might have come across AI customer support agents, or used a conversational interface to structure content for a blog or website.&lt;/p&gt;

&lt;p&gt;In software testing specifically, AI agents have the power to unlock transformational change for businesses. Think smarter, faster automation for more complex tests, vastly expanded test coverage, better testing for new technologies, and plenty more besides.&lt;/p&gt;

&lt;p&gt;Here's how AI agents are set to transform your QA testing processes this year -and beyond.&lt;/p&gt;

&lt;h2&gt;
  
  
  8 Ways AI Agents are Transforming QA Testing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. More Tests, Quicker
&lt;/h3&gt;

&lt;p&gt;Kicking things off with a simple, but useful, effect of AI agents: if you can test quickly, you can test more. If you can test more, you gain more insight into your app and have a greater chance of picking up defects. If you catch more defects before shipping your code, your product quality increases.&lt;/p&gt;

&lt;p&gt;AI agents allow software teams of all sizes to expand their QA test coverage, with no extra time cost, even for&lt;a href="https://momentic.ai/blog/end-to-end-testing-guide" rel="noopener noreferrer"&gt;complex processes like end to end testing&lt;/a&gt;. In fact, with an AI agent you'll test far more in the fraction of the time it takes for your external QA processes to come full cycle - which leads us to...&lt;/p&gt;

&lt;h3&gt;
  
  
  2. An Accelerated Shift Away from External QA
&lt;/h3&gt;

&lt;p&gt;A&lt;a href="https://momentic.ai/blog/why-ai-will-automate-qa" rel="noopener noreferrer"&gt;move away from external QA&lt;/a&gt; has been on the cards for a while now, as automation - then AI automation - increased the amount of testing it was feasible to do in house. Autonomous AI agents could be the final nail in the QA coffin for many businesses.&lt;/p&gt;

&lt;p&gt;Testing via external QA has always been slow and expensive, with a&lt;a href="https://momentic.ai/blog/modern-teams" rel="noopener noreferrer"&gt;risk of technical debt&lt;/a&gt; thanks to lack of direct engineer involvement in testing.&lt;/p&gt;

&lt;p&gt;But what if your AI testing agent could build and run those tests in minutes in house, with just a few plain English prompts, and integrate directly into your CI/CD pipelines? Would you have &lt;em&gt;any&lt;/em&gt; need of external QA then?&lt;/p&gt;

&lt;p&gt;Probably not, which is why we expect it to shrink over the course of the next 5 years.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Better Testing for Conversational Interfaces
&lt;/h3&gt;

&lt;p&gt;GenAI is completely transforming how consumers interact with technology. Think of how often people use conversational AI ('conversational user interfaces', or CUI, to give them their official title) across their everyday lives.&lt;/p&gt;

&lt;p&gt;Being able to incorporate CUIs into your products and customer-facing business processes sets you up for long-term success. It offers both convenience and accessibility for your customers and major efficiency gains for your business.&lt;/p&gt;

&lt;p&gt;Previously, CUI implementation has been hindered by how complex these interfaces are to build and test. Whilst Big Tech has been able to throw resources behind Siri, ChatGPT, and Google Assistant, smaller businesses have lagged behind with low level adoption (basic customer service chatbots) or none at all.&lt;/p&gt;

&lt;p&gt;By generating huge datasets of conversational data for training, and analyzing CUI responses for sentiment and intent, AI agents cut the complexity of CUI testing significantly - and make building high-quality CUIs feasible for a wider range of companies.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. More Targeted Testing and Development Workflows
&lt;/h3&gt;

&lt;p&gt;One of the most powerful things about AI agents in QA testing is their ability for predictive analytics. As well as simply automating your tests, they can analyze patterns in previous test runs to identify where bugs are most likely to occur.&lt;/p&gt;

&lt;p&gt;As well as allowing the AI agent to prioritize high-risk areas for more testing, this helps engineering teams organize their time more effectively. Engineers can dedicate more resources to areas susceptible to bugs and improve overall software quality as a result.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. (Even) More Focus on App Security and Data Privacy
&lt;/h3&gt;

&lt;p&gt;AI agents use vast amounts of data to run and optimize&lt;a href="https://momentic.ai/blog/how-to-build-qa" rel="noopener noreferrer"&gt;QA testing&lt;/a&gt; processes. Whilst some of this may be artificial data, a portion is likely to be production data gathered from real users.&lt;/p&gt;

&lt;p&gt;Without the right safeguards in place, this can pose security and compliance risks for software businesses - with potential reputational and legal repercussions in the event of a breach.&lt;/p&gt;

&lt;p&gt;Smart businesses will audit and upgrade their data governance processes alongside GenAI adoption, to make sure that integration of new tech doesn't impact their ability to store data securely and maintain users' trust. Expect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A push for more security awareness among employees for faster identification of unusual data access or inconsistent outputs&lt;/li&gt;
&lt;li&gt;Evolution of traditional security tools like encryption, tokenization, and DRM to optimize data security in use and transit, such as continuous encryption&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Bias Testing Becomes Central to App Quality
&lt;/h3&gt;

&lt;p&gt;Your AI agent is only as good as the data you train it on. Poor quality datasets lead to redundant or inaccurate results - which is absolutely not what you need when trying to build and release a quality product.&lt;/p&gt;

&lt;p&gt;As a result, software teams are increasingly focused on maintaining high quality datasets and performing regular testing to ensure outputs are inclusive and accurate. Bias testing - making sure that AI agents aren't influenced by human biases in datasets - is a significant part of this, and can include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using fairness metrics and exploratory data analysis to identify potential biases in data sources&lt;/li&gt;
&lt;li&gt;Diversifying training data to reduce likelihood of bias from limited sources&lt;/li&gt;
&lt;li&gt;Applying algorithmic fairness techniques across the training process&lt;/li&gt;
&lt;li&gt;Using bias detection tools and libraries to find and mitigate bias in AI&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Acceleration of Shift Left/Shift Right Testing
&lt;/h3&gt;

&lt;p&gt;Shift Left methodology shifts testing to run concurrently with development, so that you pick up bugs earlier, when they are easier and cheaper to fix.&lt;/p&gt;

&lt;p&gt;Shift Right methodology emphasizes the role of post go-live testing in continuous improvement.&lt;/p&gt;

&lt;p&gt;Both have major CI/CD benefits, and both are becoming increasingly popular among software teams wanting to ship fast and streamline costs whilst increasing product quality.&lt;/p&gt;

&lt;p&gt;Shift Left and Shift Right methodologies are made &lt;em&gt;significantly&lt;/em&gt; easier by AI testing agents for QA, so expect adoption to continue - and perhaps speed up. This is because the speed of AI agent testing makes it more feasible to run testing and development concurrently, whilst predictive analytic capabilities can help teams accurately identify key monitoring and testing areas after product launch.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Less Time Needed For Test Maintenance
&lt;/h3&gt;

&lt;p&gt;Fed up of fragile CSS/XPath locators breaking your test scripts? AI testing agents can adapt test cases to changes in UI or requirements clauses automatically.&lt;/p&gt;

&lt;p&gt;What this means for software and QA teams: fewer hours piled into routine test maintenance and fixing flaky tests, and more hours dedicated to valuable development work building new features and updates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Meet Mo: Momentic’s AI QA Agent
&lt;/h2&gt;

&lt;p&gt;AI agents can do more than create and maintain automated tests. They can also investigate a product independently, explore real user journeys, and uncover defects that predefined test scripts might miss.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://momentic.ai/mo" rel="noopener noreferrer"&gt;Mo is Momentic’s AI QA agent&lt;/a&gt; for autonomous bug bashing across web, iOS and Android.&lt;/strong&gt; Point Mo at a URL or app build, describe the feature, release, or user journey that matters, and let it explore the product.&lt;/p&gt;

&lt;p&gt;Mo works through real user flows across hosted browsers, emulators, and simulators. When it finds an issue, it returns an evidence-backed bug report with a recording, reproduction steps, and its reasoning. You give Mo an objective, review the findings, and fix them yourself or hand the report to your coding agent. For each bug, Mo's Coder agent also writes a regression test and opens it as a draft pull request.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQs
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;What are AI agents in QA testing?&lt;/strong&gt;
They’re autonomous AIs that can make decisions, learn from feedback, and adapt testing when conditions change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How are AI agents different from AI-based automation?&lt;/strong&gt;
AI-based automation is rules-based with predefined workflows; AI agents are adaptive and autonomous.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How do AI agents improve test coverage and speed?&lt;/strong&gt;
They let teams run more tests faster, without adding extra time cost, even for complex end-to-end flows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Can AI agents reduce reliance on external QA teams?&lt;/strong&gt;
Yes because they can build and run tests quickly in-house and integrate into CI/CD pipelines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How do AI agents reduce test maintenance work?&lt;/strong&gt;
They can automatically adapt test cases when UI or requirements change, reducing flaky/broken tests.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>testing</category>
      <category>ai</category>
      <category>qa</category>
      <category>automation</category>
    </item>
    <item>
      <title>Playwright fixtures: built-in, custom and worker-scoped</title>
      <dc:creator>Wei-Wei Wu</dc:creator>
      <pubDate>Thu, 05 Nov 2026 16:00:00 +0000</pubDate>
      <link>https://dev.to/wuweiweiwu/playwright-fixtures-built-in-custom-and-worker-scoped-1jdo</link>
      <guid>https://dev.to/wuweiweiwu/playwright-fixtures-built-in-custom-and-worker-scoped-1jdo</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://momentic.ai/blog/playwright-fixtures-guide" rel="noopener noreferrer"&gt;Momentic blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Playwright fixtures supply test dependencies and handle setup and teardown. This guide uses the built-in &lt;code&gt;page&lt;/code&gt;, &lt;code&gt;context&lt;/code&gt;, &lt;code&gt;browser&lt;/code&gt;, and &lt;code&gt;request&lt;/code&gt; fixtures.&lt;/li&gt;
&lt;li&gt;Every code example is runnable as written, including a custom fixture defined with &lt;code&gt;test.extend&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Test-scoped fixtures run for each test. Worker-scoped fixtures can serve multiple tests, while &lt;code&gt;auto&lt;/code&gt; fixtures run without an explicit request.&lt;/li&gt;
&lt;li&gt;The guide covers authentication with &lt;code&gt;storageState&lt;/code&gt;, per-project fixture overrides, and when &lt;code&gt;beforeEach&lt;/code&gt; is simpler than a fixture.&lt;/li&gt;
&lt;li&gt;The troubleshooting sections explain common mistakes, including hidden &lt;code&gt;auto&lt;/code&gt; dependencies, shared worker state, and missed teardown.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What a Playwright fixture actually is
&lt;/h2&gt;

&lt;p&gt;Playwright fixtures make test setup explicit through named arguments. When a test requests a fixture in its callback, Playwright resolves that fixture and its dependencies, runs setup, and passes the value to the test. After the test finishes, Playwright runs the fixture’s teardown. For a test-scoped resource such as a page, that lifecycle gives each test its own setup and cleanup.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;beforeEach&lt;/code&gt; hook runs shared setup before each test. A fixture runs when a test or another fixture requests it, unless you mark it automatic. Fixtures can also depend on one another, so Playwright can set them up in dependency order and tear them down afterward. Hooks remain useful for simple setup that every test needs, but fixtures make reusable resources and their cleanup explicit.&lt;/p&gt;

&lt;p&gt;The built-in starting points are &lt;code&gt;page&lt;/code&gt;, &lt;code&gt;context&lt;/code&gt;, &lt;code&gt;browser&lt;/code&gt;, and &lt;code&gt;request&lt;/code&gt;. They provide a browser page, an isolated browser context, a browser instance, and an API request client, respectively. The next section shows how their scopes affect what tests share.&lt;/p&gt;

&lt;h2&gt;
  
  
  Built-in fixtures: page, context, browser, request
&lt;/h2&gt;

&lt;p&gt;Playwright gives each test a fresh &lt;code&gt;page&lt;/code&gt;, &lt;code&gt;context&lt;/code&gt;, and &lt;code&gt;request&lt;/code&gt; fixture by default. The &lt;code&gt;browser&lt;/code&gt; fixture lives for the worker, which can run multiple tests. A browser contains contexts, and each context contains pages. The &lt;code&gt;request&lt;/code&gt; fixture provides a separate API request context for HTTP calls, so an API call does not depend on the page’s browser context.&lt;/p&gt;

&lt;p&gt;Save this as &lt;code&gt;tests/built-ins.spec.ts&lt;/code&gt;. The test starts a local HTTP server, so it needs no application or external endpoint.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createServer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:http&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;uses browser, context, page, and request&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;browser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/health&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text/html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;h1&amp;gt;Ready&amp;lt;/h1&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;127.0.0.1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;address&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Server did not bind to a TCP port&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;baseURL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`http://127.0.0.1:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;baseURL&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;heading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ready&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}))&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toBeVisible&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;toContain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;browser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isConnected&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;baseURL&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/health`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;toEqual&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Playwright and its Chromium browser, then run the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; @playwright/test
npx playwright &lt;span class="nb"&gt;install &lt;/span&gt;chromium
npx playwright &lt;span class="nb"&gt;test &lt;/span&gt;tests/built-ins.spec.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Playwright creates a new browser context and page for each test, which keeps browser state isolated. It reuses the worker-scoped browser to avoid launching a browser for every test. The test-scoped &lt;code&gt;request&lt;/code&gt; fixture has its own request context and cleanup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing a custom fixture with test.extend
&lt;/h2&gt;

&lt;p&gt;A custom fixture can give each test a seeded API client and close its local server afterward. &lt;code&gt;test.extend&lt;/code&gt; defines the dependencies. Playwright starts the server before creating the client, then runs teardown after the test releases it with &lt;code&gt;use()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Install the test runner, then save the two files below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; @playwright/test @types/node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;fixtures.ts&lt;/code&gt;. The &lt;code&gt;seededApi&lt;/code&gt; fixture requests both the custom &lt;code&gt;apiServer&lt;/code&gt; fixture and Playwright’s built-in &lt;code&gt;request&lt;/code&gt; fixture. The server keeps its data in memory, so the example needs no external service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createServer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:http&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;SeededApi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;seededItem&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;create&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;get&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;apiServer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;seededApi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SeededApi&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;apiServer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;content-type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/items&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="k"&gt;await &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
        &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;

      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="sr"&gt;items&lt;/span&gt;&lt;span class="se"&gt;\/(\d&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="sr"&gt;$/&lt;/span&gt;&lt;span class="p"&gt;)?.[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statusCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Not found&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
      &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;127.0.0.1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;address&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Server did not bind to a TCP port&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`http://127.0.0.1:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
      &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="na"&gt;seededApi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;apiServer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;apiServer&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/items`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;apiServer&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/items/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;seededItem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Existing item&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;seededItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;items.spec.ts&lt;/code&gt;. Import the extended &lt;code&gt;test&lt;/code&gt;, not the unmodified one, so Playwright can resolve &lt;code&gt;seededApi&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./fixtures&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;reads a seeded item and creates another&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;seededApi&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;seededApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seededApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seededItem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seededApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seededItem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;created&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;seededApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;New item&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;seededApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;created&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;created&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;npx playwright test items.spec.ts&lt;/code&gt;. Both custom fixtures are test-scoped by default. Each test gets a fresh server, and the code after &lt;code&gt;await use(...)&lt;/code&gt; closes it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test-scoped vs worker-scoped fixtures
&lt;/h2&gt;

&lt;p&gt;A test-scoped fixture runs for each test that requests it. A worker-scoped fixture runs once in a worker process and can serve multiple tests, including tests in different files assigned to that worker. Playwright may restart a worker after a failure, so worker scope does not mean once for the entire suite.&lt;/p&gt;

&lt;p&gt;Save this example as &lt;code&gt;fixture-scope.spec.ts&lt;/code&gt;. The server starts once per worker, while &lt;code&gt;apiResult&lt;/code&gt; makes a fresh request for each test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createServer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:http&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;TestFixtures&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;apiResult&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;WorkerFixtures&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;serverURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;TestFixtures&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;WorkerFixtures&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;serverURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ok&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}))&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;127.0.0.1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;address&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Server did not receive a TCP port&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;

      &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`http://127.0.0.1:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
        &lt;span class="p"&gt;})&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;worker&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;

  &lt;span class="na"&gt;apiResult&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;serverURL&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;serverURL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispose&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;returns the server response&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;apiResult&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;apiResult&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toEqual&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ok&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it with &lt;code&gt;npx playwright test fixture-scope.spec.ts&lt;/code&gt;. Use worker scope for expensive resources that tests can safely share. Keep mutable test data in test-scoped fixtures, because changes to worker-scoped state can leak into later tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Auto fixtures that run without being requested
&lt;/h2&gt;

&lt;p&gt;An auto fixture runs for every test that uses the extended &lt;code&gt;test&lt;/code&gt;, even when the test does not request the fixture by name. You can use one to collect browser console errors and fail the test after its assertions finish.&lt;/p&gt;

&lt;p&gt;Save this as &lt;code&gt;auto-console.spec.ts&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Fixtures&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;consoleErrors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Fixtures&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;consoleErrors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;type&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;type&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
      &lt;span class="p"&gt;};&lt;/span&gt;

      &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;console&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onConsole&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;off&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;console&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onConsole&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toEqual&lt;/span&gt;&lt;span class="p"&gt;([]);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;shows the save button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setContent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Save&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})).&lt;/span&gt;&lt;span class="nf"&gt;toBeVisible&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the example with these commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; @playwright/test
npx playwright &lt;span class="nb"&gt;install &lt;/span&gt;chromium
npx playwright &lt;span class="nb"&gt;test &lt;/span&gt;auto-console.spec.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The test requests only &lt;code&gt;page&lt;/code&gt;, but Playwright still starts &lt;code&gt;consoleErrors&lt;/code&gt; before the test and checks the collected messages afterward. Keep auto fixtures limited to checks you want in every test. Otherwise, a test can fail because of setup it never names.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authentication fixtures with storageState
&lt;/h2&gt;

&lt;p&gt;Authenticate once in a setup project, then load the saved browser state into each test’s fresh context. The example below runs against a small local app, so it needs no external account. The login credentials and cookie are for demonstration only.&lt;/p&gt;

&lt;p&gt;Install Playwright and its browser.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
npm i &lt;span class="nt"&gt;-D&lt;/span&gt; @playwright/test
npx playwright &lt;span class="nb"&gt;install &lt;/span&gt;chromium
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;app.cjs&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createServer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:http&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/login&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text/html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;``&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/login&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="k"&gt;await &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fields&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URLSearchParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;demo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
        &lt;span class="nx"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;demo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeHead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;302&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/dashboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Set-Cookie&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;session=demo; HttpOnly; SameSite=Lax&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/dashboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
      &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cookie&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;session=demo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text/html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;h1&amp;gt;Dashboard&amp;lt;/h1&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeHead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Unauthorized&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;127.0.0.1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;playwright.config.ts&lt;/code&gt;. The dependency makes the setup project finish before the authenticated spec starts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;defineConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;use&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;baseURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http://127.0.0.1:3100&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;webServer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node app.cjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http://127.0.0.1:3100/login&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;projects&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;setup&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;testMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;**/auth.setup.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;chromium&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;testMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;**/auth.spec.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;dependencies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;setup&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="na"&gt;use&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;browserName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;chromium&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;auth.setup.ts&lt;/code&gt; to write the state file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;mkdir&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:fs/promises&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;authenticate&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/login&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;locator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;[name="user"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;demo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;locator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;[name="password"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;demo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Log in&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;heading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Dashboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}))&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toBeVisible&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;mkdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;playwright/.auth&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;recursive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;context&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;storageState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;playwright/.auth/user.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;fixtures.ts&lt;/code&gt; and &lt;code&gt;auth.spec.ts&lt;/code&gt;. Overriding Playwright’s &lt;code&gt;storageState&lt;/code&gt; fixture supplies the saved state when Playwright creates each test context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// fixtures.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;storageState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;playwright/.auth/user.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// auth.spec.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./fixtures&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;opens the authenticated dashboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/dashboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;heading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Dashboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}))&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toBeVisible&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;npx playwright test&lt;/code&gt;. Add &lt;code&gt;playwright/.auth/&lt;/code&gt; to &lt;code&gt;.gitignore&lt;/code&gt; because saved auth state can contain sensitive cookies. A shared login keeps setup fast, but tests that modify account data may need separate accounts to preserve  &lt;a href="https://momentic.ai/blog/session-management-and-isolation-for-reliable-tests" rel="noopener noreferrer"&gt;test isolation&lt;/a&gt; .&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixtures vs beforeEach
&lt;/h2&gt;

&lt;p&gt;Use a fixture when setup provides a value that tests request by name. Use &lt;code&gt;beforeEach&lt;/code&gt; when every test in a file needs the same simple setup. Both approaches can prepare a page, but a fixture keeps setup beside the value it supplies and can run cleanup after &lt;code&gt;use()&lt;/code&gt; returns.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;tests/fixture.spec.ts&lt;/code&gt;, &lt;code&gt;readyPage&lt;/code&gt; depends on Playwright’s built-in &lt;code&gt;page&lt;/code&gt; fixture. The test requests &lt;code&gt;readyPage&lt;/code&gt;, so Playwright navigates before running the test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;readyPage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;readyPage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://example.com/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fixture setup&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;readyPage&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;readyPage&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toHaveTitle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Example Domain&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;code&gt;tests/hook.spec.ts&lt;/code&gt;, the hook performs the same navigation before each test. No custom fixture is needed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;beforeEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://example.com/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hook setup&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toHaveTitle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Example Domain&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run both files with &lt;code&gt;npx playwright test tests/fixture.spec.ts tests/hook.spec.ts&lt;/code&gt;. Playwright closes the built-in &lt;code&gt;page&lt;/code&gt; after each test in either version. If your setup creates another resource, a fixture can release it after &lt;code&gt;await use(value)&lt;/code&gt;. Hook-based setup needs a corresponding &lt;code&gt;afterEach&lt;/code&gt; for that cleanup. For a single file that only needs navigation, &lt;code&gt;beforeEach&lt;/code&gt; remains the simpler choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overriding fixtures per project
&lt;/h2&gt;

&lt;p&gt;Project configuration can change a fixture option without duplicating the fixture implementation. The same &lt;code&gt;readyPage&lt;/code&gt; fixture below opens a different path for each project because it reads &lt;code&gt;startPath&lt;/code&gt; before passing the page to &lt;code&gt;use()&lt;/code&gt;. Playwright applies each project's &lt;code&gt;use&lt;/code&gt; values when it runs the test.&lt;/p&gt;

&lt;p&gt;Create &lt;code&gt;fixtures.ts&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;startPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Options&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;readyPage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;startPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;option&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}],&lt;/span&gt;
  &lt;span class="na"&gt;readyPage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;startPath&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;startPath&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;playwright.config.ts&lt;/code&gt;. Both projects use the same public site so the example runs without an application server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;defineConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Options&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./fixtures&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;defineConfig&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Options&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;projects&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;desktop&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;use&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;baseURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;startPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;viewport&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1280&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;720&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mobile&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;use&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;baseURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;startPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/?view=mobile&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;viewport&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;390&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;844&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;example.spec.ts&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./fixtures&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;opens the configured page&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;readyPage&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;readyPage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;locator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;h1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toHaveText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Example Domain&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it with these commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; @playwright/test
npx playwright &lt;span class="nb"&gt;install &lt;/span&gt;chromium
npx playwright &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For staging and production, you can set a different &lt;code&gt;baseURL&lt;/code&gt; in each project while keeping &lt;code&gt;readyPage&lt;/code&gt; unchanged. A project can override a declared fixture &lt;em&gt;option&lt;/em&gt; through &lt;code&gt;use&lt;/code&gt;, as &lt;code&gt;startPath&lt;/code&gt; does here. Replacing a fixture's setup function requires a separate extended &lt;code&gt;test&lt;/code&gt;, rather than a function assigned to the project's &lt;code&gt;use&lt;/code&gt; configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes with Playwright fixtures
&lt;/h2&gt;

&lt;p&gt;Playwright fixtures can make tests flaky when their scope or cleanup does not match the state they manage. The  &lt;a href="https://playwright.dev/docs/test-fixtures" rel="noopener noreferrer"&gt;fixture lifecycle&lt;/a&gt;  helps explain four common mistakes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Forgetting to request a fixture.&lt;/strong&gt; A normal custom fixture runs only when a test or another fixture names it as a dependency. Defining an &lt;code&gt;apiClient&lt;/code&gt; fixture does not initialize it for every test. Add &lt;code&gt;apiClient&lt;/code&gt; to the test argument’s destructured properties wherever the test needs it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keeping mutable state in a worker-scoped fixture.&lt;/strong&gt; Playwright reuses a worker fixture across tests in that worker. If one test changes a shared client’s headers or account state, a later test may inherit the change. Keep mutable test state in a test-scoped fixture, or reset shared state between tests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overusing &lt;code&gt;auto&lt;/code&gt;.&lt;/strong&gt; An auto fixture runs without appearing in the test’s arguments. Use it for work every test needs, such as collecting failure evidence. Otherwise, hidden setup makes a test’s dependencies harder to inspect and adds work to tests that do not need it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skipping asynchronous teardown.&lt;/strong&gt; A fixture must await &lt;code&gt;use(value)&lt;/code&gt; before it cleans up, and it must await asynchronous cleanup such as &lt;code&gt;client.close()&lt;/code&gt;. Without those awaits, a shared resource can close too early or remain open when the next test starts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When failures depend on test order or appear only in CI, check fixture scope and cleanup alongside the other causes in  &lt;a href="https://momentic.ai/blog/how-to-debug-and-fix-flaky-playwright-tests" rel="noopener noreferrer"&gt;this flaky-test debugging guide&lt;/a&gt; .&lt;/p&gt;

&lt;h2&gt;
  
  
  Where fixtures fit in a larger test strategy
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://playwright.dev/docs/test-fixtures" rel="noopener noreferrer"&gt;Playwright fixtures&lt;/a&gt;  give tests the setup they request and run teardown afterward. Test-scoped fixtures help isolate tests, while worker-scoped fixtures let tests share resources. Neither scope decides which product behavior deserves a test or whether a UI change calls for a test update.&lt;/p&gt;

&lt;p&gt;To extend a Playwright suite, use the  &lt;a href="https://momentic.ai/blog/playwright-locators-guide" rel="noopener noreferrer"&gt;Playwright locators guide&lt;/a&gt;  for selector choices and  &lt;a href="https://momentic.ai/blog/playwright-e2e-testing-best-practices" rel="noopener noreferrer"&gt;Playwright E2E testing best practices&lt;/a&gt;  for broader test design. As the product changes, you also need a way to maintain tests and distinguish regressions from test failures. Evaluate  &lt;a href="https://momentic.ai/docs" rel="noopener noreferrer"&gt;Momentic&lt;/a&gt;  against those requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can a custom fixture override the built-in &lt;code&gt;page&lt;/code&gt; fixture?
&lt;/h3&gt;

&lt;p&gt;Yes. Define page in test.extend and use the original page as its dependency. Your replacement can configure the page before passing it to use().&lt;/p&gt;

&lt;h3&gt;
  
  
  Can fixtures be async?
&lt;/h3&gt;

&lt;p&gt;Yes. An async fixture can await setup, pass its value to use(), and await cleanup after use() returns.&lt;/p&gt;

&lt;h3&gt;
  
  
  How many fixtures can one test use?
&lt;/h3&gt;

&lt;p&gt;Playwright documents no fixed limit. Request the fixtures the test needs in its argument object. Playwright also resolves fixtures that those fixtures depend on.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do fixtures work with &lt;code&gt;test.describe.parallel&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;Yes. Test-scoped fixtures run for each test. Worker-scoped fixtures run once per worker, and parallel workers do not share their fixture instances.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens when merged extended tests define the same fixture name?
&lt;/h3&gt;

&lt;p&gt;The definitions cannot remain independent under one name. Give the fixtures distinct names, or combine their behavior in one fixture before merging the tests.&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Mobile MCP servers: set up Appium MCP, Maestro MCP and mobile-mcp</title>
      <dc:creator>Wei-Wei Wu</dc:creator>
      <pubDate>Tue, 03 Nov 2026 16:00:00 +0000</pubDate>
      <link>https://dev.to/wuweiweiwu/mobile-mcp-servers-set-up-appium-mcp-maestro-mcp-and-mobile-mcp-40kj</link>
      <guid>https://dev.to/wuweiweiwu/mobile-mcp-servers-set-up-appium-mcp-maestro-mcp-and-mobile-mcp-40kj</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://momentic.ai/blog/mobile-mcp-server-setup" rel="noopener noreferrer"&gt;Momentic blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;mobile-mcp&lt;/strong&gt; lets a coding agent inspect and control a mobile app during a live session. Reach for it when you need to explore the UI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Appium MCP&lt;/strong&gt; gives the agent access through an Appium session. Reach for it when your mobile setup already uses Appium drivers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maestro MCP&lt;/strong&gt; lets the agent work with Maestro’s mobile testing tools. Reach for it when you already use Maestro flows.&lt;/li&gt;
&lt;li&gt;All three can help an agent inspect and drive an app, but an MCP session alone does not leave behind a test that runs in CI.&lt;/li&gt;
&lt;li&gt;For a versioned test, use Momentic’s MCP server to write and run YAML tests. Install the mobile skills with &lt;code&gt;npx momentic-mobile skills --yes&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Appium MCP, Maestro MCP and mobile-mcp compared
&lt;/h2&gt;

&lt;p&gt;All three run as local stdio servers that your coding agent starts with one command. They differ in what they drive and what they leave behind.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Server&lt;/th&gt;
&lt;th&gt;Install&lt;/th&gt;
&lt;th&gt;Platforms and targets&lt;/th&gt;
&lt;th&gt;What the agent works with&lt;/th&gt;
&lt;th&gt;Leaves a test behind?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/mobile-next/mobile-mcp" rel="noopener noreferrer"&gt;mobile-mcp&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;npx -y @mobilenext/mobile-mcp@latest&lt;/td&gt;
&lt;td&gt;iOS and Android: simulators, emulators and real devices&lt;/td&gt;
&lt;td&gt;The native accessibility tree, with screenshots and coordinates as a fallback&lt;/td&gt;
&lt;td&gt;No. The session lives in the agent's conversation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/appium/appium-mcp" rel="noopener noreferrer"&gt;Appium MCP&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;npx -y appium-mcp@latest&lt;/td&gt;
&lt;td&gt;Android (UiAutomator2) and iOS (XCUITest): simulators, emulators and real devices&lt;/td&gt;
&lt;td&gt;An Appium session: find elements, tap, type, gestures, screenshots&lt;/td&gt;
&lt;td&gt;It can generate Java/TestNG test code from a description&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://docs.maestro.dev/getting-started/maestro-mcp" rel="noopener noreferrer"&gt;Maestro MCP&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;maestro mcp (needs the Maestro CLI)&lt;/td&gt;
&lt;td&gt;iOS and Android apps, plus web&lt;/td&gt;
&lt;td&gt;Maestro commands, so the agent can write, run and debug flows&lt;/td&gt;
&lt;td&gt;Yes, when the agent saves the flow as a YAML file&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Pick the one that matches the tooling you already run. If your team has Appium capabilities and drivers set up, Appium MCP reuses them. If you write Maestro flows, Maestro MCP lets the agent write more of them. If you want an agent to poke at an app with no framework at all, mobile-mcp has the least setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up mobile-mcp
&lt;/h2&gt;

&lt;p&gt;Boot an iOS simulator (&lt;code&gt;xcrun simctl boot "iPhone 16"&lt;/code&gt;) or start an Android emulator first. The project's installer finds the MCP clients on your machine and configures them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx @mobilenext/mobile-mcp@latest &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To configure each client by hand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Claude Code&lt;/span&gt;
claude mcp add mobile-mcp &lt;span class="nt"&gt;--&lt;/span&gt; npx &lt;span class="nt"&gt;-y&lt;/span&gt; @mobilenext/mobile-mcp@latest

&lt;span class="c"&gt;# Codex&lt;/span&gt;
codex mcp add mobile-mcp npx &lt;span class="s2"&gt;"@mobilenext/mobile-mcp@latest"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Cursor, add the server to &lt;code&gt;~/.cursor/mcp.json&lt;/code&gt; or a project-level &lt;code&gt;.cursor/mcp.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"mobile-mcp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@mobilenext/mobile-mcp@latest"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;mobile-mcp drives the app from the native accessibility tree first, so the agent reads element labels instead of spending image tokens on screenshots. It falls back to a screenshot and coordinate taps when an element has no accessible label. It also installs, launches and terminates apps, opens deep links and records the screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up Appium MCP
&lt;/h2&gt;

&lt;p&gt;Appium MCP bundles the UiAutomator2 and XCUITest drivers for local sessions. You still need the platform toolchains: &lt;code&gt;ANDROID_HOME&lt;/code&gt;, Java and the Android SDK tools for Android, and Xcode with an installed simulator for iOS (macOS only).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Claude Code&lt;/span&gt;
claude mcp add appium-mcp &lt;span class="nt"&gt;--&lt;/span&gt; npx &lt;span class="nt"&gt;-y&lt;/span&gt; appium-mcp@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Cursor, and for other clients that take a JSON config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"appium-mcp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"stdio"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"appium-mcp@latest"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"ANDROID_HOME"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/path/to/android/sdk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"CAPABILITIES_CONFIG"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/path/to/your/capabilities.json"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Codex, the same server goes in &lt;code&gt;~/.codex/config.toml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mcp_servers&lt;/span&gt;&lt;span class="k"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appium-mcp&lt;/span&gt;&lt;span class="k"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"npx"&lt;/span&gt;
&lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"appium-mcp@latest"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ANDROID_HOME&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"/path/to/android/sdk"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;CAPABILITIES_CONFIG&lt;/code&gt; points at a JSON file of Appium capabilities, such as &lt;code&gt;platformName&lt;/code&gt;, &lt;code&gt;appium:deviceName&lt;/code&gt; and &lt;code&gt;appium:app&lt;/code&gt;. The agent opens a session with &lt;code&gt;appium_session_management&lt;/code&gt;, then uses tools such as &lt;code&gt;appium_find_element&lt;/code&gt;, &lt;code&gt;appium_gesture&lt;/code&gt; and &lt;code&gt;appium_set_value&lt;/code&gt;. For a device farm or CI, pass a &lt;code&gt;remoteServerUrl&lt;/code&gt; and explicit capabilities when the session is created instead of using the local drivers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up Maestro MCP
&lt;/h2&gt;

&lt;p&gt;Install the  &lt;a href="https://docs.maestro.dev/getting-started/installing-maestro" rel="noopener noreferrer"&gt;Maestro CLI&lt;/a&gt;  first. The MCP server is a subcommand of it, so there is no separate package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Claude Code&lt;/span&gt;
claude mcp add maestro &lt;span class="nt"&gt;--&lt;/span&gt; maestro mcp

&lt;span class="c"&gt;# Codex&lt;/span&gt;
codex mcp add maestro &lt;span class="nt"&gt;--&lt;/span&gt; maestro mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or add it to &lt;code&gt;~/.codex/config.toml&lt;/code&gt; by hand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mcp_servers&lt;/span&gt;&lt;span class="k"&gt;.&lt;/span&gt;&lt;span class="n"&gt;maestro&lt;/span&gt;&lt;span class="k"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"maestro"&lt;/span&gt;
&lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"mcp"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Cursor, merge this into &lt;code&gt;~/.cursor/mcp.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"maestro"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"maestro"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"mcp"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This assumes &lt;code&gt;maestro&lt;/code&gt; is on your &lt;code&gt;PATH&lt;/code&gt;. If the client starts from a minimal shell, use the full path from &lt;code&gt;which maestro&lt;/code&gt;. Maestro MCP is the only one of the three that writes into a test format you already run: when the agent saves its work as a flow file, &lt;code&gt;maestro test&lt;/code&gt; can run it again in CI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where an MCP session stops and a repeatable test starts
&lt;/h2&gt;

&lt;p&gt;A live MCP session can help a coding agent inspect a mobile app and try a user journey, but the session alone does not give CI a test to run. The agent’s observations and next steps remain in its conversation unless the agent writes them into a file. A PR cannot review or rerun a conversation as a test.&lt;/p&gt;

&lt;p&gt;For example, an agent might open an order screen and confirm that the latest order appears. To check that behavior after every change, you need a saved test with an assertion and a repeatable run command. Appium and Maestro can support persistent tests, but access through their MCP servers does not, by itself, save the agent’s exploration as one.&lt;/p&gt;

&lt;p&gt;Momentic’s  &lt;a href="https://momentic.ai/blog/how-to-set-up-momentic-mcp-server" rel="noopener noreferrer"&gt;MCP server&lt;/a&gt;  gives a coding agent a way to write, run, and fix tests while keeping the test definition as YAML in your repository. Install the mobile skills and the MCP server for your agent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx momentic-mobile skills &lt;span class="nt"&gt;--yes&lt;/span&gt;
npx momentic-mobile install-mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command equips the agent to work on mobile tests. The agent still needs to turn the behavior it explored into a YAML test and run it. Once you commit that file, reviewers can diff the test in a PR, and CI can invoke it without asking the agent to explore the app again. The MCP server handles the agent interaction. The test file and CI invocation make the check repeatable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the resulting test in CI
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;npx momentic-mobile skills --yes&lt;/code&gt; in your project, then use your coding agent and the Momentic MCP server to write and run the mobile test. Review the resulting YAML test and commit it to your repository. CI needs that file, not the agent’s chat history.&lt;/p&gt;

&lt;p&gt;Add a pull-request job that builds the app and runs the committed test with the Momentic CLI. Give the job the credentials and simulator or emulator access it needs, then make the job a required status check so a failed test blocks the merge. The CI job runs the committed tests with &lt;code&gt;npx momentic-mobile run --upload-results&lt;/code&gt;, with &lt;code&gt;MOMENTIC_API_KEY&lt;/code&gt; set as a CI secret. See the  &lt;a href="https://momentic.ai/docs/cli-reference/momentic-mobile/commands/run" rel="noopener noreferrer"&gt;CLI reference&lt;/a&gt;  for device and sharding flags.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to set up the Momentic MCP server&lt;/li&gt;
&lt;li&gt;Best MCP servers for testing&lt;/li&gt;
&lt;li&gt;Playwright MCP vs. a testing MCP server&lt;/li&gt;
&lt;li&gt;Testing mobile apps in Cursor&lt;/li&gt;
&lt;li&gt;Appium vs. Maestro vs. AI testing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can these servers use physical devices?
&lt;/h3&gt;

&lt;p&gt;Appium can drive physical iOS and Android devices when you configure the appropriate drivers and devices. Maestro supports physical devices as well as simulators and emulators. Check the mobile-mcp project’s README before assuming its server supports your device setup. Momentic’s mobile testing uses simulators and emulators, not physical devices.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can one MCP configuration drive both iOS and Android?
&lt;/h3&gt;

&lt;p&gt;You can register one server, but that does not make both platforms ready to use. You still need the devices and platform-specific tooling that the server requires. With Appium, you also need the appropriate driver for each platform.&lt;/p&gt;

&lt;h3&gt;
  
  
  How is Momentic’s MCP server different?
&lt;/h3&gt;

&lt;p&gt;The device-control servers let an agent interact with a running app. Momentic’s MCP server lets an agent write, run, and fix end-to-end tests that remain as YAML files in your repository. The separate npx momentic-mobile skills --yes command installs mobile testing skills. Check the &lt;a href="https://momentic.ai/docs" rel="noopener noreferrer"&gt;Momentic documentation&lt;/a&gt; for the current setup.&lt;/p&gt;

&lt;h3&gt;
  
  
  Must I abandon an existing Appium or Maestro suite?
&lt;/h3&gt;

&lt;p&gt;No. You can keep that suite in CI while adding Momentic tests for behavior you want to cover separately. Do not assume existing test files will run unchanged in Momentic.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>mcp</category>
      <category>mobile</category>
      <category>ai</category>
    </item>
    <item>
      <title>Migrating from Selenium to Playwright: A Step-by-Step Guide</title>
      <dc:creator>Wei-Wei Wu</dc:creator>
      <pubDate>Sat, 31 Oct 2026 09:54:45 +0000</pubDate>
      <link>https://dev.to/wuweiweiwu/migrating-from-selenium-to-playwright-a-step-by-step-guide-2pkj</link>
      <guid>https://dev.to/wuweiweiwu/migrating-from-selenium-to-playwright-a-step-by-step-guide-2pkj</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://momentic.ai/blog/migrate-selenium-playwright" rel="noopener noreferrer"&gt;Momentic blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Migrating from Selenium to Playwright takes 11 steps: audit the framework, pick a language, install Playwright, convert tests, replace wait strategies, rebuild page objects, simplify parallel runs, update CI/CD, migrate gradually, train the team, then adopt advanced features. To skip the rebuild, teams move straight to Momentic, where tests are plain-English YAML that coding agents write and maintain.&lt;/p&gt;

&lt;p&gt;Tired of the constant workarounds needed to make &lt;a href="https://momentic.ai/blog/selenium-future-relevance" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; work with modern web apps?&lt;/p&gt;

&lt;p&gt;Thinking about all the hours the team could save* if only Selenium did X, Y, or Z better*?&lt;/p&gt;

&lt;p&gt;Congratulations – you’ve reached the point where many engineering teams start to consider migrating from Selenium to Playwright. Here’s what you need to do, the challenges you should anticipate, and some alternative software suggestions.&lt;/p&gt;

&lt;p&gt;One more path exists. Teams that move to Momentic skip the rebuild: tests are version-controlled YAML in your own repository, they self-heal when the UI changes, and Mo, an autonomous AI coworker, explores the app and reports bugs beyond your migrated coverage. The last section covers that option.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Migrate from Selenium to Playwright?
&lt;/h2&gt;

&lt;p&gt;Teams migrate because Playwright executes tests faster, waits for elements automatically, handles modern web apps, runs tests in parallel natively, and needs fewer third-party integrations than Selenium.&lt;/p&gt;

&lt;p&gt;In the case of &lt;a href="https://momentic.ai/blog/playwright-vs-selenium" rel="noopener noreferrer"&gt;Playwright and Selenium&lt;/a&gt;, it’s pretty clear that the efficiency gains you’ll get from Playwright far outweigh that risk. Here’s why:&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright Executes Tests Faster
&lt;/h3&gt;

&lt;p&gt;Playwright runs tests faster thanks to its direct browser communication over WebSockets (no WebDriver layer).&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright Offers Built-In Auto-Waiting
&lt;/h3&gt;

&lt;p&gt;Playwright automatically waits for elements to be actionable before testing. This means fewer flaky tests and less time spent coding complex workarounds – especially if you’re testing SPAs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright Handles Modern Apps Better
&lt;/h3&gt;

&lt;p&gt;Selenium was released in 2004, Playwright in 2020. This means that Playwright is, naturally, better designed for &lt;a href="https://momentic.ai/blog/browser-testing-tools" rel="noopener noreferrer"&gt;modern testing needs&lt;/a&gt; – as well as SPAs, Playwright deals with shadow DOMs, network interception, and multiple browser contexts better than Selenium.&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright Offers Native Parallel Support
&lt;/h3&gt;

&lt;p&gt;Playwright supports parallel testing out of the box. This offers a significantly easier and more efficient way of running parallel tests than Selenium, which relies on external tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  Playwright Requires Fewer Third-Party Integrations
&lt;/h3&gt;

&lt;p&gt;Playwright has a built-in test runner and reporting features, so you don’t need to rely on third-party tools for test retries, tracing, screenshots, or HTML reports.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Migrate from Selenium to Playwright In 11 Steps
&lt;/h2&gt;

&lt;p&gt;The migration takes 11 steps, from auditing your Selenium framework to adopting Playwright's advanced features, and most teams run both frameworks in parallel during the switch. The exact process varies between teams based on Selenium setup, and it requires technical know-how.&lt;/p&gt;

&lt;p&gt;If you don’t have this expertise in-house, find a consultant who can advise you on your specific circumstances. A good one is worth the investment.&lt;/p&gt;

&lt;p&gt;Still, it can be pretty useful to get an overview of what you need to do in a Selenium to Playwright migration, and when you need to do it. Here’s an at-a-glance guide for reference:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Audit your Selenium framework&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Boring but necessary&lt;/li&gt;
&lt;li&gt;Review test coverage and other key metrics – where could Playwright improve things?&lt;/li&gt;
&lt;li&gt;Note key requirements for migration – what resources will you need, and when will you need them?&lt;/li&gt;
&lt;li&gt;Discuss process retention – which workflows will you keep? Which will no longer work?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Choose your Playwright language&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Playwright supports JavaScript/Typescript, Python, .NET, and Java&lt;/li&gt;
&lt;li&gt;If you’ve chosen it for language continuity, carry on&lt;/li&gt;
&lt;li&gt;However, you could use this opportunity to migrate from Java to TypeScript for better test maintainability – lots of teams do this&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Install Playwright in your project&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This one’s self explanatory&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Convert basic tests&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start simple, then work your way through your test suite&lt;/li&gt;
&lt;li&gt;What to be aware of: no WebDriver setup, built-in assertions, no explicit waits&lt;/li&gt;
&lt;li&gt;If you’ve done it right, tests will become shorter and more readable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. Replace wait strategies&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Playwright automatically waits for element visibility, stability, enabled state, and network idle&lt;/li&gt;
&lt;li&gt;This significantly reduces flakiness&lt;/li&gt;
&lt;li&gt;Make sure you update migrated tests to benefit from this&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;6. Rebuild Page Objects&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you migrate Selenium to Playwright, your POM becomes cleaner, more asynchronous, and less dependent on driver injection&lt;/li&gt;
&lt;li&gt;Ensure test scripts are set up to enable this&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;7. Simplify parallel execution&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bid farewell to Selenium Grid and complex Docker setups&lt;/li&gt;
&lt;li&gt;Playwright offers native parallelization&lt;/li&gt;
&lt;li&gt;To maximize the benefits, simplify your execution strategy and remove unnecessary infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;8. Update CI/CD&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remove WebDriver setup, driver binaries, and Grid services&lt;/li&gt;
&lt;li&gt;Ensure that your CI is updated to store the test artifacts Playwright generates (HTML reports, trace viewer, screenshots on failure)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;9. Migrate gradually&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do not try to do everything at once&lt;/li&gt;
&lt;li&gt;Create a priority list for rewriting and migration&lt;/li&gt;
&lt;li&gt;High-priority, high-value tests go first&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;10. Train your team&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make time for proper training – this reduces the likelihood of bad habits forming, and ensures you maximize efficiency gains&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Focus training on key Selenium/Playwright differences, including:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Asynch waits&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Locators&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fixtures&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Debugging with Trace Viewer&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;11. Start using Playwright’s advanced features&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After migration and training, the efficiency gains really start&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Take a look at:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Network interception&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multiple browser contexts&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Built-in tracing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;API testing&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Are The Challenges of Migrating from Selenium to Playwright?
&lt;/h2&gt;

&lt;p&gt;The two challenges that stall most migrations are user buy-in and the temporary dual maintenance of both frameworks. Migrating from Selenium can also feel intimidating: for many teams, it is the only test automation tool they have ever used.&lt;/p&gt;

&lt;p&gt;The key is anticipating these challenges and planning how to address them in advance. Consider the following:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. User Buy-In
&lt;/h3&gt;

&lt;p&gt;Migrating from Selenium to Playwright will only work if your users buy into the change, and embrace it. However, people are naturally change-resistant. This creates a dilemma.&lt;/p&gt;

&lt;p&gt;(This doesn’t mean that your team are luddites – just that they’re following a natural ‘if it’s safe, why move’ evolutionary instinct). To alleviate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Communicating the benefits early. Chances are, there’s plenty that your team doesn’t love about Selenium – show them how Playwright fixes that&lt;/li&gt;
&lt;li&gt;Staggering training – a huge info-dump will make things seem insurmountable. Delivering training in bite-sized pieces is more manageable&lt;/li&gt;
&lt;li&gt;Encouragement – there may be setbacks, and things may operate less efficiently as your team gets the hang of a new tool. Reward your team’s commitment and perseverance, show recognition for their efforts, whatever works in your organization&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Temporary Dual Maintenance
&lt;/h3&gt;

&lt;p&gt;You won’t be able to migrate all your tests at once – which means you’ll need to maintain both Selenium and Playwright as you complete the switch. If you don’t organize this properly, things could get pretty chaotic. Make sure to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Be super clear about which tests are migrated, and when they will be migrated&lt;/li&gt;
&lt;li&gt;Check in regularly with stakeholders to avoid misunderstandings&lt;/li&gt;
&lt;li&gt;Run a tight ship, administratively speaking – update key documentation as you go, and maintain a single source of truth throughout the project&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Which tools convert Selenium tests to Playwright?
&lt;/h2&gt;

&lt;p&gt;No tool converts a Selenium suite to Playwright and gives you tests you can trust without a review. The options are a manual rewrite, a coding agent that ports one file at a time, or a move to a test format that an agent writes from the spec instead of from the old code.&lt;/p&gt;

&lt;p&gt;Here is what each option does and where it stops:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Playwright codegen records a new test from a browser session. It does not read Selenium code, so it replaces a Selenium test instead of converting it. Use it when the old test is short and the flow is easy to click through.&lt;/li&gt;
&lt;li&gt;A coding agent (Claude Code, Cursor, Codex, Devin) converts Selenium Java, Python or C# to Playwright TypeScript. It handles the mechanical part well: driver setup, locators, waits and assertions. It still needs a run and a review for every file, because the agent cannot see the app when it writes the code.&lt;/li&gt;
&lt;li&gt;Community scripts on GitHub rewrite the driver API calls with regular expressions. They cover a small part of the WebDriver API, and they do not touch page objects, waits or test data. Treat their output as a starting point, not as a converted test.&lt;/li&gt;
&lt;li&gt;Momentic ships no automatic converter from Selenium. Instead, a coding agent with the Momentic MCP server or the coding agent skills writes the YAML test from the existing spec, then runs it and reads the result.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Momentic path is documented in &lt;a href="https://momentic.ai/docs/get-started/test-portability" rel="noopener noreferrer"&gt;Test portability&lt;/a&gt;. Keep the Selenium suite running, port the highest-value flows first, and delete an old spec only after its replacement passes a few consecutive runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  What breaks when you move Selenium tests to Playwright?
&lt;/h2&gt;

&lt;p&gt;Explicit waits, driver management, Selenium Grid and driver-injected page objects break first, because Playwright removes the layer they depend on. Locators, iframes and multi-window flows need a rewrite, not a search and replace.&lt;/p&gt;

&lt;p&gt;Plan for these six breakages before you convert the first file:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WebDriverWait and implicit waits. Playwright waits for an element to be attached, visible, stable and enabled before it acts. A ported wait either does nothing or hides a real bug. Delete the wait and let the locator action or the web-first assertion (expect(locator).toBeVisible()) do the work.&lt;/li&gt;
&lt;li&gt;Driver binaries and WebDriverManager. Playwright installs its own browsers with npx playwright install. Every driver download step in CI goes away.&lt;/li&gt;
&lt;li&gt;Selenium Grid and remote WebDriver URLs. Playwright runs tests in parallel with workers on one machine, and across machines with --shard. The Grid hub, the nodes and the Docker files that ran them are no longer needed.&lt;/li&gt;
&lt;li&gt;Page objects that receive a WebDriver in the constructor. Playwright page objects receive a Page, and every method becomes async. A Java suite with synchronous chains needs await on every line in TypeScript.&lt;/li&gt;
&lt;li&gt;switchTo().frame() and switchTo().window(). Playwright uses page.frameLocator() for iframes and a new Page object for each tab or popup. Alerts move from switchTo().alert() to page.on('dialog').&lt;/li&gt;
&lt;li&gt;Cloud grid configuration for BrowserStack or Sauce Labs. Both vendors run Playwright, but with a different connection method (a CDP endpoint, not a WebDriver capability), so the config file changes even when the vendor stays.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Locators do not break, but they cost you the most time. A Selenium suite full of absolute XPath keeps working in Playwright and stays as brittle as before. Convert to getByRole, getByLabel and getByTestId while you port, or the migration moves the maintenance problem without fixing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can a coding agent convert a Selenium suite?
&lt;/h2&gt;

&lt;p&gt;Yes. A coding agent converts Selenium code to Playwright faster than an engineer, and the same agent can write the flow as a Momentic YAML test instead. The difference is what the agent does after it writes the file.&lt;/p&gt;

&lt;p&gt;For a Selenium to Playwright port, give the agent one test file, the page objects it imports, and a prompt like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Convert this Selenium Java test to Playwright TypeScript.
Use getByRole, getByLabel or getByTestId locators. Remove every
explicit wait and use web-first assertions. Keep the test name
and the assertions. Run `npx playwright test &amp;lt;file&amp;gt;` and fix
failures until it passes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent produces a file that compiles. It does not know whether the locator matches the real page until the test runs, so the loop that matters is run, read the failure, correct the code. In practice an engineer still reviews every converted file, because the agent will invent a test ID or drop an assertion it could not map.&lt;/p&gt;

&lt;p&gt;With Momentic the agent skips the Playwright code and writes the test as steps in plain English:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Test&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;checkoutShowsConfirmation&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://shop.example.com"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;WebDriverWait&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Duration&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofSeconds&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;until&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ExpectedConditions&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;elementToBeClickable&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;By&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"checkout"&lt;/span&gt;&lt;span class="o"&gt;)))&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;click&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;findElement&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;By&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt;&lt;span class="o"&gt;)).&lt;/span&gt;&lt;span class="na"&gt;sendKeys&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"jeff@example.com"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;findElement&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;By&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;cssSelector&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"button[type=submit]"&lt;/span&gt;&lt;span class="o"&gt;)).&lt;/span&gt;&lt;span class="na"&gt;click&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;findElement&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;By&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"confirmation"&lt;/span&gt;&lt;span class="o"&gt;)).&lt;/span&gt;&lt;span class="na"&gt;isDisplayed&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;fileType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;momentic/test/v2&lt;/span&gt;
&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;checkout-shows-confirmation&lt;/span&gt;
&lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://shop.example.com&lt;/span&gt;
&lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;click&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Checkout&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jeff@example.com&lt;/span&gt;
      &lt;span class="na"&gt;into&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Email input&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;click&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Place order&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assert&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;An order confirmation is visible&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The YAML file lives in your repository next to the code. The agent writes it with the &lt;a href="https://momentic.ai/docs/coding-agents/mcp-server" rel="noopener noreferrer"&gt;Momentic MCP server&lt;/a&gt; or the &lt;a href="https://momentic.ai/docs/coding-agents/skills" rel="noopener noreferrer"&gt;coding agent skills&lt;/a&gt;, runs it with npx momentic run, and reads the step that failed, the screenshot and the trace. When the checkout button is renamed later, Momentic re-resolves the element from the step description instead of failing on a selector.&lt;/p&gt;

&lt;h2&gt;
  
  
  How long does a Selenium to Playwright migration take for 500 tests?
&lt;/h2&gt;

&lt;p&gt;Plan 3 to 6 months of one engineer for a manual rewrite of 500 tests, 6 to 10 weeks with a coding agent doing the conversion and an engineer reviewing, and 4 to 8 weeks for an agent-assisted move to Momentic. These are planning figures. Convert your first 20 tests, measure the hours per test, and rescale before you commit a date.&lt;/p&gt;

&lt;p&gt;The figures come from a per-test estimate, and the per-test cost is what changes between the three paths:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Path&lt;/th&gt;
&lt;th&gt;Hours per test&lt;/th&gt;
&lt;th&gt;500 tests&lt;/th&gt;
&lt;th&gt;What the engineer does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Manual rewrite in Playwright&lt;/td&gt;
&lt;td&gt;1 to 3&lt;/td&gt;
&lt;td&gt;500 to 1,500 hours&lt;/td&gt;
&lt;td&gt;Reads the Selenium test, writes the Playwright test, rebuilds the page object, debugs the run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Coding agent writes Playwright, engineer reviews&lt;/td&gt;
&lt;td&gt;0.5 to 1&lt;/td&gt;
&lt;td&gt;250 to 500 hours&lt;/td&gt;
&lt;td&gt;Reviews the diff, runs the test, corrects locators the agent guessed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Coding agent writes Momentic YAML, engineer reviews&lt;/td&gt;
&lt;td&gt;0.3 to 0.6&lt;/td&gt;
&lt;td&gt;150 to 300 hours&lt;/td&gt;
&lt;td&gt;Reviews the steps against the spec, runs the test, accepts the result&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two costs are not in the table and apply to both Playwright paths: the page objects, which you rebuild once per page and not once per test, and the dual maintenance period, in which every UI change costs a fix in Selenium and a fix in Playwright. With Momentic the second cost falls away for the ported tests, because the test updates when the UI changes and the change is a diff in your repository.&lt;/p&gt;

&lt;p&gt;Cost follows the same shape. At a loaded engineer cost of $100 per hour, the manual rewrite of 500 tests costs $50,000 to $150,000 in engineering time before the suite runs in CI. The agent-assisted paths cost $15,000 to $50,000 in review time plus the tooling. Put your own rate and your measured hours per test in the same formula.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do Selenium Grid parallel runs map to Playwright workers in CI?
&lt;/h2&gt;

&lt;p&gt;A Grid node becomes a Playwright worker, and a Grid with several machines becomes a sharded run. Set workers in playwright.config.ts for one machine, and pass --shard=1/4 on four CI jobs to split the suite across machines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# .github/workflows/e2e.yml&lt;/span&gt;
&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;e2e&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;matrix&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;shard&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;2&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;3&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;4&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx playwright install --with-deps&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx playwright test --shard=${{ matrix.shard }}/4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three rules keep the mapping honest. Tests that shared state on the Grid, such as one login account, fail under workers because each worker runs in its own browser context. Playwright reports arrive per shard, so merge them with npx playwright merge-reports or upload each blob as an artifact. And the retry count in playwright.config.ts replaces the rerun-failed-tests plugin you had in Selenium.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is a Selenium to Playwright migration worth it in 2026?
&lt;/h2&gt;

&lt;p&gt;A Selenium to Playwright migration is worth it in 2026 when the suite is under about 300 tests, the team already writes TypeScript, and Selenium Grid costs more than an engineer-week per quarter to run. Above that size, or when maintenance hours are the real cost, the port only moves the problem, and a move to an agent-maintained format pays back sooner.&lt;/p&gt;

&lt;p&gt;Use this table to make the call. Each row is one input that changes the answer; the last column gives the path that wins on that input alone.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Migrate to Playwright&lt;/th&gt;
&lt;th&gt;Stay on Selenium&lt;/th&gt;
&lt;th&gt;Move to Momentic&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Suite size&lt;/td&gt;
&lt;td&gt;Under 300 tests: a port fits in one quarter&lt;/td&gt;
&lt;td&gt;Over 1,000 tests and stable: the rewrite cost is not paid back&lt;/td&gt;
&lt;td&gt;Any size: the agent writes tests from the spec, not from the old code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Java or TypeScript&lt;/td&gt;
&lt;td&gt;TypeScript team: Playwright is the native fit&lt;/td&gt;
&lt;td&gt;Java team with no plan to change: Selenium keeps the language&lt;/td&gt;
&lt;td&gt;Either: the test is YAML, and the agent works in both repos&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Grid cost&lt;/td&gt;
&lt;td&gt;You run your own Grid: Playwright workers and --shard remove the hub and nodes&lt;/td&gt;
&lt;td&gt;You already pay a cloud grid that runs Selenium well&lt;/td&gt;
&lt;td&gt;Momentic runs the browsers, so the Grid line item goes away&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Maintenance hours&lt;/td&gt;
&lt;td&gt;Under 10 hours a week: auto-waiting cuts the flaky share&lt;/td&gt;
&lt;td&gt;Under 5 hours a week: no reason to move&lt;/td&gt;
&lt;td&gt;Over 10 hours a week: tests re-resolve elements when the UI changes, so the hours drop&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Add up the rows. Two or more rows in the Playwright column make the port worth it. Two or more rows in the Momentic column mean the port is a detour: you pay for a rewrite and keep the maintenance bill.&lt;/p&gt;

&lt;p&gt;Yes for speed, no for maintenance. Software testing is faster, simpler, and easier to scale with Playwright, but you still own a code-based suite. If you plan your migration properly, you are likely to start realizing those efficiency gains relatively soon after implementing.&lt;/p&gt;

&lt;p&gt;On the other hand, Playwright is no longer the* creme de la creme *of software testing tools. You’re still anchored to writing tests in code, and auto-waits don’t solve your ongoing test maintenance burden. If you’re looking to shift left and up your release cadence (and in this environment, you need to), Playwright will only get you halfway there.&lt;/p&gt;

&lt;p&gt;Momentic removes the two costs that Playwright keeps: writing the test in code, and fixing it when the UI changes. It does this with functionality that Playwright does not offer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Natural language test creation:&lt;/strong&gt; create tests in plain English – it takes seconds, and makes it much easier for your engineers to test as they go and avoid huge find-and-fix bottlenecks just before code is shipped&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Version-controlled YAML:&lt;/strong&gt; tests live in your own repository as plain English, so engineers and coding agents can read, diff, and maintain them like source code&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Intent-based locators:&lt;/strong&gt; these update your test when the UI changes – &lt;a href="https://momentic.ai/blog/self-healing-test-automation-guide" rel="noopener noreferrer"&gt;tests self-heal&lt;/a&gt;, minimizing your test maintenance burden and freeing up engineering hours for other, more valuable tasks&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI agents:&lt;/strong&gt; Mo, your autonomous AI coworker, explores your app, evaluates critical user flows, generates new tests, and reports the bugs it finds. Routine maintenance runs in the background&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you migrate from Selenium to Playwright now, chances are you’ll need to migrate again in a couple of years when you realize that AI offers steeper efficiency gains.&lt;/p&gt;

&lt;p&gt;Why waste effort migrating to a &lt;a href="https://momentic.ai/blog/playwright-alternatives" rel="noopener noreferrer"&gt;system that’s on its way out&lt;/a&gt;? Migrate straight from Selenium to an AI-native testing tool to really see the difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  Migrate to Momentic
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;We went from 1-2 months for 80% user flow coverage to 1-2 days.&lt;/p&gt;

&lt;p&gt;— Aditya Advani, Best Parents&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://momentic.ai/" rel="noopener noreferrer"&gt;Momentic&lt;/a&gt; is an AI testing solution that’s designed to be intelligent, intuitive, and fast. Implement on Day 1, test on Day 1.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://momentic.ai/customers/best-parents" rel="noopener noreferrer"&gt;Here’s how Best Parents reached 80% user flow coverage&lt;/a&gt; in just one day after implementing Momentic – &lt;em&gt;with tests written in plain English&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Want to join them? &lt;a href="https://momentic.ai/sales" rel="noopener noreferrer"&gt;Talk to our engineering team today&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How do I migrate a Selenium suite to Playwright?
&lt;/h3&gt;

&lt;p&gt;Audit your Selenium framework, choose a language, install Playwright, convert basic tests, replace wait strategies, rebuild page objects, simplify parallel execution, update CI/CD, migrate gradually, train your team, then adopt advanced features like tracing and network interception.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is there a tool that converts Selenium tests to Playwright?
&lt;/h3&gt;

&lt;p&gt;No tool reliably converts Selenium tests to Playwright, so teams rewrite them by hand or have a coding agent port them. Another path is Momentic, where tests are plain-English YAML that self-heal when the UI changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  What breaks when you move Selenium tests to Playwright?
&lt;/h3&gt;

&lt;p&gt;Explicit waits break because Playwright auto-waits for actionable elements. WebDriver setup and Selenium Grid are no longer needed. Page objects must be rebuilt for async locators, and CI must store Playwright's trace and screenshot artifacts.&lt;/p&gt;

&lt;h3&gt;
  
  
  How long does a Selenium to Playwright migration take for 500 tests?
&lt;/h3&gt;

&lt;p&gt;Plan 3 to 6 months of one engineer for a manual rewrite of 500 tests, 6 to 10 weeks with a coding agent converting and an engineer reviewing, and 4 to 8 weeks for an agent-assisted move to Momentic. Convert 20 tests first and rescale from the measured hours per test.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is a Selenium to Playwright migration worth it in 2026?
&lt;/h3&gt;

&lt;p&gt;Yes when the suite is under about 300 tests, the team writes TypeScript, and you run your own Selenium Grid. No when maintenance hours are the main cost: the port keeps a code-based suite, so move to tests that an agent writes and maintains instead.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can a coding agent convert our Selenium suite for us?
&lt;/h3&gt;

&lt;p&gt;Yes. Claude Code, Cursor, Codex or Devin convert Selenium Java or Python to Playwright TypeScript one file at a time, and an engineer reviews and runs each file. The same agent can write the flow as a Momentic YAML test with the Momentic MCP server, then run it and read the failure.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>playwright</category>
      <category>selenium</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Using Cursor for UI Testing: How Much Can AI Actually Automate?</title>
      <dc:creator>Wei-Wei Wu</dc:creator>
      <pubDate>Sat, 31 Oct 2026 09:54:42 +0000</pubDate>
      <link>https://dev.to/wuweiweiwu/using-cursor-for-ui-testing-how-much-can-ai-actually-automate-4d2c</link>
      <guid>https://dev.to/wuweiweiwu/using-cursor-for-ui-testing-how-much-can-ai-actually-automate-4d2c</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://momentic.ai/blog/cursor-ui-testing-guide" rel="noopener noreferrer"&gt;Momentic blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Yes, Cursor can write and edit UI tests. It drafts Playwright or Cypress tests from a user story, writes page objects and mocks, and fixes broken selectors when you ask. Its agent can also drive a browser to click through your running app, but it does not keep those checks as tests that run again in CI. Connect it to a test runner, such as the Momentic MCP server, to close that gap.&lt;/p&gt;

&lt;p&gt;Can you use AI code generation tools like Cursor for UI testing? TL;DR yes, with some caveats. They accelerate test creation and maintenance without offering some of the steepest efficiency gains agentic AI tools offer.&lt;/p&gt;

&lt;p&gt;Depending on your requirements, this is no bad thing. But it’s important to understand what Cursor does well and what its limitations are before building an entire &lt;a href="https://momentic.ai/blog/enterprise-testing-strategy-guide" rel="noopener noreferrer"&gt;testing strategy&lt;/a&gt; around it. It will suit teams looking for an AI solution that sits on top of their existing framework and takes some of the grunt work out of your existing processes. It won’t suit those looking to do away with slow, cumbersome frameworks entirely.&lt;/p&gt;

&lt;p&gt;Here’s how Cursor accelerates testing, what it won’t help you with, and what your alternatives are.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cursor for UI Testing: What It Does Well
&lt;/h2&gt;

&lt;p&gt;Cursor does four UI testing jobs well: it drafts test cases from a user story, writes Playwright or Cypress code, edits broken selectors on request, and generates mocks and test data.&lt;/p&gt;

&lt;p&gt;If you’re looking for an AI testing tool that will shave some time off established processes, Cursor offers plenty to like. This makes it ideal for teams in that ‘in-between’ stage, if you’re using it as a coding agent and aren’t quite ready to add another tool to your stack, using Cursor for UI testing can help accelerate release cycles.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test Creation With AI
&lt;/h3&gt;

&lt;p&gt;One of the major pain points of traditional test automation frameworks is the effort required to create tests in the first place. If, as many modern organizations do, your engineers test code themselves without external QA handoff, this significantly eats into time spent on ideation and feature development.&lt;/p&gt;

&lt;p&gt;Using &lt;a href="https://momentic.ai/blog/libraries-and-heartbreak" rel="noopener noreferrer"&gt;Cursor&lt;/a&gt; for UI testing allows you to significantly reduce time spent on authoring tests in two key ways:&lt;/p&gt;

&lt;h3&gt;
  
  
  Generating Test Cases From Requirements
&lt;/h3&gt;

&lt;p&gt;Paste a user story and let Cursor generate the set of tests required to validate it. Cursor’s AI is relatively intelligent when it comes to what to test, as well as obvious happy-path tests, it can suggest edge cases, error scenarios, and accessibility checks to incorporate into your test suite.&lt;/p&gt;

&lt;h3&gt;
  
  
  Writing Playwright/Cypress code
&lt;/h3&gt;

&lt;p&gt;This is where Cursor offers the strongest efficiency gains. Cursor can generate code for &lt;a href="https://momentic.ai/blog/selenium-vs-playwright" rel="noopener noreferrer"&gt;Playwright, Selenium, and other traditional frameworks&lt;/a&gt; that’s complex enough to include&lt;/p&gt;

&lt;p&gt;page objects, selectors, test setup, assertions, and mock APIs.&lt;/p&gt;

&lt;p&gt;It’s good enough to understand large, complex codebases (including React components, Next.js pages, and API routes) and to generate tests that actually match your implementation, rather than generic templates or examples.&lt;/p&gt;

&lt;p&gt;It’s not perfect 100% of the time, but it gets you much closer than starting from scratch. Cursor code generation plus human review is far quicker than getting humans to code everything from scratch.&lt;/p&gt;

&lt;h3&gt;
  
  
  AI-Assisted Test Maintenance
&lt;/h3&gt;

&lt;p&gt;Using traditional frameworks, maintaining UI tests is often more expensive than writing new ones, in terms of engineering hours. As a result, teams either dedicate huge amounts of time to &lt;a href="https://momentic.ai/blog/how-self-healing-test-automation-reduces-maintenance" rel="noopener noreferrer"&gt;test maintenance&lt;/a&gt; (to keep test suites compact) or simply write new tests whenever needed, causing unnecessary bloat. Neither option is ideal.&lt;/p&gt;

&lt;p&gt;Using Cursor for UI testing significantly reduces the time needed to maintain your tests. With the right prompt, Cursor’s AI can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Refactor selectors&lt;/li&gt;
&lt;li&gt;Update page objects&lt;/li&gt;
&lt;li&gt;Fix broken locators&lt;/li&gt;
&lt;li&gt;Rename methods&lt;/li&gt;
&lt;li&gt;Convert old patterns to new ones&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you’re shipping multiple minor UI updates per week, this is a particularly useful tool to have on hand.&lt;/p&gt;

&lt;h3&gt;
  
  
  Generating Mocks and Test Data
&lt;/h3&gt;

&lt;p&gt;Cursor is very effective at creating mock API responses, fixtures, factories, seed data, and edge-case datasets. This saves a significant amount of repetitive manual work for your team.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Cursor for UI Testing Falls Short
&lt;/h2&gt;

&lt;p&gt;Cursor falls short in four places: dynamic UI behavior, assertions about business outcomes, selector stability, and turning browser exploration into repeatable tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cursor Often Misunderstands Dynamic UI Behavior
&lt;/h3&gt;

&lt;p&gt;This is a major point for teams using Cursor for UI testing. Dynamic behavior is common in modern web and mobile apps, and Cursor often misreads state transitions, real-time updates and other dynamic behavior. That makes it an incomplete solution on its own.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cursor Struggles to Find the Right Assertions
&lt;/h3&gt;

&lt;p&gt;Cursor’s AI will typically test “does the button exist?” over “was the order successfully submitted?” Generally, it lacks the domain knowledge to test business-critical assertions. This risks leaving important issues untested while giving the impression of broader coverage. Superficially scaling test coverage is easy with Cursor, but ensuring that coverage is meaningful takes significantly more effort.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cursor Generates Tests With Unstable Selectors
&lt;/h3&gt;

&lt;p&gt;On the one hand, using Cursor for UI testing helps accelerate test maintenance. On the other hand, teams report that Cursor-generated tests add to that burden by generating brittle selectors that increase flakiness.&lt;/p&gt;

&lt;p&gt;So, you maintain tests quicker, but &lt;a href="https://momentic.ai/blog/test-coverage-vs-code-coverage" rel="noopener noreferrer"&gt;generate more tests&lt;/a&gt; for which maintenance is required, and in-depth human review is still needed to ensure locator quality. Your net time spent on maintenance is still likely to decrease, but those efficiency gains are hampered significantly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cursor Can Explore Your App, but It Does Not Keep What It Finds
&lt;/h3&gt;

&lt;p&gt;Cursor’s agent can now control a browser. Its docs describe navigating, clicking, typing, taking screenshots, and reading console logs and network traffic to test an app. That is useful for checking a change while you build it. But Cursor is still a coding agent, not an &lt;a href="https://momentic.ai/blog/agentic-testing-guide" rel="noopener noreferrer"&gt;agentic testing solution&lt;/a&gt;. A browser session in chat is not a saved test that runs again in CI, and browser actions need your approval by default.&lt;/p&gt;

&lt;p&gt;For example, Cursor can click through a checkout flow and report what it saw, but that check ends with the chat. To keep the coverage, you still turn it into framework code and maintain its selectors. What it explores, and which coverage gaps it finds, still depend on what you ask it to look at.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cursor for UI Testing: An Example Workflow
&lt;/h2&gt;

&lt;p&gt;A practical Cursor workflow splits the work: a person sets the test strategy and reviews the assertions, Cursor writes the skeletons and boilerplate, CI runs the tests, and Cursor helps fix the failures.&lt;/p&gt;

&lt;p&gt;Can you use Cursor for UI testing effectively? Absolutely, if you understand what it can and cannot do, and build your workflows around that.&lt;/p&gt;

&lt;p&gt;Assuming that Cursor can take care of absolutely everything will result in disappointment. Seeing Cursor as a tool that accelerates code creation, with humans still entirely responsible for code quality, is a much more effective way of structuring things. A template workflow might look a little something like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Human defines test strategy&lt;/li&gt;
&lt;li&gt;AI generates test skeletons&lt;/li&gt;
&lt;li&gt;Human reviews assertions&lt;/li&gt;
&lt;li&gt;AI writes boilerplate&lt;/li&gt;
&lt;li&gt;CI executes tests&lt;/li&gt;
&lt;li&gt;AI helps fix failures&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Cursor Alternatives: AI-Native Testing Solutions
&lt;/h2&gt;

&lt;p&gt;The alternative to Cursor-written framework code is a testing tool that Cursor can drive. With Momentic, Cursor writes the test as plain-English steps, runs it, reads the failed step, screenshot and trace, and corrects its own code.&lt;/p&gt;

&lt;p&gt;Rather than simply accelerating your existing processes, &lt;a href="https://momentic.ai/" rel="noopener noreferrer"&gt;AI-native testing solutions&lt;/a&gt; add a whole new dimension to your strategy. Intelligent, agentic solutions move beyond code creation and maintenance on demand to a more intelligent approach.&lt;/p&gt;

&lt;p&gt;An agentic tool runs the app while it tests. It can explore a stated area, report what failed with a screenshot and a trace, and point a person at the step that broke. You still decide what to test and review each change.&lt;/p&gt;

&lt;p&gt;Momentic steps target an element by its description, not by a CSS selector. When a saved locator stops matching the page, Momentic finds the element again from that description. Cursor fixes a broken selector when you ask it to. Momentic re-resolves the element during the run, and you review the result in the run viewer.&lt;/p&gt;

&lt;p&gt;This moves part of the maintenance work from your engineers to the test runner. With more AI-generated code to verify, that time adds up.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does It Need to Be One or the Other?
&lt;/h3&gt;

&lt;p&gt;Not necessarily. You can combine the flexibility of custom code with the exploratory capabilities of &lt;a href="https://momentic.ai/blog/set-theory-of-agentic-testing" rel="noopener noreferrer"&gt;agentic AI&lt;/a&gt; by building critical paths in Playwright (with code generated and maintained by Cursor) while using AI testing solutions for broader regression and exploratory coverage.&lt;/p&gt;

&lt;p&gt;This gives you the visibility of code where you need it, while significantly reducing the engineering hours needed to keep large UI suites running.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do I connect Cursor to a test runner?
&lt;/h2&gt;

&lt;p&gt;Install the Momentic MCP server and the Momentic skills in your project. The MCP server gives Cursor a live browser and tools to run, edit and triage tests. The skills tell Cursor which tools to call and in what order. See the &lt;a href="https://momentic.ai/docs/coding-agents/mcp-server" rel="noopener noreferrer"&gt;MCP guide&lt;/a&gt; and the &lt;a href="https://momentic.ai/docs/coding-agents/skills" rel="noopener noreferrer"&gt;skills guide&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx momentic install-mcp &lt;span class="nt"&gt;--client&lt;/span&gt; cursor &lt;span class="nt"&gt;--scope&lt;/span&gt; project
npx momentic skills &lt;span class="nt"&gt;--target&lt;/span&gt; cursor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first command writes the server entry to .cursor/mcp.json. The second installs the skills in .cursor/skills/ and adds a pointer in .cursor/rules/momentic-skills.mdc. Restart Cursor, start a new chat, and ask which momentic_ tools are available.&lt;/p&gt;

&lt;p&gt;Then the agent loop has four steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Cursor writes and runs a test with the Momentic CLI or the Momentic MCP server.&lt;/li&gt;
&lt;li&gt;The run returns a structured failure: the step that failed, a screenshot and a trace.&lt;/li&gt;
&lt;li&gt;Cursor reads that result and corrects its own code, then runs the test again.&lt;/li&gt;
&lt;li&gt;Momentic maintains the test when the UI changes, and you review the change.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Can Cursor update my end-to-end tests when I change a component?
&lt;/h2&gt;

&lt;p&gt;Yes, if the tests are files in your repository. Ask Cursor to run the affected tests after it changes the component, and to update a test only when the expected behavior changed. Review the test diff with the code diff in the same pull request.&lt;/p&gt;

&lt;p&gt;A test that targets a CSS class breaks when Cursor renames that class. A Momentic step describes the element instead, for example "the Submit order button". When the saved locator stops matching, Momentic finds the element again from the description for that run, so a markup change does not fail the test.&lt;/p&gt;

&lt;p&gt;This also stops Cursor from writing brittle selectors, because the test holds no selector. See &lt;a href="https://momentic.ai/docs/reliability/auto-maintenance" rel="noopener noreferrer"&gt;locator auto-healing&lt;/a&gt; for how the re-resolution works.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI Testing Tools vs Cursor for UI Testing: At-A-Glance Comparison
&lt;/h2&gt;

&lt;p&gt;The table compares Cursor-written framework tests with an AI-native testing tool on purpose, authoring, maintenance and exploration.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;Cursor for UI Testing&lt;/th&gt;
&lt;th&gt;AI-native testing tools (for example, Momentic)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Primary Purpose&lt;/td&gt;
&lt;td&gt;AI-powered code generation and test maintenance on top of existing frameworks&lt;/td&gt;
&lt;td&gt;Tests written as plain-English steps, run in a real browser, with failure evidence a coding agent can read&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best Fit&lt;/td&gt;
&lt;td&gt;Teams that want to accelerate existing Playwright/Cypress workflows without changing their testing stack&lt;/td&gt;
&lt;td&gt;Teams that want a coding agent to write, run and correct end-to-end tests in the repository&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Test Creation&lt;/td&gt;
&lt;td&gt;Generates test cases from requirements and user stories, including happy paths, edge cases, error scenarios, and accessibility checks&lt;/td&gt;
&lt;td&gt;Plain-English steps in YAML files, written by an engineer or by Cursor through the Momentic MCP server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Test Maintenance&lt;/td&gt;
&lt;td&gt;Assists with refactoring selectors, updating page objects, fixing locators, renaming methods, and modernizing patterns when prompted&lt;/td&gt;
&lt;td&gt;Finds an element again from the step description when a saved locator stops matching; you review the result&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;App Exploration&lt;/td&gt;
&lt;td&gt;The agent can click through the app in a browser, with each action approved by default, but sessions are not saved as repeatable tests&lt;/td&gt;
&lt;td&gt;Mo explores a running app from an objective and files bugs with recordings and reproduction steps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Level of Autonomy&lt;/td&gt;
&lt;td&gt;Human-driven; heavily dependent on prompts, review, and oversight.&lt;/td&gt;
&lt;td&gt;The agent runs tests and reads the failed step, screenshot and trace; people review the diff&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Testing Approach&lt;/td&gt;
&lt;td&gt;Reactive and code-centric: humans define strategy, AI accelerates implementation&lt;/td&gt;
&lt;td&gt;Tests live in your repository and run from the CLI in CI&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Final Thoughts: Will Cursor For UI Testing Be Enough?
&lt;/h2&gt;

&lt;p&gt;Cursor is enough when you keep Playwright or Cypress and review every generated test yourself. When you want Cursor to run the tests and act on the failures, give it a test runner it can call.&lt;/p&gt;

&lt;p&gt;If you’re using it for code generation already, using Cursor for UI testing will give you some quick wins, coverage, and maintenance-wise. It won’t let you integrate AI with your testing processes to its full potential, however.&lt;/p&gt;

&lt;p&gt;An agentic tool adds what Cursor does not have: a test runner that the agent can call, failure evidence it can read, and tests saved from exploring the running app.&lt;/p&gt;

&lt;p&gt;To keep the flexibility of custom code, opt for Playwright and Cursor as a combination. To level up your testing processes and really accelerate your release cycles, choose a tool like Momentic, or a hybrid approach of the two.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We needed a way to own testing in-house without allocating too much engineering time toward addressing flakes. Momentic gave us that perfect blend of ownership, reliability, and flexibility.&lt;/p&gt;

&lt;p&gt;— Aniruddha Laud, Head of Engineering, Pocus&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://momentic.ai/customers/pocus" rel="noopener noreferrer"&gt;How Pocus reduced flaky tests by a factor of 20 and now validates 100% of production deployments with Momentic&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can Cursor be used for UI testing?
&lt;/h3&gt;

&lt;p&gt;Yes. Cursor writes and edits Playwright, Cypress and Selenium tests from a prompt or a user story. Its agent can click through your app in a browser, but it does not keep those checks as tests, so an engineer or a connected test runner must run each test and check what it asserts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which test tools work with Cursor?
&lt;/h3&gt;

&lt;p&gt;Any framework whose tests are code files, such as Playwright, Cypress and Selenium. Momentic also works with Cursor through its MCP server: run npx momentic install-mcp --client cursor, and Cursor can write, run and triage Momentic tests from chat.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I add a testing skill to Cursor?
&lt;/h3&gt;

&lt;p&gt;Run npx momentic skills --target cursor in your repository. It installs the Momentic skills in .cursor/skills/ and adds a pointer in .cursor/rules/momentic-skills.mdc, so Cursor knows which test tools to call and in what order.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can Cursor update my end-to-end tests when I change a component?
&lt;/h3&gt;

&lt;p&gt;Yes, if the tests live in your repository. Ask Cursor to run the affected tests after the change and to edit a test only when the expected behavior changed. Review the test diff with the code diff.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I stop Cursor from writing brittle selectors?
&lt;/h3&gt;

&lt;p&gt;Write tests that hold no selector. A Momentic step describes the element in plain English, and Momentic finds the element again from that description when the saved locator stops matching. In Playwright, ask Cursor for role-based or test-id locators.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can Cursor fix a failing test on its own?
&lt;/h3&gt;

&lt;p&gt;Only with the failure in front of it. Connected to the Momentic MCP server, Cursor runs the test, reads the failed step, screenshot and trace, and corrects its code. You review the diff before merge.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>cursor</category>
      <category>ai</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
