<?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: LOKENDER SINGH</title>
    <description>The latest articles on DEV Community by LOKENDER SINGH (@lokender_singh_8258958b86).</description>
    <link>https://dev.to/lokender_singh_8258958b86</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%2F2054663%2F3759985b-0158-4e7e-aea4-9cc4c22604da.png</url>
      <title>DEV Community: LOKENDER SINGH</title>
      <link>https://dev.to/lokender_singh_8258958b86</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lokender_singh_8258958b86"/>
    <language>en</language>
    <item>
      <title>How to Self-Heal Broken Playwright Tests from Traces with PIE</title>
      <dc:creator>LOKENDER SINGH</dc:creator>
      <pubDate>Mon, 16 Nov 2026 13:00:19 +0000</pubDate>
      <link>https://dev.to/lokender_singh_8258958b86/how-to-self-heal-broken-playwright-tests-from-traces-with-pie-22nh</link>
      <guid>https://dev.to/lokender_singh_8258958b86/how-to-self-heal-broken-playwright-tests-from-traces-with-pie-22nh</guid>
      <description>&lt;p&gt;Every engineer who maintains a Playwright test suite knows this failure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;locator.click: Test timeout exceeded
waiting for locator('#login-button-old')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;UI changes break tests all the time. But fixing them manually is tedious: you open the Playwright trace viewer, inspect DOM snapshots, find the renamed selector, update your Page Object or spec file, and rerun the test.&lt;/p&gt;

&lt;p&gt;Worse, sometimes the selector didn't break because of UI drift—it broke because a backend API threw an HTTP 500, a mock didn't load, or the session expired. Blindly updating the locator in those situations masks a real application regression.&lt;/p&gt;

&lt;p&gt;That distinction is why we built &lt;strong&gt;PIE (Playwright Intelligence Engine)&lt;/strong&gt;, invoked via &lt;code&gt;pw-intel&lt;/code&gt;. PIE reads a failed Playwright trace, decides whether the app or the test is broken, and only if it is the test does it rewrite the locator — proving the fix in a throwaway Git worktree sandbox before touching your code. Tier 1 is offline AST (&lt;strong&gt;$0 tokens&lt;/strong&gt;); Gate 0 refuses to repair when the backend returns HTTP 500s.&lt;/p&gt;

&lt;p&gt;In this tutorial, you will learn how to use &lt;strong&gt;PIE&lt;/strong&gt;, invoked via the &lt;strong&gt;&lt;code&gt;pw-intel&lt;/code&gt;&lt;/strong&gt; CLI, to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Capture rich failure traces in Playwright.&lt;/li&gt;
&lt;li&gt;Run a causal diagnosis to distinguish UI drift from application bugs.&lt;/li&gt;
&lt;li&gt;Automatically heal drifted locators with isolated Git worktree verification.&lt;/li&gt;
&lt;li&gt;Verify that PIE safely abstains when the application itself is failing.&lt;/li&gt;
&lt;li&gt;Connect PIE directly to &lt;strong&gt;Cursor&lt;/strong&gt; and &lt;strong&gt;Claude Code&lt;/strong&gt; via its built-in &lt;strong&gt;Model Context Protocol (MCP)&lt;/strong&gt; server.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  What is PIE?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;PIE (Playwright Intelligence Engine)&lt;/strong&gt; is an open-source CLI and AI companion for Microsoft Playwright. It reads failed Playwright trace archives (&lt;code&gt;trace.zip&lt;/code&gt;) and runs a two-tier verification pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Playwright Trace (.zip)
  │
  ▼
[1. Gate 0: Negative Controls]
  │── Server 500 / Network Error? ──► ABSTAIN (0 Tokens, 0 Changes)
  │
  ▼ (UI Drift Verified)
[2. Tier 1: Deterministic AST]
  │── Stable DOM snapshot match?   ──► Local Fast-Path ($0 Cost, &amp;lt;50ms)
  │
  ▼ (Complex Shift)
[3. Evidence Redactor &amp;amp; Slicer]
  │── Redacts secrets &amp;amp; extracts minimal target bounding box
  │
  ▼
[4. Tier 2: Semantic AI Agent]
  │── Intent-Preserving Candidate (Assertions Immutable)
  │
  ▼
[5. Headless Git Sandbox]
  ├── Test Passes  ──► Atomically Promote to Workspace
  └── Test Fails   ──► Discard &amp;amp; Leave Working Tree Clean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Key Capabilities of PIE:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tier 1 ($0 Token Cost):&lt;/strong&gt; Instant, local TypeScript AST fixes (&lt;code&gt;ts-morph&lt;/code&gt;) for renamed IDs, classes, and attributes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tier 2 (AI Semantic Fallback):&lt;/strong&gt; Engages an LLM only when DOM structure shifts significantly (e.g. converting native inputs to custom React comboboxes or modals), without ever touching assertions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail-Closed Safety (Gate 0):&lt;/strong&gt; Abstains from editing UI locators if the trace shows an HTTP 500 backend error or network timeout.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proof-Before-Promotion:&lt;/strong&gt; Re-runs the affected test in a disposable Git worktree sandbox before touching your active workspace.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Native MCP Server:&lt;/strong&gt; Exposes full diagnostic, repair, and test generation capabilities to AI coding assistants like Cursor and Claude.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Prerequisites &amp;amp; Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Node.js&lt;/strong&gt;: v20.0.0 or higher&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Git&lt;/strong&gt;: Installed and initialized in your repository (used for isolated worktree sandboxing)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Playwright&lt;/strong&gt;: &lt;code&gt;@playwright/test&lt;/code&gt; installed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Install PIE in your Playwright project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install --save-dev playwright-intelligence-engine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run PIE's built-in diagnostic healthcheck:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx pw-intel doctor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Running Playwright Intelligence Engine Diagnostic Healthcheck (pw-intel doctor)...

  ✓ Node.js Runtime     : v24.19.0 (Supported &amp;gt;= 20.0.0)
  ✓ Git Version Control : git version 2.44.0.windows.1
  ✓ Playwright Test     : ^1.64.1 (Found in package.json)
  ✓ Workspace Access    : Read/Write verified for '&amp;lt;cwd&amp;gt;'
  ✓ Host Platform       : win32 (x64)
  ✓ LLM Provider        : None configured (100% offline deterministic mode active)

Healthcheck Verdict: HEALTHY (Ready for diagnostic and repair workflows)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Note: If an LLM API key is configured in your environment, &lt;code&gt;pw-intel doctor&lt;/code&gt; displays &lt;code&gt;Configured (AI test generation enabled)&lt;/code&gt;)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Initialize your repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx pw-intel init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 1: Configure Trace Retention on Failure
&lt;/h2&gt;

&lt;p&gt;PIE requires Playwright’s trace archive to inspect DOM snapshots, network calls, and action timelines.&lt;/p&gt;

&lt;p&gt;In your &lt;code&gt;playwright.config.ts&lt;/code&gt;, ensure &lt;code&gt;baseURL&lt;/code&gt; and &lt;code&gt;trace&lt;/code&gt; are configured:&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;// playwright.config.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&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="s1"&gt;'@playwright/test'&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="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;use&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;baseURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'https://www.saucedemo.com'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'retain-on-failure'&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="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 2: Reproduce a Controlled Locator Drift
&lt;/h2&gt;

&lt;p&gt;Let’s simulate a common real-world scenario against a live public demo app (&lt;code&gt;saucedemo.com&lt;/code&gt;): a login button selector changed in the frontend code.&lt;/p&gt;

&lt;p&gt;Create &lt;code&gt;tests/ui/auth.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="n"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&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="s1"&gt;'@playwright/test'&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="s1"&gt;'Should login successfully with valid credentials'&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="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;page&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="k"&gt;await&lt;/span&gt; &lt;span class="n"&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="s1"&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="n"&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="s1"&gt;'#user-name'&lt;/span&gt;&lt;span class="p"&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="s1"&gt;'standard_user'&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="n"&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="s1"&gt;'#password'&lt;/span&gt;&lt;span class="p"&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="s1"&gt;'secret_sauce'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Drift injected: old selector '#login-button-stale' does not exist in the DOM&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&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="s1"&gt;'#login-button-stale'&lt;/span&gt;&lt;span class="p"&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="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;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;)&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="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;inventory&lt;/span&gt;&lt;span class="o"&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="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the test to capture the failure trace:&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/ui/auth.spec.ts --trace=on
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Playwright fails with a timeout and writes the trace archive to &lt;code&gt;test-results/&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;locator.click: Timeout 5000ms exceeded.
waiting for locator('#login-button-stale')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 3: Diagnose the Trace with PIE
&lt;/h2&gt;

&lt;p&gt;Before making any repairs, inspect what PIE sees inside the trace without modifying code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx pw-intel diagnose test-results/auth-Should-login-successfully-chromium/trace.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Illustrative diagnosis output):&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;╔══════════════════════════════════════════════════════════════════════╗
║             PLAYWRIGHT INTELLIGENCE ENGINE: DIAGNOSTIC REPORT        ║
╚══════════════════════════════════════════════════════════════════════╝

Root Cause Classification : LOCATOR_DRIFT
Confidence Level          : 94.0%
Failure Fingerprint       : failure-8a71b2d019f
Action Outcome            : 🟢 REPAIRABLE
────────────────────────────────────────────────────────────────────────
Failed Action Details:
  • Call ID     : call@18
  • Method      : page.click
  • Selector    : #login-button-stale
  • Error       : locator.click: Timeout 5000ms exceeded waiting for locator('#login-button-stale')
────────────────────────────────────────────────────────────────────────
Evidence Provenance:
  • DOM Snapshot Available : ✅ YES
  • Network Logs Ingested  : ✅ YES (12 events)
  • Source Code Mapped     : ✅ tests/ui/auth.spec.ts:9
────────────────────────────────────────────────────────────────────────
Analysis:
  Target element '#login-button-stale' was not found in the DOM.
  Snapshot analysis identified stable accessible replacement:
  page.getByRole('button', { name: 'Login' })
────────────────────────────────────────────────────────────────────────
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 4: Dry-Run Inspection vs. Sandbox Verification
&lt;/h2&gt;

&lt;p&gt;PIE offers granular control over repair execution:&lt;/p&gt;

&lt;h3&gt;
  
  
  A. Dry-Run Proposal (Inspection Only)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx pw-intel repair
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Emits the proposed diff and diagnostic analysis without executing tests or modifying your workspace.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  B. Isolated Worktree Execution (No Local Changes)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx pw-intel repair --execute
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Creates a temporary Git worktree sandbox, applies the proposed patch, and runs Playwright in isolation to verify the fix works before promoting.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 5: Apply Verified Repairs to Your Workspace
&lt;/h2&gt;

&lt;p&gt;When you are ready to apply verified repairs atomically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx pw-intel repair --apply --verbose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Terminal output &lt;em&gt;(illustrative telemetry breakdown)&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Telemetry &amp;amp; Spend Breakdown:
  • Fast-Path AST   : 1 trace (0 tokens, $0.000000 USD)
  • Semantic LLM    : 0 traces (0 tokens, $0.000000 USD)
  • Total Tokens    : 0 tokens
  • Total Cost      : $0.000000 USD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check &lt;code&gt;git diff&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;- await page.locator('#login-button-stale').click();&lt;/span&gt;
&lt;span class="gi"&gt;+ await page.getByRole('button', { name: 'Login' }).click();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now rerun the test locally:&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/ui/auth.spec.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 passed (2.8s)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 6: Negative-Control Test on Your Own Application
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note on Scoping:&lt;/strong&gt; Step 2 used the public &lt;code&gt;saucedemo.com&lt;/code&gt; demo app for client-side login. However, client-side static apps do not have backend API endpoints that throw real HTTP 500 errors.&lt;br&gt;
To test PIE's Gate 0 abstention, point &lt;code&gt;baseURL&lt;/code&gt; at your own staging/local application and intercept its actual authentication or data route.&lt;br&gt;
&lt;em&gt;(Alternatively, the PIE repository ships &lt;code&gt;benchmarks/controlled-app/app-server.ts&lt;/code&gt;, which returns real 401, 404, and 500 responses).&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Example against your application's real auth route:&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="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Should handle backend failure'&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="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;page&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="c1"&gt;// Injected server failure against your app's real endpoint:&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&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="s1"&gt;'**/api/v1/auth'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="n"&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="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;contentType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'application/json'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&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="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Internal Server Error'&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="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="n"&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="s1"&gt;'/login'&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="n"&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="s1"&gt;'button'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Login'&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;click&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="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;)&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="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;dashboard&lt;/span&gt;&lt;span class="o"&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="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the test to capture the failure trace, then invoke repair:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx pw-intel repair --apply --verbose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Gate 0 triggers immediately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;status: ABSTAINED
tier: negative_control
reason: Backend service error (HTTP 500) observed during tested action.
promotedFiles: []
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tokens consumed&lt;/strong&gt;: 0&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost&lt;/strong&gt;: $0.00&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Modified files&lt;/strong&gt;: None&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PIE refrains from making changes because the failure is an application bug, not a broken test. You can even generate a bug report directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx pw-intel report-defect test-results/failed-trace/trace.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 7: Cursor &amp;amp; Claude Code IDE Integration via MCP
&lt;/h2&gt;

&lt;p&gt;Instead of running CLI commands manually, you can plug PIE directly into your AI coding assistant using the &lt;strong&gt;Model Context Protocol (MCP)&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up in Cursor / Windsurf
&lt;/h3&gt;

&lt;p&gt;Add to your project's &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="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"playwright-intelligence"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&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="s2"&gt;"playwright-intelligence-engine"&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="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;h3&gt;
  
  
  Setting up in Claude Desktop
&lt;/h3&gt;

&lt;p&gt;Add to &lt;code&gt;claude_desktop_config.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="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"pw-intel"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&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="s2"&gt;"playwright-intelligence-engine"&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="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;&lt;em&gt;(For Claude Code CLI, add via &lt;code&gt;claude mcp add pw-intel -- npx -y playwright-intelligence-engine mcp&lt;/code&gt;).&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Available MCP Tools for Your Assistant:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;pw_intel_diagnose&lt;/code&gt;&lt;/strong&gt;: Diagnoses &lt;code&gt;trace.zip&lt;/code&gt; archives with DOM, network, and error evidence directly in your chat prompt.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;pw_intel_autonomous_repair&lt;/code&gt;&lt;/strong&gt;: Formulates a repair, spins up a headless sandbox, verifies the patch, and promotes it cleanly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;pw_intel_batch_repair&lt;/code&gt;&lt;/strong&gt;: Discovers all failing traces across the repo in parallel, verifies them in isolated worktrees, and promotes verified fixes in one pass.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;pw_intel_profile&lt;/code&gt;&lt;/strong&gt;: Discovers your project's Page Objects, fixtures, and locator patterns so generated code looks native.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;run_qa_pipeline&lt;/code&gt;&lt;/strong&gt;: Generates full E2E suites from natural language requirements (&lt;code&gt;pw-intel qa&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  CLI Command Quick Reference
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Usage&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;doctor&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx pw-intel doctor&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Inspects Node, Git, Playwright &amp;amp; environment readiness&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;init&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx pw-intel init&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Initializes &lt;code&gt;.pie/config.json&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;diagnose&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx pw-intel diagnose &amp;lt;trace.zip&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ingests a trace and outputs root cause diagnosis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;repair&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx pw-intel repair&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Inspection dry-run: emits repair proposal without executing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;repair --execute&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx pw-intel repair --execute&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Verifies repair proposal in an isolated Git worktree&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;repair --apply&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx pw-intel repair --apply&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Applies only sandbox-verified repairs to your workspace&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;report-defect&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx pw-intel report-defect &amp;lt;trace.zip&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Emits an issue-ready bug report with HAR &amp;amp; network telemetry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;qa&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx pw-intel qa &amp;lt;featureName&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Evidence-driven test generation matching repository conventions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;mcp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npx pw-intel mcp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Starts the Model Context Protocol stdio server for Cursor/Claude&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;PIE&lt;/strong&gt; turns test maintenance from manual guesswork into a rigorous, evidence-driven process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Offline Fast-Path&lt;/strong&gt;: 100% deterministic AST repairs at $0 token cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail-Closed Gate 0&lt;/strong&gt;: Abstains when the application or environment crashes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sandbox Proof&lt;/strong&gt;: Never touches your working tree unless the repair passes in an isolated Git worktree.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assertion Safety&lt;/strong&gt;: Asserts remain structurally immutable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;First-Class MCP&lt;/strong&gt;: Direct native integration into Cursor, Windsurf, and Claude.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Give it a try in your repository and let us know what you think!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;npm&lt;/strong&gt;: &lt;a href="https://www.npmjs.com/package/playwright-intelligence-engine" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/playwright-intelligence-engine&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub&lt;/strong&gt;: &lt;a href="https://github.com/lst2121/playwright-intelligence-engine" rel="noopener noreferrer"&gt;https://github.com/lst2121/playwright-intelligence-engine&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>typescript</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
