<?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: Gary Parker</title>
    <description>The latest articles on DEV Community by Gary Parker (@garyparker).</description>
    <link>https://dev.to/garyparker</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%2F2027099%2Fab95a6b5-096a-4c83-ae96-279a3796a824.png</url>
      <title>DEV Community: Gary Parker</title>
      <link>https://dev.to/garyparker</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/garyparker"/>
    <language>en</language>
    <item>
      <title>Agents in the Loop: 2-5 Idle Tests With Survivors, 30-38 Without</title>
      <dc:creator>Gary Parker</dc:creator>
      <pubDate>Fri, 04 Dec 2026 17:15:15 +0000</pubDate>
      <link>https://dev.to/garyparker/agents-in-the-loop-2-5-idle-tests-with-survivors-30-38-without-377l</link>
      <guid>https://dev.to/garyparker/agents-in-the-loop-2-5-idle-tests-with-survivors-30-38-without-377l</guid>
      <description>&lt;p&gt;Given only "add tests that improve this suite", a coding agent wrote 58 to 66 tests, and 30 to 38 of them detect no mutant that ufo's own suite missed. Given the list of surviving mutants as well, it wrote 23 to 28 tests, and 2 to 5 of them are idle. Each arm ran 5 times.&lt;/p&gt;

&lt;p&gt;Chapter 6 of &lt;a href="https://garyparker.dev/mutation-testing" rel="noopener noreferrer"&gt;Mutation Testing for the AI Era&lt;/a&gt;. &lt;a href="https://garyparker.dev/blog/killing-survivors-without-chasing-the-score" rel="noopener noreferrer"&gt;Chapter 4&lt;/a&gt; did this by hand: 31 tests, 62 mutants. The prompts, the harness and every run are in &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/tree/5bc504e" rel="noopener noreferrer"&gt;the PoC repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The question
&lt;/h2&gt;

&lt;p&gt;Does giving an agent the mutation survivors make it write tests that check more, or does it just add more tests?&lt;/p&gt;

&lt;p&gt;The subject is unjs/ufo at &lt;code&gt;f06c800&lt;/code&gt;, with its own suite. &lt;a href="https://garyparker.dev/blog/reading-a-mutation-report" rel="noopener noreferrer"&gt;Chapter 3&lt;/a&gt; measured 1011 mutants, and 176 of them go undetected: 112 survived and 64 have no coverage. Survivors in an OSS subject are suite gaps, not bugs. &lt;code&gt;src/punycode.ts&lt;/code&gt; is vendored code and out of scope, as in chapter 4. It holds 47 of the 176, which leaves 129.&lt;/p&gt;

&lt;h2&gt;
  
  
  The two arms
&lt;/h2&gt;

&lt;p&gt;Arm A gets this prompt, and nothing else:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Add tests that improve this suite.

- Scope: `subject/src`. Leave `subject/src/punycode.ts` alone: it is vendored third-party code.
- Write new test files only under `agent/`, named `*.test.ts`. Import the library as `import { ... } from "../src"`, like ufo's own tests.
- Do not change any other file.
- Run the suite with `npm test`. Every test must pass.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Arm B gets the same prompt plus the 129 undetected mutants in scope, one per line, from the chapter 3 report: file, line, column, mutator, status, original code and replacement. For example, &lt;code&gt;src/parse.ts:4:37, StringLiteral, Survived: "\"ufo:protocolRelative\"" -&amp;gt; "\"\""&lt;/code&gt;. The prompt does not say "kill these". Both prompts are in &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/tree/5bc504e/prompts" rel="noopener noreferrer"&gt;&lt;code&gt;prompts/&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How a run works
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Model &lt;code&gt;claude-sonnet-5-5&lt;/code&gt; in headless Claude Code 2.1.334, with a 60-turn cap and a 30-minute wall clock. No run came near either: the longest used 22 turns.&lt;/li&gt;
&lt;li&gt;Each run starts in a fresh clone that holds ufo's source and suite and a Vitest config. It has none of chapter 4's tests, results or scripts, so the agent cannot see the human answers.&lt;/li&gt;
&lt;li&gt;The agent can read, write, edit, search, and run &lt;code&gt;npm test&lt;/code&gt; and &lt;code&gt;npx vitest&lt;/code&gt;. It cannot run Stryker, so arm A cannot mutation-test itself. Each run had 2 to 6 tool calls denied, all of them shell commands outside that list. The agent worked around them, and no run tried to start Stryker.&lt;/li&gt;
&lt;li&gt;After the run, a diff check fails the run if anything outside &lt;code&gt;agent/*.test.ts&lt;/code&gt; changed, or if the suite fails on the unmutated code. All 10 runs passed both checks. The check has &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/blob/5bc504e/tests/ch6-diff-check.test.ts" rel="noopener noreferrer"&gt;its own test&lt;/a&gt;, which I saw fail before it passed.&lt;/li&gt;
&lt;li&gt;Then Stryker 10.1.1 with &lt;code&gt;disableBail&lt;/code&gt;, as in chapter 4, scores ufo's suite plus the agent's tests. Vitest 4.1.5, Node v24.14.1.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;Each cell is min / median / max over 5 runs. The last column is chapter 4's 31 hand-written tests.&lt;/p&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;Arm A: prompt only&lt;/th&gt;
&lt;th&gt;Arm B: prompt + survivors&lt;/th&gt;
&lt;th&gt;Human, chapter 4&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Tests added&lt;/td&gt;
&lt;td&gt;58 / 59 / 66&lt;/td&gt;
&lt;td&gt;23 / 25 / 28&lt;/td&gt;
&lt;td&gt;31&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Newly detected mutants&lt;/td&gt;
&lt;td&gt;51 / 65 / 72&lt;/td&gt;
&lt;td&gt;72 / 73 / 77&lt;/td&gt;
&lt;td&gt;62&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kills per test&lt;/td&gt;
&lt;td&gt;0.88 / 1.07 / 1.22&lt;/td&gt;
&lt;td&gt;2.67 / 2.88 / 3.26&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tests that kill nothing new&lt;/td&gt;
&lt;td&gt;30 / 34 / 38&lt;/td&gt;
&lt;td&gt;2 / 5 / 5&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tests with no unique kill&lt;/td&gt;
&lt;td&gt;34 / 37 / 44&lt;/td&gt;
&lt;td&gt;4 / 6 / 6&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mutation score&lt;/td&gt;
&lt;td&gt;87.64% / 89.02% / 89.71%&lt;/td&gt;
&lt;td&gt;89.71% / 89.81% / 90.21%&lt;/td&gt;
&lt;td&gt;88.72%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The baseline score is 82.59%. "Newly detected" counts mutants that were Survived or NoCoverage in chapter 3 and are Killed or Timeout now.&lt;/p&gt;

&lt;p&gt;Per run:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Run&lt;/th&gt;
&lt;th&gt;A tests&lt;/th&gt;
&lt;th&gt;A newly detected&lt;/th&gt;
&lt;th&gt;A kill nothing&lt;/th&gt;
&lt;th&gt;A no unique kill&lt;/th&gt;
&lt;th&gt;B tests&lt;/th&gt;
&lt;th&gt;B newly detected&lt;/th&gt;
&lt;th&gt;B kill nothing&lt;/th&gt;
&lt;th&gt;B no unique kill&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;60&lt;/td&gt;
&lt;td&gt;65&lt;/td&gt;
&lt;td&gt;34&lt;/td&gt;
&lt;td&gt;37&lt;/td&gt;
&lt;td&gt;25&lt;/td&gt;
&lt;td&gt;73&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;66&lt;/td&gt;
&lt;td&gt;66&lt;/td&gt;
&lt;td&gt;38&lt;/td&gt;
&lt;td&gt;44&lt;/td&gt;
&lt;td&gt;25&lt;/td&gt;
&lt;td&gt;72&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;59&lt;/td&gt;
&lt;td&gt;63&lt;/td&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;td&gt;36&lt;/td&gt;
&lt;td&gt;28&lt;/td&gt;
&lt;td&gt;77&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;59&lt;/td&gt;
&lt;td&gt;72&lt;/td&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;td&gt;34&lt;/td&gt;
&lt;td&gt;27&lt;/td&gt;
&lt;td&gt;72&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;58&lt;/td&gt;
&lt;td&gt;51&lt;/td&gt;
&lt;td&gt;37&lt;/td&gt;
&lt;td&gt;44&lt;/td&gt;
&lt;td&gt;23&lt;/td&gt;
&lt;td&gt;75&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Arm A's newly detected count swings from 51 to 72 across runs, so read the ranges, not one run.&lt;/p&gt;

&lt;h2&gt;
  
  
  "Kills nothing new" is the junk count
&lt;/h2&gt;

&lt;p&gt;A test that kills nothing new passes, and it detects none of the 176 mutants that ufo's suite missed. It may still pin behaviour the suite already pins, so it is not necessarily wrong. It adds no detection, and it adds code to maintain.&lt;/p&gt;

&lt;p&gt;Arm A has 30 to 38 of these in 58 to 66 tests. Arm B has 2 to 5 in 23 to 28.&lt;/p&gt;

&lt;p&gt;The human figure is 0 by construction. The &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/blob/5bc504e/scripts/measure-ch4.mjs" rel="noopener noreferrer"&gt;chapter 4 script&lt;/a&gt; fails if an added test kills nothing new, because I triaged survivors first and wrote a test only for a mutant I had picked. So 0 shows the filter worked. It does not show humans never write idle tests.&lt;/p&gt;

&lt;p&gt;"No unique kill" is stricter: no mutant is killed by this test alone. The humans have 7 of 31 by that count, because several chapter 4 tests share kills. Arm A's 34 to 44 is above that, and arm B's 4 to 6 is just under it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overlap with the 62 human kills
&lt;/h2&gt;

&lt;p&gt;Arm A detects 35 to 46 of the 62 mutants the chapter 4 tests detected. Arm B detects 45 to 51. Outside the human 62, A finds 16 to 26 mutants and B finds 21 to 28.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the numbers say
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;With the survivor list, the agent wrote less than half the tests and detected as many mutants or more: 72 to 77 newly detected against 51 to 72.&lt;/li&gt;
&lt;li&gt;The ranges touch only at 72, arm A's best run and arm B's worst. With 5 runs per arm, treat that as a strong direction and not a tight estimate.&lt;/li&gt;
&lt;li&gt;Arm B's tests kill 2.67 to 3.26 mutants each, against 0.88 to 1.22 for arm A and 2 for the human tests.&lt;/li&gt;
&lt;li&gt;Arm B's mutation score, 89.71% to 90.21%, is above the human 88.72%. Chapter 4 stopped there on purpose, so the score is not the point.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Test-level counts credit a kill to a test only when the report lists it as a killer. In A-2, 6 detected mutants have no credited test, and in B-5, 1. The "kills nothing new" counts are correct for credited kills, and may overcount idle tests by that much.&lt;/li&gt;
&lt;li&gt;Arm A ignored the punycode scope note once. In A-2, 3 of the 66 newly detected mutants are in &lt;code&gt;src/punycode.ts&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;n=5 per arm, one subject, one model, one prompt wording each. A different model or a prompt that says "kill these mutants" may behave differently.&lt;/li&gt;
&lt;li&gt;Arm B is told where the gaps are. Arm A is not, and ufo's source is the only guide it has. The comparison measures what the list adds, not a realistic workflow.&lt;/li&gt;
&lt;li&gt;The agent cost is a list-price estimate from the CLI, not a bill: $0.39 to $0.61 per run for arm A ($2.59 for 5 runs) and $0.38 to $0.42 per run for arm B ($1.99 for 5 runs).&lt;/li&gt;
&lt;li&gt;Mutation score rewards detection, not value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Give the agent the survivors, run the same Stryker command on its tests, and count the tests that kill nothing new. The harness is in &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/tree/5bc504e" rel="noopener noreferrer"&gt;qa-gary-parker/poc-mutation-testing-ufo&lt;/a&gt;. The raw numbers are in &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/tree/5bc504e/results/ch6-agent" rel="noopener noreferrer"&gt;&lt;code&gt;results/ch6-agent&lt;/code&gt;&lt;/a&gt;. Measured with StrykerJS 10.1.1 and Vitest 4.1.5 on ufo &lt;code&gt;f06c800&lt;/code&gt;, 5 runs per arm.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://garyparker.dev/blog/agents-in-the-loop-mutation-guided-test-writing" rel="noopener noreferrer"&gt;https://garyparker.dev/blog/agents-in-the-loop-mutation-guided-test-writing&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>mutationtesting</category>
      <category>typescript</category>
      <category>ai</category>
    </item>
    <item>
      <title>Mutation Testing in CI Without the Bill: 4.5 to 6.8 Seconds, Not 70.5 to 107.4</title>
      <dc:creator>Gary Parker</dc:creator>
      <pubDate>Thu, 03 Dec 2026 12:42:27 +0000</pubDate>
      <link>https://dev.to/garyparker/mutation-testing-in-ci-without-the-bill-45-to-68-seconds-not-705-to-1074-nkl</link>
      <guid>https://dev.to/garyparker/mutation-testing-in-ci-without-the-bill-45-to-68-seconds-not-705-to-1074-nkl</guid>
      <description>&lt;p&gt;On a pull request, an incremental Stryker run takes 4.5 to 6.8 seconds. A full run on the same runners takes 70.5 to 107.4. On each runner, incremental is 15.67 to 16.17 times faster than full, and a run limited to the changed file is 8.1 to 8.26 times faster. &lt;a href="https://garyparker.dev/blog/killing-survivors-without-chasing-the-score" rel="noopener noreferrer"&gt;Chapter 4&lt;/a&gt; got the score to 88.72%. This chapter makes the check cheap enough to run on every pull request, and makes it fail the build when the score drops.&lt;/p&gt;

&lt;p&gt;Chapter 5 of &lt;a href="https://garyparker.dev/mutation-testing" rel="noopener noreferrer"&gt;Mutation Testing for the AI Era&lt;/a&gt;. The workflows, the config, the timing script and the raw results are in &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo" rel="noopener noreferrer"&gt;the PoC repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cost problem
&lt;/h2&gt;

&lt;p&gt;A mutation run tests every mutant against the suite. ufo has 1011 mutants, and a full run on a GitHub-hosted runner took 70.5 to 107.4 seconds. ufo is small. The cost grows with the number of mutants and the tests that run for each one, so a larger repo pays far more, on every push.&lt;/p&gt;

&lt;p&gt;Most of that work is repeated. A pull request changes a few lines, and almost every mutant sits in code the pull request did not touch. The three modes below skip that work in different ways.&lt;/p&gt;

&lt;p&gt;Survivors in an OSS subject are suite gaps, not bugs. The subject is unjs/ufo at &lt;code&gt;f06c800&lt;/code&gt;, with its own suite. This chapter uses it as a timing subject.&lt;/p&gt;

&lt;p&gt;The baseline here is 82.59%, the chapter 3 score, not chapter 4's 88.72%. The chapter 5 config runs ufo's own suite without the chapter 4 tests, with Stryker's default bail. I chose that so the timings are those of a plain run. The chapter 4 config adds &lt;code&gt;kills/&lt;/code&gt; and sets &lt;code&gt;disableBail&lt;/code&gt;, and each of its runs took the CI runner 395 to 407 seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three modes
&lt;/h2&gt;

&lt;p&gt;All three use one config, &lt;code&gt;stryker.ch5.config.mjs&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="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'./stryker.config.mjs'&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="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="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;reporters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'clear-text'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'json'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;clearTextReporter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;reportTests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;jsonReporter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'reports/ch5/mutation.json'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;incrementalFile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'reports/ch5/stryker-incremental.json'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;thresholds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;85&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&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;The config does not turn incremental mode on. Each mode passes its own flags:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Full:&lt;/strong&gt; &lt;code&gt;npx stryker run stryker.ch5.config.mjs --incremental --force&lt;/code&gt;. Runs every mutant and rewrites the baseline file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Incremental:&lt;/strong&gt; &lt;code&gt;npx stryker run stryker.ch5.config.mjs --incremental&lt;/code&gt;. Reads the baseline and reuses the result of every mutant whose code and covering tests did not change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Changed files:&lt;/strong&gt; &lt;code&gt;npx stryker run stryker.ch5.config.mjs --mutate subject/src/query.ts&lt;/code&gt;. Mutates only the files you list and reuses nothing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How I measured it
&lt;/h2&gt;

&lt;p&gt;The change is one line in &lt;code&gt;subject/src/query.ts&lt;/code&gt;: &lt;code&gt;s.length &amp;lt; 2&lt;/code&gt; becomes &lt;code&gt;s.length &amp;lt;= 1&lt;/code&gt;. The behaviour is the same, so the suite stays green. It changes 7 mutants.&lt;/p&gt;

&lt;p&gt;A script, &lt;code&gt;scripts/measure-ch5.mjs&lt;/code&gt;, runs four modes in order on one runner:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;full&lt;/code&gt; on the clean tree. This builds the baseline.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;incremental&lt;/code&gt; on the changed tree, with the baseline.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;changed-files&lt;/code&gt; on the changed tree, mutating &lt;code&gt;query.ts&lt;/code&gt; only.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;full-changed&lt;/code&gt;, a full run on the changed tree.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;code&gt;Measure ch5&lt;/code&gt; workflow runs the script as 3 jobs, one per runner. Every run uses StrykerJS 10.1.1, Vitest 4.1.5 and Node v24.14.1 on ufo &lt;code&gt;f06c800&lt;/code&gt;. That is 3 runs per mode.&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;Wall time&lt;/th&gt;
&lt;th&gt;Mutants tested&lt;/th&gt;
&lt;th&gt;Mutants reused&lt;/th&gt;
&lt;th&gt;Score&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;full&lt;/td&gt;
&lt;td&gt;70.5-107.4 s&lt;/td&gt;
&lt;td&gt;1011&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;82.59%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;incremental&lt;/td&gt;
&lt;td&gt;4.5-6.8 s&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;1004&lt;/td&gt;
&lt;td&gt;82.59%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;changed files&lt;/td&gt;
&lt;td&gt;8.7-13 s&lt;/td&gt;
&lt;td&gt;78&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;85.9%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Incremental tests 7 mutants and reuses 1004. Its score, 82.59%, is the score of the full run, because the reused results are real results from the baseline.&lt;/p&gt;

&lt;p&gt;The changed files score, 85.9%, is for &lt;code&gt;query.ts&lt;/code&gt; only. It has 78 mutants, and the run tests all of them. It is not a project score.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compare within a run, not across runs
&lt;/h2&gt;

&lt;p&gt;The 3 runners had 3 different CPU models, so the full run spans 70.5 to 107.4 seconds:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Run&lt;/th&gt;
&lt;th&gt;CPU&lt;/th&gt;
&lt;th&gt;full&lt;/th&gt;
&lt;th&gt;incremental&lt;/th&gt;
&lt;th&gt;changed files&lt;/th&gt;
&lt;th&gt;Full / incremental&lt;/th&gt;
&lt;th&gt;Full / changed files&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;AMD EPYC 9V45&lt;/td&gt;
&lt;td&gt;70.5 s&lt;/td&gt;
&lt;td&gt;4.5 s&lt;/td&gt;
&lt;td&gt;8.7 s&lt;/td&gt;
&lt;td&gt;15.67&lt;/td&gt;
&lt;td&gt;8.1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;AMD EPYC 9V74&lt;/td&gt;
&lt;td&gt;84.1 s&lt;/td&gt;
&lt;td&gt;5.2 s&lt;/td&gt;
&lt;td&gt;10.3 s&lt;/td&gt;
&lt;td&gt;16.17&lt;/td&gt;
&lt;td&gt;8.17&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;AMD EPYC 7763&lt;/td&gt;
&lt;td&gt;107.4 s&lt;/td&gt;
&lt;td&gt;6.8 s&lt;/td&gt;
&lt;td&gt;13 s&lt;/td&gt;
&lt;td&gt;15.79&lt;/td&gt;
&lt;td&gt;8.26&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each runner had 4 CPUs. A ratio of the medians across runs would mix hardware with mode. The ratio inside one run does not, and it stays in a narrow band: 15.67 to 16.17 for incremental and 8.1 to 8.26 for changed files. Quote the speedup, not the seconds. Seconds depend on the runner you get.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does incremental give the same answer?
&lt;/h2&gt;

&lt;p&gt;Fast is no use if it is wrong. The fourth mode, &lt;code&gt;full-changed&lt;/code&gt;, runs every mutant on the changed tree. I compared it with the incremental run, mutant by mutant, on whether each one is detected (Killed or Timeout) or not. They differ on 0 mutants in all 3 runs. Both runs also score 82.59%.&lt;/p&gt;

&lt;h2&gt;
  
  
  The gate
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;thresholds.break&lt;/code&gt; is the gate. When the score falls below it, Stryker exits with code 1, and the job fails. The baseline is 82.59%, and I set &lt;code&gt;break&lt;/code&gt; to 80. That leaves 2.59 points of room.&lt;/p&gt;

&lt;p&gt;I checked that the gate fails. With &lt;code&gt;break&lt;/code&gt; at 90, a local run printed &lt;code&gt;Final mutation score 82.99 under breaking threshold 90, setting exit code to 1 (failure).&lt;/code&gt; and exited 1. The local score is 82.99%, not 82.59%: 25 mutants timed out on my machine and 12 on the runner, and Stryker counts a timeout as detected. The config, the full output and the exit code are &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/blob/main/results/ch5-gate" rel="noopener noreferrer"&gt;in the repo&lt;/a&gt;. The committed config keeps &lt;code&gt;break&lt;/code&gt; at 80.&lt;/p&gt;

&lt;p&gt;Pick &lt;code&gt;break&lt;/code&gt; just under your current score, then raise it as the score rises. A value far under the score never fails.&lt;/p&gt;

&lt;h2&gt;
  
  
  The workflow
&lt;/h2&gt;

&lt;p&gt;On a pull request, the job restores the baseline, runs incremental, then runs the changed files:&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="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/cache/restore@v6&lt;/span&gt;
  &lt;span class="na"&gt;with&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="s"&gt;reports/ch5/stryker-incremental.json&lt;/span&gt;
    &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;stryker-incremental-none&lt;/span&gt;
    &lt;span class="na"&gt;restore-keys&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;stryker-incremental-&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="s"&gt;Stryker, incremental, gated by thresholds.break&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx stryker run stryker.ch5.config.mjs --incremental&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="s"&gt;Stryker, changed files only&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;files=$(git diff --name-only --diff-filter=d origin/${{ github.base_ref }}...HEAD -- 'subject/src/*.ts' | grep -v '^subject/src/index.ts$' | paste -sd, -)&lt;/span&gt;
    &lt;span class="s"&gt;if [ -z "$files" ]; then echo "no mutated file changed"; exit 0; fi&lt;/span&gt;
    &lt;span class="s"&gt;npx stryker run stryker.ch5.config.mjs --mutate "$files"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The nightly run, at 03:17 UTC, and any manual dispatch run full and save the baseline:&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="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="s"&gt;Stryker, full run, rebuilds the baseline&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx stryker run stryker.ch5.config.mjs --incremental --force&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/cache/save@v6&lt;/span&gt;
  &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always() &amp;amp;&amp;amp; github.ref == 'refs/heads/main'&lt;/span&gt;
  &lt;span class="na"&gt;with&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="s"&gt;reports/ch5/stryker-incremental.json&lt;/span&gt;
    &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;stryker-incremental-${{ github.run_id }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I ran this on a real pull request, a demo change that I closed afterwards. First, a manual full run on &lt;code&gt;main&lt;/code&gt; logged &lt;code&gt;Cache saved with key: stryker-incremental-46964796850&lt;/code&gt;. The pull request run then logged &lt;code&gt;Cache restored from key: stryker-incremental-46964796850&lt;/code&gt;, and Stryker reused 1004 of 1011 mutant results. The score was 82.59%, over &lt;code&gt;break&lt;/code&gt;. The changed files step mutated &lt;code&gt;query.ts&lt;/code&gt; only: 78 mutants, 85.9%, also over &lt;code&gt;break&lt;/code&gt;. Both logs are in &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/blob/main/results/ch5-workflow" rel="noopener noreferrer"&gt;&lt;code&gt;results/ch5-workflow&lt;/code&gt;&lt;/a&gt; (&lt;code&gt;baseline.log&lt;/code&gt; and &lt;code&gt;pr-warm.log&lt;/code&gt;), and &lt;code&gt;runs.json&lt;/code&gt; there lists the run IDs. &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/actions/runs/46967851844" rel="noopener noreferrer"&gt;The pull request run is here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cache, not artifact
&lt;/h2&gt;

&lt;p&gt;The baseline file lives in the Actions cache, not in an artifact. The reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A pull request can restore a cache that &lt;code&gt;main&lt;/code&gt; saved. &lt;code&gt;restore-keys&lt;/code&gt; picks the newest &lt;code&gt;stryker-incremental-*&lt;/code&gt; entry. To fetch an artifact, the job would have to look up the last good run through the API first.&lt;/li&gt;
&lt;li&gt;Pull requests only restore. Only a full run on &lt;code&gt;main&lt;/code&gt; saves: the nightly run, or a manual dispatch. A pull request cannot overwrite the baseline, so &lt;code&gt;main&lt;/code&gt; stays the only source.&lt;/li&gt;
&lt;li&gt;The baseline can be up to a day old. Incremental mode compares the mutated files and the test files with the current ones, so a pull request still gets fresh results for what it changed. The Stryker docs say what it cannot see: "Stryker will not detect any changes you've made in files other than mutated files and test files." Updated dev dependencies and environment changes are in that list. That is why the nightly run uses &lt;code&gt;--force&lt;/code&gt;: it re-tests every mutant and rebuilds the baseline.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The first pull request is cold
&lt;/h2&gt;

&lt;p&gt;With no cache, there is no baseline. The first pull request in &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/actions/runs/46963315731" rel="noopener noreferrer"&gt;my run&lt;/a&gt; logged &lt;code&gt;Cache not found&lt;/code&gt; and tested all 1011 mutants. Its log is &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/blob/main/results/ch5-workflow/pr-cold.log" rel="noopener noreferrer"&gt;&lt;code&gt;pr-cold.log&lt;/code&gt;&lt;/a&gt;. That is a full run, so it costs a full run. After the nightly run saves a baseline, pull requests take the incremental path.&lt;/p&gt;

&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The first draft of the measure script, &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/blob/eb2d02a/scripts/measure-ch5.mjs#L107" rel="noopener noreferrer"&gt;at &lt;code&gt;eb2d02a&lt;/code&gt;&lt;/a&gt;, computed the speedup as a ratio of medians across runs. With 3 CPU models, that number mixed hardware and mode. On these medians it gives 84.1 / 5.2, stored as &lt;code&gt;16.173099999999998&lt;/code&gt;. I replaced it with the per-run ratio, rounded to 2 decimals.&lt;/li&gt;
&lt;li&gt;The cache steps could only be checked by real runs. The cold run and the warm run above are those runs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;p&gt;One library, one commit, one small change, 3 runners. Incremental cost grows with the reach of the change: a change to a helper that many tests cover re-tests more mutants than 7. The Stryker docs also say a killed mutant is reused only while its killing test still exists and did not change, and a survivor is reused only if no new test covers it and no tests changed. So a test change re-runs the mutants it touches.&lt;/p&gt;

&lt;p&gt;With &lt;code&gt;--mutate&lt;/code&gt;, the &lt;code&gt;break&lt;/code&gt; threshold applies to the changed files' own score, not the project's. A file with few mutants can pass or fail on one mutant. The incremental step gates the whole project, so run both.&lt;/p&gt;

&lt;p&gt;Use incremental on pull requests, full on a schedule, and &lt;code&gt;break&lt;/code&gt; just under your score. Compare modes on one runner, and trust ratios more than seconds.&lt;/p&gt;

&lt;p&gt;Everything above is reproducible: &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo" rel="noopener noreferrer"&gt;qa-gary-parker/poc-mutation-testing-ufo&lt;/a&gt;. The timing run is &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/actions/runs/46964790129" rel="noopener noreferrer"&gt;on GitHub&lt;/a&gt;, and its output is in &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo/blob/main/results/ch5-ci" rel="noopener noreferrer"&gt;&lt;code&gt;results/ch5-ci&lt;/code&gt;&lt;/a&gt;. Measured with StrykerJS 10.1.1 and Vitest 4.1.5 on ufo &lt;code&gt;f06c800&lt;/code&gt;, 3 runs per mode, one per runner.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://garyparker.dev/blog/mutation-testing-in-ci-without-the-bill" rel="noopener noreferrer"&gt;https://garyparker.dev/blog/mutation-testing-in-ci-without-the-bill&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>mutationtesting</category>
      <category>typescript</category>
      <category>githubactions</category>
    </item>
    <item>
      <title>Killing Survivors Without Chasing the Score: 31 Tests, 62 Mutants</title>
      <dc:creator>Gary Parker</dc:creator>
      <pubDate>Wed, 02 Dec 2026 16:18:11 +0000</pubDate>
      <link>https://dev.to/garyparker/killing-survivors-without-chasing-the-score-31-tests-62-mutants-4i6</link>
      <guid>https://dev.to/garyparker/killing-survivors-without-chasing-the-score-31-tests-62-mutants-4i6</guid>
      <description>&lt;p&gt;31 tests in ufo's own style detect 62 of the 176 mutants its suite missed, and move the score from 82.59% to 88.72%. The other 114 stay undetected on purpose, and each one has a written reason. &lt;a href="https://garyparker.dev/blog/reading-a-mutation-report" rel="noopener noreferrer"&gt;Chapter 3&lt;/a&gt; read the report. This chapter acts on it, and stops well short of 100%.&lt;/p&gt;

&lt;p&gt;Chapter 4 of &lt;a href="https://garyparker.dev/mutation-testing" rel="noopener noreferrer"&gt;Mutation Testing for the AI Era&lt;/a&gt;. The tests, the list of accepted mutants and the raw reports are in &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo" rel="noopener noreferrer"&gt;the PoC repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule
&lt;/h2&gt;

&lt;p&gt;A new test has to check something ufo promises: a doc comment, an example, or behaviour a caller relies on. If the only test that kills a mutant would pin odd behaviour, the mutant stays alive and I write down why.&lt;/p&gt;

&lt;p&gt;Survivors in an OSS subject are suite gaps, not bugs. All 31 tests pass on ufo as it is. They check behaviour ufo already has, which its own suite did not check.&lt;/p&gt;

&lt;h2&gt;
  
  
  Triage before tests
&lt;/h2&gt;

&lt;p&gt;I sorted the 176 before I wrote a test. The order: the file, then equivalence, then the contract.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The file.&lt;/strong&gt; 47 undetected mutants are in &lt;code&gt;punycode.ts&lt;/code&gt;, a minified copy of punycode 2.1.1 vendored into ufo. Their gaps belong to punycode's tests, so they are out of scope. 22 more are in &lt;code&gt;url.ts&lt;/code&gt;, whose &lt;code&gt;$URL&lt;/code&gt; and &lt;code&gt;createURL&lt;/code&gt; are marked &lt;code&gt;@deprecated&lt;/code&gt; upstream. A new test for deprecated code is cost with no return. Accepted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Equivalence.&lt;/strong&gt; 20 mutants behave like the original for every input. No test can kill them. Accepted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The contract.&lt;/strong&gt; 25 mutants can be killed, but only by a test that pins behaviour nobody relies on. Low value. Accepted.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That leaves 62, and each one now has a test. 53 of them had survived and 9 had no coverage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the tests live
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;subject/&lt;/code&gt; stays a byte-identical copy of ufo at &lt;code&gt;f06c800&lt;/code&gt;. The 31 tests are in &lt;code&gt;kills/&lt;/code&gt;, written the way ufo writes its own: &lt;code&gt;describe&lt;/code&gt; and &lt;code&gt;test&lt;/code&gt;, tables of &lt;code&gt;{ input, out }&lt;/code&gt;, and an import from &lt;code&gt;"../src"&lt;/code&gt;. Each file drops into ufo's &lt;code&gt;test/&lt;/code&gt; folder unchanged.&lt;/p&gt;

&lt;p&gt;Stryker normally stops at the first test that kills a mutant. This chapter sets &lt;code&gt;disableBail: true&lt;/code&gt;, so the report lists every test that kills each mutant. That is where the per-test counts below come from.&lt;/p&gt;

&lt;p&gt;The measure script fails if a new test kills nothing that ufo's suite missed. It also fails if the accepted list does not match the undetected mutants exactly. CI runs it on every push, so the list cannot drift from the report.&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&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;Mutants&lt;/th&gt;
&lt;th&gt;Killed&lt;/th&gt;
&lt;th&gt;Timeout&lt;/th&gt;
&lt;th&gt;Survived&lt;/th&gt;
&lt;th&gt;No coverage&lt;/th&gt;
&lt;th&gt;Mutation score&lt;/th&gt;
&lt;th&gt;Score of covered code&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Before (ufo's suite)&lt;/td&gt;
&lt;td&gt;1011&lt;/td&gt;
&lt;td&gt;823&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;112&lt;/td&gt;
&lt;td&gt;64&lt;/td&gt;
&lt;td&gt;82.59%&lt;/td&gt;
&lt;td&gt;88.17%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;After (+ 31 tests)&lt;/td&gt;
&lt;td&gt;1011&lt;/td&gt;
&lt;td&gt;881&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;59&lt;/td&gt;
&lt;td&gt;55&lt;/td&gt;
&lt;td&gt;88.72%&lt;/td&gt;
&lt;td&gt;93.83%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Stryker ran twice on a GitHub-hosted runner and scored 88.72% both times. Every mutant had the same status in both runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  One test, eight mutants
&lt;/h2&gt;

&lt;p&gt;Chapter 3 found 7 undetected mutants on one line of &lt;code&gt;parseQuery&lt;/code&gt;: the guard that drops &lt;code&gt;__proto__&lt;/code&gt; and &lt;code&gt;constructor&lt;/code&gt; keys. The doc comment promises that guard. The test from chapter 3 is now in &lt;code&gt;kills/&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="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ignores __proto__ and constructor keys"&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="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="nf"&gt;parseQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"__proto__=x&amp;amp;constructor=y&amp;amp;a=1"&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;toEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1"&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;p&gt;It kills 8 mutants: all 7 on that line, and #375, which makes &lt;code&gt;parseQuery&lt;/code&gt; always drop the first character. 7 of the 8 die to this test alone. Across all 31 tests the range is 1 to 8 mutants each. Some mutants die to more than one test, so the 62 work out at 2 per test added.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overlap is fine
&lt;/h2&gt;

&lt;p&gt;For 7 of the 31 tests, every mutant they kill is also killed by another new test. &lt;code&gt;isScriptProtocol("https:")&lt;/code&gt; is one of them. It kills #595 from chapter 3, but so does the &lt;code&gt;xjavascript:&lt;/code&gt; case in the same table.&lt;/p&gt;

&lt;p&gt;I kept all 7. Each one checks a different promise, and a higher score is not the reason a test exists. Deleting a test because another test already covers its mutants is chasing the score in the other direction.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 20 no test can kill
&lt;/h2&gt;

&lt;p&gt;An equivalent mutant changes the code but not what the code does. Here is #1000, in &lt;code&gt;withFragment&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;hash&lt;/span&gt; &lt;span class="o"&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;return&lt;/span&gt; &lt;span class="n"&gt;input&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="n"&gt;parsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseURL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;parsed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"#"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;encodeHash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hash&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;Stryker replaced &lt;code&gt;hash === ""&lt;/code&gt; on the last line with &lt;code&gt;false&lt;/code&gt;. The guard above already returns when &lt;code&gt;hash&lt;/code&gt; is empty, so that comparison is never true. The mutant changes nothing that a test can see.&lt;/p&gt;

&lt;p&gt;The other 19 are the same kind of difference that no input can reach. A default value that the regex always fills. A fallback array that the code only reads from index 1. A regex match that always has 3 entries, so &lt;code&gt;&amp;lt; 2&lt;/code&gt; and &lt;code&gt;&amp;lt;= 2&lt;/code&gt; give the same answer (#393). #95 from chapter 3 is on the list too.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 25 a test could kill, but should not
&lt;/h2&gt;

&lt;p&gt;Low value means the only killing test would pin behaviour that no caller relies on.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;11 default arguments&lt;/strong&gt;, such as &lt;code&gt;input = ""&lt;/code&gt;. A test would call the function with nothing. Chapter 3 called these cheap to cover. They are also cheap to leave.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;#70, &lt;code&gt;mailto:&lt;/code&gt;.&lt;/strong&gt; &lt;code&gt;parseURL&lt;/code&gt; turns a URL without &lt;code&gt;//&lt;/code&gt; after the scheme into all-empty fields. The mutant changes a default that only that path uses. A test that kills it would pin &lt;code&gt;mailto:a@b.com&lt;/code&gt; parsing to six empty strings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fast paths.&lt;/strong&gt; &lt;code&gt;resolveURL&lt;/code&gt; returns early when there is nothing to resolve, and &lt;code&gt;filterQuery&lt;/code&gt; returns early when the input has no &lt;code&gt;?&lt;/code&gt;. Without the early return, the slow path parses and rebuilds the input. &lt;code&gt;HTTP://a.com/x&lt;/code&gt; comes back as &lt;code&gt;http://a.com/x&lt;/code&gt;, and &lt;code&gt;mailto:a@b.com&lt;/code&gt; comes back as &lt;code&gt;//&lt;/code&gt;, the #70 behaviour again. A killing test would pin what each function returns for input it was not called to change.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of the 25 has its reason in the accepted list, next to its mutant id.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a list and not disable comments
&lt;/h2&gt;

&lt;p&gt;Stryker can skip a mutant with a comment in the source, such as &lt;code&gt;// Stryker disable next-line ConditionalExpression: equivalent, guard above&lt;/code&gt;. That edits the code. Here the code is ufo's, and the copy must stay identical to upstream. So the reasons live in &lt;code&gt;results/ch4-kills/accepted.json&lt;/code&gt;, by mutant id.&lt;/p&gt;

&lt;p&gt;Ids only hold while the source and the mutators stay the same. The measure script checks that every id still points at the same mutant as in chapter 3. In your own repo, the comment is the better place: it sits next to the code and moves with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Timeouts went up
&lt;/h2&gt;

&lt;p&gt;Timeouts rose from 12 to 16. Four &lt;code&gt;punycode.ts&lt;/code&gt; mutants (#323, #325, #359, #369) went from Killed to Timeout. With &lt;code&gt;disableBail&lt;/code&gt;, Stryker runs every covering test against a mutant instead of stopping at the first failure. For these 4, the full set ran past the time limit. Both statuses count as detected, so the score is the same either way.&lt;/p&gt;

&lt;p&gt;Each Stryker run took the CI runner 395 to 407 seconds, with &lt;code&gt;disableBail&lt;/code&gt; on.&lt;/p&gt;

&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The CI check passed when it should have failed. The step runs &lt;code&gt;git diff --exit-code&lt;/code&gt; on &lt;code&gt;summary.json&lt;/code&gt; to prove that a fresh run matches the committed numbers. On the first run, no &lt;code&gt;summary.json&lt;/code&gt; was committed yet, and &lt;code&gt;git diff&lt;/code&gt; ignores untracked files. &lt;code&gt;git add -N&lt;/code&gt; marks the file as intent-to-add, so the diff sees it. The next run failed as it should, and printed the numbers it found.&lt;/li&gt;
&lt;li&gt;The first full runs were on a laptop with other work running. Static mutants timed out there that survive on a quiet runner, so the count of newly detected mutants was too high. One of them, #549, is on the equivalent list: on the runner it survives. Every "after" number in this post comes from the CI runner. The "before" row is the chapter 3 report.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Limits: one library, one commit, Stryker's default mutators. The 67 accepted mutants reflect my reading of ufo's contract. Another reader could move a few of the 25 low-value mutants into the "write a test" pile.&lt;/p&gt;

&lt;p&gt;Triage first: the file, then equivalence, then the contract. Write tests only for what is left, and write down why the rest stays.&lt;/p&gt;

&lt;p&gt;Everything above is reproducible: &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo" rel="noopener noreferrer"&gt;qa-gary-parker/poc-mutation-testing-ufo&lt;/a&gt;. Measured with StrykerJS 10.1.1 and Vitest 4.1.5 on ufo &lt;code&gt;f06c800&lt;/code&gt;, 2 Stryker runs.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://garyparker.dev/blog/killing-survivors-without-chasing-the-score" rel="noopener noreferrer"&gt;https://garyparker.dev/blog/killing-survivors-without-chasing-the-score&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>mutationtesting</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Reading a Mutation Report: 176 Mutants ufo's Tests Missed</title>
      <dc:creator>Gary Parker</dc:creator>
      <pubDate>Tue, 01 Dec 2026 11:02:58 +0000</pubDate>
      <link>https://dev.to/garyparker/reading-a-mutation-report-176-mutants-ufos-tests-missed-50lp</link>
      <guid>https://dev.to/garyparker/reading-a-mutation-report-176-mutants-ufos-tests-missed-50lp</guid>
      <description>&lt;p&gt;A mutation report is a list of questions, not a list of bugs. I ran StrykerJS on &lt;a href="https://github.com/unjs/ufo" rel="noopener noreferrer"&gt;unjs/ufo&lt;/a&gt;, a URL library with 489 tests, and it scored 82.59% on both runs: 176 of 1011 mutants went undetected. This post reads that report: what each status means, where to look first, and which survivors are worth a test.&lt;/p&gt;

&lt;p&gt;Chapter 3 of &lt;a href="https://garyparker.dev/mutation-testing" rel="noopener noreferrer"&gt;Mutation Testing for the AI Era&lt;/a&gt;. The pinned copy of ufo, the measure script and the raw reports are in &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo" rel="noopener noreferrer"&gt;the PoC repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The subject
&lt;/h2&gt;

&lt;p&gt;ufo at commit &lt;code&gt;f06c800&lt;/code&gt; (v1.6.4), copied unchanged, with its own Vitest suite. Stryker mutated every file in &lt;code&gt;src/&lt;/code&gt; except &lt;code&gt;index.ts&lt;/code&gt;, which only re-exports the others.&lt;/p&gt;

&lt;p&gt;Survivors in an OSS subject are suite gaps, not bugs. Each one is a change to the code that no test noticed. It says nothing about whether ufo is wrong.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mutants&lt;/th&gt;
&lt;th&gt;Killed&lt;/th&gt;
&lt;th&gt;Timeout&lt;/th&gt;
&lt;th&gt;Survived&lt;/th&gt;
&lt;th&gt;No coverage&lt;/th&gt;
&lt;th&gt;Errors&lt;/th&gt;
&lt;th&gt;Mutation score&lt;/th&gt;
&lt;th&gt;Score of covered code&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1011&lt;/td&gt;
&lt;td&gt;823&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;112&lt;/td&gt;
&lt;td&gt;64&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;82.59%&lt;/td&gt;
&lt;td&gt;88.17%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What each status means
&lt;/h2&gt;

&lt;p&gt;Stryker gives each mutant one status:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Killed&lt;/strong&gt;: at least one test failed with the mutant in place. The suite noticed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Survived&lt;/strong&gt;: tests ran the mutated code, and all of them passed. The report's own tooltip says it plainly: "You're missing a test for them."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No coverage&lt;/strong&gt;: no test ran the mutated code at all.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Timeout&lt;/strong&gt;: the mutated code ran far longer than the normal run, usually an endless loop. Stryker counts it as detected.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Runtime error&lt;/strong&gt; and &lt;strong&gt;compile error&lt;/strong&gt;: the mutant broke the run or the build. They are left out of the score. There were none here.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The score is (killed + timeout) / (killed + timeout + survived + no coverage). "Score of covered code" leaves out the no-coverage mutants. The gap between those two numbers is the first thing to read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to look first: the two scores per file
&lt;/h2&gt;

&lt;p&gt;The HTML report shows both scores for each file. Their gap tells you what kind of work each file needs.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;File&lt;/th&gt;
&lt;th&gt;Mutants&lt;/th&gt;
&lt;th&gt;Survived&lt;/th&gt;
&lt;th&gt;No coverage&lt;/th&gt;
&lt;th&gt;Score&lt;/th&gt;
&lt;th&gt;Score of covered code&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;encoding.ts&lt;/td&gt;
&lt;td&gt;43&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;95.35%&lt;/td&gt;
&lt;td&gt;97.62%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;parse.ts&lt;/td&gt;
&lt;td&gt;150&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;td&gt;86%&lt;/td&gt;
&lt;td&gt;95.56%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;punycode.ts&lt;/td&gt;
&lt;td&gt;180&lt;/td&gt;
&lt;td&gt;28&lt;/td&gt;
&lt;td&gt;19&lt;/td&gt;
&lt;td&gt;73.89%&lt;/td&gt;
&lt;td&gt;82.61%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;query.ts&lt;/td&gt;
&lt;td&gt;78&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;85.9%&lt;/td&gt;
&lt;td&gt;88.16%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;url.ts&lt;/td&gt;
&lt;td&gt;90&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;td&gt;75.56%&lt;/td&gt;
&lt;td&gt;89.47%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;utils.ts&lt;/td&gt;
&lt;td&gt;470&lt;/td&gt;
&lt;td&gt;60&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;84.47%&lt;/td&gt;
&lt;td&gt;86.87%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A wide gap means code no test runs.&lt;/strong&gt; &lt;code&gt;url.ts&lt;/code&gt; scores 75.56% of all mutants but 89.47% of covered ones. 14 of its 22 undetected mutants have no coverage. The fix is a test that calls that code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A narrow gap means tests that run the code but do not check it.&lt;/strong&gt; &lt;code&gt;utils.ts&lt;/code&gt; scores 84.47% and 86.87%. 60 of its 73 undetected mutants survived. The fix is a sharper assertion in a test that already exists.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check what the file is before you read its survivors.&lt;/strong&gt; &lt;code&gt;punycode.ts&lt;/code&gt; has the lowest score and 47 undetected mutants. Its header comment explains why: "Tree-shaked + Minified version of &lt;a href="mailto:punycode@2.1.1"&gt;punycode@2.1.1&lt;/a&gt;". It is vendored, minified code. Read its survivors last, or leave it out of &lt;code&gt;mutate&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What the mutator tells you
&lt;/h2&gt;

&lt;p&gt;The mutator name says what kind of check is missing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ConditionalExpression: 41 of 112 survivors.&lt;/strong&gt; Stryker replaces a condition with &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;. A survivor means no test needed the other outcome.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;StringLiteral: 34 of 64 no-coverage mutants.&lt;/strong&gt; Many are default parameters such as &lt;code&gt;input = ""&lt;/code&gt;. They only run when a caller leaves the argument out. These are cheap to cover and rarely matter.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The file tells you where the gap is. The mutator tells you what to write.&lt;/p&gt;

&lt;h2&gt;
  
  
  Same gap, two statuses
&lt;/h2&gt;

&lt;p&gt;Line 62 of &lt;code&gt;query.ts&lt;/code&gt;, the &lt;code&gt;if&lt;/code&gt;, has 7 undetected mutants: 6 survived and 1 has no coverage.&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="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;decodeQueryKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&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="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="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"__proto__"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"constructor"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;continue&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;Mutant #397 replaces the condition with &lt;code&gt;false&lt;/code&gt;. It survived, and 38 tests cover it. Mutant #405 empties &lt;code&gt;{ continue; }&lt;/code&gt;. It has no coverage. Both point at the same gap: no test sends a &lt;code&gt;__proto__&lt;/code&gt; or &lt;code&gt;constructor&lt;/code&gt; key. The condition runs for every key, so the tests cover it. The body never runs, so the tests do not.&lt;/p&gt;

&lt;p&gt;When one line holds a cluster of statuses, read it as one gap. Write one test, not seven:&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;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'drops __proto__ and constructor keys'&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="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="nf"&gt;parseQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'__proto__=x&amp;amp;constructor=y&amp;amp;a=1'&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;toEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'1'&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;p&gt;It passes on ufo as it is. With #397 in place, it fails: &lt;code&gt;AssertionError: expected { __proto__: 'x', …(2) } to deeply equal { a: '1' }&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Timeouts count as detected
&lt;/h2&gt;

&lt;p&gt;All 12 timeouts are in &lt;code&gt;punycode.ts&lt;/code&gt;. Mutant #221 empties the body of this loop:&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;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;o&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;e&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;700&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nf"&gt;e&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;455&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;e&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;35&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 the body empty, &lt;code&gt;n&lt;/code&gt; never changes and the loop never ends. Stryker stops the run and counts the mutant as detected. A timeout is not a gap: a caller would hang, and a hanging test run is a failing one. Skip them when you triage.&lt;/p&gt;

&lt;p&gt;Timeouts also depend on the machine. One rerun ran while the machine was busy, with a load average of 32. In its second Stryker run, 9 mutants timed out that had not timed out in the first: 8 had survived and 1 had been killed. The score rose from 82.59% to 83.38%. All 9 were static mutants: module-level code, such as a regex constant, that runs once when the module loads. Stryker runs every test against a static mutant, so these are the slowest to finish. The measure script compares the two runs and refused to write results. If the timeout count changes between runs, suspect the machine before the suite.&lt;/p&gt;

&lt;h2&gt;
  
  
  The survivors that matter
&lt;/h2&gt;

&lt;p&gt;Rank survivors by what the code promises, not by count.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#397, the prototype guard.&lt;/strong&gt; The doc comment on &lt;code&gt;parseQuery&lt;/code&gt; says: "The &lt;code&gt;__proto__&lt;/code&gt; and &lt;code&gt;constructor&lt;/code&gt; keys are ignored to prevent prototype pollution." No test checks that promise. Without the guard, &lt;code&gt;__proto__&lt;/code&gt; comes back as a key in the result. This is the first test I would add.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#595, &lt;code&gt;isScriptProtocol&lt;/code&gt;.&lt;/strong&gt; The function says if a protocol, such as &lt;code&gt;javascript:&lt;/code&gt;, can run script:&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;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isScriptProtocol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;protocol&lt;/span&gt;&lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="kt"&gt;string&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="o"&gt;!!&lt;/span&gt;&lt;span class="n"&gt;protocol&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="no"&gt;PROTOCOL_SCRIPT_RE&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="n"&gt;protocol&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;Stryker replaced the whole expression with &lt;code&gt;true&lt;/code&gt;, and it survived. All 6 test cases expect &lt;code&gt;true&lt;/code&gt;. The doc comment shows &lt;code&gt;isScriptProtocol("https://example.com"); // false&lt;/code&gt;, but no test checks a &lt;code&gt;false&lt;/code&gt; result. The mutant fails safe, since it flags every protocol. The gap is that the test table has only one side:&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;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'https: is not a script protocol'&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="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="nf"&gt;isScriptProtocol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'https:'&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;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&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;This one fails with #595 in place: &lt;code&gt;AssertionError: expected true to be false // Object.is equality&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The survivors to leave
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;#95 is an equivalent mutant.&lt;/strong&gt; In &lt;code&gt;parse.ts&lt;/code&gt;, Stryker removed the &lt;code&gt;?&lt;/code&gt; from &lt;code&gt;/([^#/?]*)(.*)?/&lt;/code&gt;. With the &lt;code&gt;?&lt;/code&gt;, an empty match gives &lt;code&gt;undefined&lt;/code&gt;. Without it, the match gives &lt;code&gt;""&lt;/code&gt;. The destructuring default &lt;code&gt;path = ""&lt;/code&gt; turns both into &lt;code&gt;""&lt;/code&gt;, so the result is the same for every input. No test can kill it, and 104 tests cover it. Stryker can skip it with a disable comment and a reason. Either way, 100% is not always reachable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#258 looks like a gap and mostly is not.&lt;/strong&gt; In &lt;code&gt;punycode.ts&lt;/code&gt;, Stryker replaced the surrogate-pair check &lt;code&gt;r &amp;gt;= 55296 &amp;amp;&amp;amp; r &amp;lt;= 56319 &amp;amp;&amp;amp; o &amp;lt; e&lt;/code&gt; with &lt;code&gt;true&lt;/code&gt;. An emoji domain seems the obvious test. I ran &lt;code&gt;toASCII&lt;/code&gt; on the original and the mutant. Emoji, &lt;code&gt;münchen.de&lt;/code&gt; and other valid input gave the same output. Only a lone low surrogate after another character, which is malformed UTF-16, gave a different one. A test for it would test punycode, not ufo.&lt;/p&gt;

&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The first summary had a "killing tests" count from the report's Tests view. The two final runs gave 168 and 170. Stryker stops at the first failing test for each mutant, so which test gets the kill can change between runs. The mutant statuses did not change. The summary now keeps only the stable numbers.&lt;/li&gt;
&lt;li&gt;The Tests view lists 487 tests, but Vitest runs 489. Stryker keys tests by their full name, and two pairs of ufo's tests share a name.&lt;/li&gt;
&lt;li&gt;My first note for #258 said an emoji test would kill it. Running the mutant showed it would not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Limits: one library, one commit, Stryker's default mutators. The score belongs to this suite at this commit, not to ufo in general. Stryker ran twice, scored 82.59% both times, and every mutant had the same status in both runs.&lt;/p&gt;

&lt;p&gt;Read the two scores per file first, then the mutator, then the line. &lt;a href="https://garyparker.dev/blog/coverage-vs-mutation-score" rel="noopener noreferrer"&gt;Chapter 1&lt;/a&gt; covers why coverage misses these gaps, and &lt;a href="https://garyparker.dev/blog/mutation-testing-ai-generated-tests" rel="noopener noreferrer"&gt;chapter 2&lt;/a&gt; runs the same check on tests an AI agent wrote.&lt;/p&gt;

&lt;p&gt;Everything above is reproducible: &lt;a href="https://github.com/qa-gary-parker/poc-mutation-testing-ufo" rel="noopener noreferrer"&gt;qa-gary-parker/poc-mutation-testing-ufo&lt;/a&gt;. Measured with StrykerJS 10.1.1 and Vitest 4.1.5 on ufo &lt;code&gt;f06c800&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://garyparker.dev/blog/reading-a-mutation-report" rel="noopener noreferrer"&gt;https://garyparker.dev/blog/reading-a-mutation-report&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>mutationtesting</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
    <item>
      <title>100% Coverage, 18% Mutation Score: What Coverage Doesn't Check</title>
      <dc:creator>Gary Parker</dc:creator>
      <pubDate>Mon, 30 Nov 2026 13:05:12 +0000</pubDate>
      <link>https://dev.to/garyparker/100-coverage-18-mutation-score-what-coverage-doesnt-check-43lf</link>
      <guid>https://dev.to/garyparker/100-coverage-18-mutation-score-what-coverage-doesnt-check-43lf</guid>
      <description>&lt;p&gt;Coverage tells you which lines ran during the tests. It does not tell you whether a test would fail if those lines were wrong. I wrote three test suites for the same small module, and all three reached 100% line and branch coverage. Their mutation scores were 18.42%, 34.21% and 100%.&lt;/p&gt;

&lt;p&gt;Chapter 1 of &lt;a href="https://garyparker.dev/mutation-testing" rel="noopener noreferrer"&gt;Mutation Testing for the AI Era&lt;/a&gt;. The module, the suites, the measure script and the raw reports are in &lt;a href="https://github.com/qa-gary-parker/poc-coverage-vs-mutation-score" rel="noopener noreferrer"&gt;the PoC repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The module
&lt;/h2&gt;

&lt;p&gt;Two functions that a real HTTP client needs. &lt;code&gt;shouldRetry&lt;/code&gt; says if a status is worth another try. &lt;code&gt;retryDelay&lt;/code&gt; gives an exponential backoff delay with a cap, and throws on an attempt out of range.&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;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;DEFAULTS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RetryOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;baseMs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;maxMs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;maxAttempts&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="c1"&gt;// 408 and 429 are worth another try; so is a 5xx, except 501 (the server will never support the request)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;shouldRetry&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="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;boolean&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="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;408&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&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="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;600&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="mi"&gt;501&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Exponential backoff: baseMs, 2 x baseMs, 4 x baseMs ... capped at maxMs&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;retryDelay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RetryOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;DEFAULTS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&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="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;maxAttempts&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;RangeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`attempt must be between 1 and ${options.maxAttempts}, got ${attempt}`&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;return&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;baseMs&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempt&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="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;maxMs&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;
  
  
  Three suites, same calls
&lt;/h2&gt;

&lt;p&gt;Each suite calls both functions with inputs that reach every line and every branch. They differ only in what they check.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;runs-only&lt;/code&gt;&lt;/strong&gt; checks that something came back. The out-of-range call sits in a &lt;code&gt;try&lt;/code&gt;/&lt;code&gt;catch&lt;/code&gt;, so the test passes whether it throws or not.&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;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'handles retryable statuses'&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="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="nf"&gt;shouldRetry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;408&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;toBeDefined&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;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;shouldRetry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;429&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;toBeDefined&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;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;shouldRetry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;503&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;toBeDefined&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;p&gt;&lt;strong&gt;&lt;code&gt;type-checks&lt;/code&gt;&lt;/strong&gt; checks the type and the range: a boolean, a delay above 0, and a throw on bad input.&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;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'returns a positive number'&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="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="nf"&gt;retryDelay&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toBeGreaterThan&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="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="nf"&gt;retryDelay&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;span class="nf"&gt;toBeGreaterThan&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="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="nf"&gt;retryDelay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;baseMs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;maxMs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;maxAttempts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&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;toBeGreaterThan&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="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;strong&gt;&lt;code&gt;exact-values&lt;/code&gt;&lt;/strong&gt; checks the exact result at each boundary (407, 408, 409, 499, 500, 501, 599, 600 and others), the delay for each attempt, the cap, and the error message.&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;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'doubles the delay on each attempt'&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="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="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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;retryDelay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempt&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;toEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;100&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;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;800&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;p&gt;All three suites pass, and Vitest's v8 coverage reports 100% of lines, statements, branches and functions for each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What mutation testing measures
&lt;/h2&gt;

&lt;p&gt;A mutation testing tool makes one small change to the code, runs the tests, and puts the change back. It does this for every change it can make: flip &lt;code&gt;&amp;lt;&lt;/code&gt; to &lt;code&gt;&amp;lt;=&lt;/code&gt;, replace a condition with &lt;code&gt;true&lt;/code&gt;, swap &lt;code&gt;Math.min&lt;/code&gt; for &lt;code&gt;Math.max&lt;/code&gt;, empty a string. Each changed copy is a mutant.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If a test fails, the mutant is &lt;strong&gt;killed&lt;/strong&gt;: the suite would notice that bug.&lt;/li&gt;
&lt;li&gt;If every test passes, the mutant &lt;strong&gt;survived&lt;/strong&gt;: the suite would let that bug through.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The mutation score is the share of mutants killed. &lt;a href="https://stryker-mutator.io/" rel="noopener noreferrer"&gt;StrykerJS&lt;/a&gt; 10.1.1 made 38 mutants from this module, and ran each suite against all 38.&lt;/p&gt;

&lt;h2&gt;
  
  
  The results
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Suite&lt;/th&gt;
&lt;th&gt;What the tests check&lt;/th&gt;
&lt;th&gt;Tests&lt;/th&gt;
&lt;th&gt;Line coverage&lt;/th&gt;
&lt;th&gt;Branch coverage&lt;/th&gt;
&lt;th&gt;Mutation score&lt;/th&gt;
&lt;th&gt;Mutants survived&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;runs-only&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a result came back&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;18.42%&lt;/td&gt;
&lt;td&gt;31 of 38&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;type-checks&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;type, range, throws&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;34.21%&lt;/td&gt;
&lt;td&gt;25 of 38&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;exact-values&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;exact result at each boundary&lt;/td&gt;
&lt;td&gt;17&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;0 of 38&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Coverage gives the same number for all three suites. The mutation score separates them.&lt;/p&gt;

&lt;h2&gt;
  
  
  What survived
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;shouldRetry&lt;/code&gt;: 21 of 22 mutants survived in both weak suites.&lt;/strong&gt; Stryker replaced &lt;code&gt;status === 408 || status === 429&lt;/code&gt; with &lt;code&gt;true&lt;/code&gt;, so every status, 404 included, says "retry". Both suites passed: the result is still defined, and still a boolean. The same goes for &lt;code&gt;status !== 501&lt;/code&gt; flipped to &lt;code&gt;status === 501&lt;/code&gt;, and for &lt;code&gt;&amp;gt;= 500&lt;/code&gt; changed to &lt;code&gt;&amp;gt; 500&lt;/code&gt;. The one mutant both suites killed empties the function body, so it returns &lt;code&gt;undefined&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;retryDelay&lt;/code&gt;: crashes count.&lt;/strong&gt; &lt;code&gt;runs-only&lt;/code&gt; killed 6 of the 15 &lt;code&gt;retryDelay&lt;/code&gt; mutants without checking a value. Five made a valid call throw, such as &lt;code&gt;attempt &amp;lt; 1&lt;/code&gt; changed to &lt;code&gt;attempt &amp;lt;= 1&lt;/code&gt;, and one returned &lt;code&gt;undefined&lt;/code&gt;. A test fails when the code under it crashes, even if the test checks nothing. That is why a suite that only calls the code still scores above 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;type-checks&lt;/code&gt; killed 11 of the 15 &lt;code&gt;retryDelay&lt;/code&gt; mutants.&lt;/strong&gt; These 4 survived:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Math.min&lt;/code&gt; changed to &lt;code&gt;Math.max&lt;/code&gt;: the cap becomes a minimum, so every delay is at least &lt;code&gt;maxMs&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;*&lt;/code&gt; changed to &lt;code&gt;/&lt;/code&gt;: the delay shrinks on each attempt.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;attempt - 1&lt;/code&gt; changed to &lt;code&gt;attempt + 1&lt;/code&gt;: every delay is 4 times longer, up to the cap.&lt;/li&gt;
&lt;li&gt;The error message emptied: &lt;code&gt;toThrow()&lt;/code&gt; with no argument passes on any error.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these still returns a number above 0, so "greater than 0" passes. &lt;code&gt;exact-values&lt;/code&gt; kills all 38, because each test names the value it expects.&lt;/p&gt;

&lt;p&gt;Every surviving mutant, with its line and its replacement, is in &lt;a href="https://github.com/qa-gary-parker/poc-coverage-vs-mutation-score/blob/main/results/summary.md" rel="noopener noreferrer"&gt;&lt;code&gt;results/summary.md&lt;/code&gt;&lt;/a&gt;. The Stryker HTML report for each suite is in &lt;code&gt;results/&amp;lt;suite&amp;gt;/mutation.html&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run it on your code
&lt;/h2&gt;

&lt;p&gt;Stryker needs a test runner plugin. For Vitest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i -D @stryker-mutator/core @stryker-mutator/vitest-runner
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PoC's &lt;code&gt;stryker.config.mjs&lt;/code&gt; adds a &lt;code&gt;SUITE&lt;/code&gt; switch to compare suites. Without it, the config is:&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;testRunner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'vitest'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;mutate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'src/**/*.ts'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;coverageAnalysis&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'perTest'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;reporters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'clear-text'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'json'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'html'&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;Then &lt;code&gt;npx stryker run&lt;/code&gt;. It prints a score per file and writes the HTML report to &lt;code&gt;reports/mutation/mutation.html&lt;/code&gt;. Start with one module where a wrong boundary costs money or pages someone, not the whole repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The first version of the measure script reported that two Stryker runs differed. Every mutant had the same status in both runs; only the order of the mutants in the JSON report changed. The script now sorts survivors by line and column before it compares the runs.&lt;/li&gt;
&lt;li&gt;A suite that only calls the code still kills some mutants, because a crash fails the test. The &lt;code&gt;runs-only&lt;/code&gt; score is 18.42%, not 0%.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Limits: one small module, hand-written suites, and Stryker's default mutators. Real suites mix all three styles. Each suite ran under Stryker twice, and every mutant had the same status both times.&lt;/p&gt;

&lt;p&gt;Coverage tells you the code ran. A mutation score tells you the tests would notice if it were wrong. &lt;a href="https://garyparker.dev/blog/mutation-testing-ai-generated-tests" rel="noopener noreferrer"&gt;Chapter 2&lt;/a&gt; runs the same check on a suite an AI agent wrote for itself.&lt;/p&gt;

&lt;p&gt;Everything above is reproducible: &lt;a href="https://github.com/qa-gary-parker/poc-coverage-vs-mutation-score" rel="noopener noreferrer"&gt;qa-gary-parker/poc-coverage-vs-mutation-score&lt;/a&gt;. Measured with StrykerJS 10.1.1 and Vitest 5.1.2.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://garyparker.dev/blog/coverage-vs-mutation-score" rel="noopener noreferrer"&gt;https://garyparker.dev/blog/coverage-vs-mutation-score&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>mutationtesting</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Sharing Playwright Traces Safely: One Sign-in, 7 Copies of the Password</title>
      <dc:creator>Gary Parker</dc:creator>
      <pubDate>Mon, 30 Nov 2026 12:17:36 +0000</pubDate>
      <link>https://dev.to/garyparker/sharing-playwright-traces-safely-one-sign-in-7-copies-of-the-password-4i78</link>
      <guid>https://dev.to/garyparker/sharing-playwright-traces-safely-one-sign-in-7-copies-of-the-password-4i78</guid>
      <description>&lt;p&gt;A Playwright trace records every action, page and request of a test. That makes it a copy of every secret the test touched. In a 4-test suite with 4 fake secrets, one sign-in test left the password in its trace 7 times. The session cookie was in the traces 27 times, and the HTML report carried all of it again.&lt;/p&gt;

&lt;p&gt;This guide shows what each artifact holds, how to open a trace, and two ways to share one safely: record less, or scrub with &lt;a href="https://garyparker.dev/projects/tracescrub" rel="noopener noreferrer"&gt;tracescrub&lt;/a&gt;, a tool I maintain. Scrubbing removed every text copy, and the trace still opened. It did not touch the screenshots, and a scrubbed frame still shows the API key. The app, the tests, the counter, the workflow and the raw output are in &lt;a href="https://github.com/qa-gary-parker/poc-playwright-sharing-traces-safely" rel="noopener noreferrer"&gt;the PoC repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The suite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A sign-in page and an account page, served by a small Node server that Playwright starts with &lt;code&gt;webServer&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;4 fake secrets: the password typed into the form, a &lt;code&gt;session&lt;/code&gt; cookie, a bearer token (in the login response, &lt;code&gt;localStorage&lt;/code&gt; and the &lt;code&gt;Authorization&lt;/code&gt; header) and an API key that the account page shows.&lt;/li&gt;
&lt;li&gt;4 tests: a setup test signs in and saves &lt;code&gt;storageState&lt;/code&gt; to &lt;code&gt;playwright/.auth/user.json&lt;/code&gt;, and 3 account tests reuse it. One account test records a HAR file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;trace: 'on'&lt;/code&gt; and the HTML reporter. Playwright 1.65.1 with Chromium, Node v24.14.1, macOS on arm64.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To count the secrets, &lt;code&gt;scripts/count.mjs&lt;/code&gt; unpacks every zip with &lt;code&gt;unzip&lt;/code&gt;, unpacks the zip that the HTML report embeds in &lt;code&gt;index.html&lt;/code&gt;, and searches for each value in plain text and in base64. It does not use tracescrub, so the counts before and after scrubbing come from the same independent check.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the artifacts hold
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Artifact&lt;/th&gt;
&lt;th&gt;Password&lt;/th&gt;
&lt;th&gt;Session cookie&lt;/th&gt;
&lt;th&gt;Bearer token&lt;/th&gt;
&lt;th&gt;API key&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;4 &lt;code&gt;trace.zip&lt;/code&gt; files&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;27&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTML report (&lt;code&gt;playwright-report/&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;27&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HAR file&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;storageState&lt;/code&gt; file&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A trace is a zip. These are the places in it that held a secret:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;N-trace.trace&lt;/code&gt;, the action log. The password is in the &lt;code&gt;fill&lt;/code&gt; parameters, in the &lt;code&gt;fill("...")&lt;/code&gt; log line and in the input's value in the DOM snapshots: 4 copies. The API key is in the text of the DOM snapshots: 4 copies. The setup test's action log also has the cookie and the token, in the result of its &lt;code&gt;storageState()&lt;/code&gt; call.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;test.trace&lt;/code&gt;, the test steps. The &lt;code&gt;Fill&lt;/code&gt; step has the password in its title, &lt;code&gt;Fill "correct-horse-7319"&lt;/code&gt;, and in its value: 2 copies.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;N-trace.network&lt;/code&gt;, the network log. The cookie and the token are in the request and response headers: 30 copies.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;resources/&lt;/code&gt;, the request and response bodies. The login request body has the password, and the &lt;code&gt;/api/me&lt;/code&gt; responses have the API key. The login response has the token, but the trace kept that body in only 4 of 6 runs, and not in the measured one.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;screencast/&lt;/code&gt;, the screenshots of the page. A frame of the account page shows the API key.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The HTML report holds the same 4 traces under &lt;code&gt;data/&lt;/code&gt;, plus the &lt;code&gt;Fill "..."&lt;/code&gt; step title in &lt;code&gt;index.html&lt;/code&gt;. Upload the report as a CI artifact and every one of those copies goes with it.&lt;/p&gt;

&lt;p&gt;The HAR file has the cookie in all 3 requests, as a header and in the cookies list. The token is in the &lt;code&gt;Authorization&lt;/code&gt; header of the &lt;code&gt;/api/me&lt;/code&gt; request, and the API key is in its response. The &lt;code&gt;storageState&lt;/code&gt; file has the cookie and the token in plain JSON. The 3 account tests load that file and start signed in; anyone with the file can do the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  Open a trace
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx playwright show-report
npx playwright show-trace test-results/&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;test&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/trace.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;show-report&lt;/code&gt; opens the HTML report, and each test links its trace. &lt;code&gt;show-trace&lt;/code&gt; opens one trace in the trace viewer.&lt;/p&gt;

&lt;p&gt;Since 1.59, Playwright can also read a trace from the terminal. Coding agents use this, so it is one more reader of your traces:&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 trace open test-results/&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;test&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/trace.zip
npx playwright trace actions
npx playwright trace close
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;trace open&lt;/code&gt; prints a summary: the title, the action count, the requests and the errors. &lt;code&gt;trace actions&lt;/code&gt; lists each action.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option 1: record less
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;trace&lt;/code&gt; option takes an object. This config keeps the action log and turns off the DOM snapshots and the screenshots:&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="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;trace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'on'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;snapshots&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;screenshots&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&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;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Artifact&lt;/th&gt;
&lt;th&gt;Password&lt;/th&gt;
&lt;th&gt;Session cookie&lt;/th&gt;
&lt;th&gt;Bearer token&lt;/th&gt;
&lt;th&gt;API key&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;4 &lt;code&gt;trace.zip&lt;/code&gt; files&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTML report&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;No screenshots, and no API key in the traces.&lt;/li&gt;
&lt;li&gt;No network log either. The type docs say the &lt;code&gt;dom&lt;/code&gt; snapshot option will "capture DOM snapshot on every action and record network activity". With it off, &lt;code&gt;trace open&lt;/code&gt; reports 0 requests.&lt;/li&gt;
&lt;li&gt;The password is still there 4 times: the &lt;code&gt;fill&lt;/code&gt; parameters, the &lt;code&gt;fill("...")&lt;/code&gt; log line, and the title and value of the &lt;code&gt;Fill&lt;/code&gt; step. The cookie and the token are still in the result of the setup test's &lt;code&gt;storageState()&lt;/code&gt; call.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Recording less cuts the copies but does not remove them, and it takes away the DOM and network views you wanted the trace for.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option 2: scrub with tracescrub
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i -D pw-tracescrub
npx tracescrub check test-results playwright-report
npx tracescrub scrub test-results playwright-report playwright/.auth --out scrubbed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;check&lt;/code&gt; reports each secret with a masked preview and exits 1 if it finds one, or if some text content could not be scanned. Images do not count: they produce a note, not a failure. &lt;code&gt;scrub&lt;/code&gt; writes copies with &lt;code&gt;[REDACTED:&amp;lt;rule&amp;gt;]&lt;/code&gt; in place of each secret, or rewrites the files with &lt;code&gt;--in-place&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Run&lt;/th&gt;
&lt;th&gt;Text copies left&lt;/th&gt;
&lt;th&gt;Findings&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;scrub&lt;/code&gt;, no options&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;105&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;scrub --no-propagate&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1 password and 4 API keys in the traces, the same in the report&lt;/td&gt;
&lt;td&gt;95&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;scrub --env DEMO_PASSWORD,...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;105&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;With no options, the scrub removed every text copy of all 4 secrets, in all 4 artifact types.&lt;/li&gt;
&lt;li&gt;It finds a secret by its structure first: a &lt;code&gt;fill&lt;/code&gt; into a password field, an &lt;code&gt;Authorization&lt;/code&gt; header, a &lt;code&gt;Set-Cookie&lt;/code&gt; header, a JSON key named &lt;code&gt;apiKey&lt;/code&gt;. It then removes the same value everywhere else. That second step is called propagation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--no-propagate&lt;/code&gt; shows why it matters. Without it, the &lt;code&gt;fill("...")&lt;/code&gt; log line kept the password, and the DOM snapshots kept the API key as page text.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--env&lt;/code&gt; with the 4 variable names removed the same copies. In this app every secret also had a structure that tracescrub knows. A secret with no such structure, in a place it does not parse, is only found by value, so pass &lt;code&gt;--env&lt;/code&gt; or &lt;code&gt;--env-file&lt;/code&gt; anyway.&lt;/li&gt;
&lt;li&gt;All 4 scrubbed traces opened with &lt;code&gt;npx playwright trace open&lt;/code&gt; and showed the same action count as the raw traces.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The images are the gap. The measured run had 18 screencast frames. tracescrub does not scan images and says so in its output: &lt;code&gt;36 image/media entries were not scanned&lt;/code&gt; (18 frames, once in the traces and once in the report). After the scrub, the last frame of the API key test still shows the key (&lt;a href="https://github.com/qa-gary-parker/poc-playwright-sharing-traces-safely/blob/main/results/default/scrubbed-frame.jpeg" rel="noopener noreferrer"&gt;the frame&lt;/a&gt;). The tracescrub README says it does not scan images, fonts, audio or video, so the same applies to the &lt;code&gt;screenshot&lt;/code&gt; and &lt;code&gt;video&lt;/code&gt; options.&lt;/p&gt;

&lt;h2&gt;
  
  
  The workflow
&lt;/h2&gt;

&lt;p&gt;These are the steps from the workflow in the repo. It scrubs the report in place, checks it, and only then uploads it. The job's &lt;code&gt;env&lt;/code&gt; sets the 4 variables; in your repo they come from &lt;code&gt;secrets&lt;/code&gt;:&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;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;DEMO_PASSWORD&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.DEMO_PASSWORD }}&lt;/span&gt;
  &lt;span class="c1"&gt;# ...and the other 3
&lt;/span&gt;&lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx playwright test&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="s"&gt;Scrub secrets from the report&lt;/span&gt;
  &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ !cancelled() }}&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;npx tracescrub scrub playwright-report --in-place --env DEMO_PASSWORD,DEMO_SESSION,DEMO_API_TOKEN,DEMO_API_KEY&lt;/span&gt;
    &lt;span class="s"&gt;npx tracescrub check playwright-report --env DEMO_PASSWORD,DEMO_SESSION,DEMO_API_TOKEN,DEMO_API_KEY&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/upload-artifact@v7&lt;/span&gt;
  &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ !cancelled() }}&lt;/span&gt;
  &lt;span class="na"&gt;with&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="s"&gt;playwright-report&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;playwright-report/&lt;/span&gt;
    &lt;span class="na"&gt;retention-days&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;if: ${{ !cancelled() }}&lt;/code&gt; runs the scrub and the upload when tests fail, which is when you need the report.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;check&lt;/code&gt; after &lt;code&gt;scrub&lt;/code&gt; fails the job if anything is left, so an unscrubbed report is never uploaded.&lt;/li&gt;
&lt;li&gt;It uploads &lt;code&gt;playwright-report/&lt;/code&gt; only, never &lt;code&gt;playwright/.auth/&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In GitHub Actions (&lt;a href="https://github.com/qa-gary-parker/poc-playwright-sharing-traces-safely/blob/main/results/ci/main.txt" rel="noopener noreferrer"&gt;job log&lt;/a&gt;), the scrub removed 49 findings from the report, &lt;code&gt;check&lt;/code&gt; found none, and the upload ran. &lt;code&gt;check&lt;/code&gt; passed with &lt;code&gt;15 image/media entries were not scanned&lt;/code&gt;: a clean check does not mean clean screenshots.&lt;/p&gt;

&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One small app with 4 secrets that I planted and knew. A real suite has secrets you did not plan for, and the count is only as good as the list of values you search for.&lt;/li&gt;
&lt;li&gt;tracescrub does not scan images. The API key on the account page survives in the screenshots whatever you scrub.&lt;/li&gt;
&lt;li&gt;Recording less is not a fix on its own. The password stayed in the step title and the action log with snapshots and screenshots off.&lt;/li&gt;
&lt;li&gt;The token count changed between runs: 6 in 4 of 6 runs, 5 in the measured one. The sign-in page leaves as soon as it reads the login response, and the trace did not always keep that body.&lt;/li&gt;
&lt;li&gt;I did not test &lt;code&gt;retain-on-failure&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'd do
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Scrub before every upload, and run &lt;code&gt;check&lt;/code&gt; after the scrub so the job fails if a secret is left.&lt;/li&gt;
&lt;li&gt;Pass the names of your test secrets with &lt;code&gt;--env&lt;/code&gt;, even when the patterns find them.&lt;/li&gt;
&lt;li&gt;Never upload &lt;code&gt;storageState&lt;/code&gt; files. They are a signed-in session.&lt;/li&gt;
&lt;li&gt;Keep secrets off the pages your tests screenshot: use test accounts whose keys are not shown, or mask them in the app's test mode.&lt;/li&gt;
&lt;li&gt;Give test accounts their own credentials, with no access to real data, and rotate them. Then a leaked trace leaks a test account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the tool itself, see &lt;a href="https://garyparker.dev/projects/tracescrub" rel="noopener noreferrer"&gt;tracescrub&lt;/a&gt;. The app, the tests, the counter and the raw results: &lt;a href="https://github.com/qa-gary-parker/poc-playwright-sharing-traces-safely" rel="noopener noreferrer"&gt;poc-playwright-sharing-traces-safely&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://garyparker.dev/blog/sharing-playwright-traces-safely" rel="noopener noreferrer"&gt;https://garyparker.dev/blog/sharing-playwright-traces-safely&lt;/a&gt;&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>ci</category>
      <category>github</category>
    </item>
    <item>
      <title>Self-Healing Tests: What the Vendors Aren't Telling You</title>
      <dc:creator>Gary Parker</dc:creator>
      <pubDate>Mon, 30 Nov 2026 10:53:33 +0000</pubDate>
      <link>https://dev.to/garyparker/self-healing-tests-what-the-vendors-arent-telling-you-59og</link>
      <guid>https://dev.to/garyparker/self-healing-tests-what-the-vendors-arent-telling-you-59og</guid>
      <description>&lt;p&gt;Every 2026 trend report leads with self-healing test automation. The pitch is always the same: your UI changes, your tests fix themselves, locator maintenance disappears from your backlog. It's the loudest claim in test tooling right now, and almost nobody selling it publishes numbers.&lt;/p&gt;

&lt;p&gt;So I ran the experiment. Everything below comes from &lt;a href="https://github.com/qa-gary-parker/poc-self-healing-selectors" rel="noopener noreferrer"&gt;a public PoC repo&lt;/a&gt; you can rerun yourself. Spoiler: the healer performed &lt;em&gt;better&lt;/em&gt; than I expected — and the sales pitch still doesn't survive contact with the data.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;A small task-manager app in three versions, simulating two releases of realistic drift:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;v1 → v2&lt;/strong&gt;: a redesign sprint. Every id and class renamed, two buttons become icon buttons (their accessible names change), one &lt;code&gt;data-testid&lt;/code&gt; renamed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;v2 → v3&lt;/strong&gt;: a CSS-modules migration. Every class hashed, ids regenerated — but accessible names and test-ids untouched.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Behaviour is identical across all three. Only the markup drifts — the failure mode self-healing exists to solve.&lt;/p&gt;

&lt;p&gt;Against v1, I wrote the same 7 scenarios three times, differing only in locator strategy: &lt;strong&gt;CSS-legacy&lt;/strong&gt; (ids and classes, the way most real suites are written), &lt;strong&gt;ARIA-first&lt;/strong&gt; (roles, labels, accessible names), and &lt;strong&gt;test-ids&lt;/strong&gt;. The healer is Playwright's official test-healer agent, run headless.&lt;/p&gt;

&lt;h2&gt;
  
  
  What two releases of drift did
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Suite&lt;/th&gt;
&lt;th&gt;v1&lt;/th&gt;
&lt;th&gt;v2 (redesign)&lt;/th&gt;
&lt;th&gt;v3 (CSS-modules)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CSS legacy&lt;/td&gt;
&lt;td&gt;7/7&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0/7&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;0/7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ARIA-first&lt;/td&gt;
&lt;td&gt;7/7&lt;/td&gt;
&lt;td&gt;5/7&lt;/td&gt;
&lt;td&gt;5/7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;test-ids&lt;/td&gt;
&lt;td&gt;7/7&lt;/td&gt;
&lt;td&gt;6/7&lt;/td&gt;
&lt;td&gt;6/7&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Note the CSS suite's failure mode: not degradation, annihilation. The login form's three selectors alone took out all seven tests, because every test logs in first. If your suite shares brittle fixtures — and every real suite shares fixtures — locator debt doesn't accumulate linearly. It detonates.&lt;/p&gt;

&lt;h2&gt;
  
  
  The healer is genuinely good
&lt;/h2&gt;

&lt;p&gt;Round one: I pointed the healer at the 10 failures against v2. It repaired &lt;strong&gt;all 10 in 4 minutes 36 seconds&lt;/strong&gt;, zero incorrect fixes, zero flaky repairs. It debugged each failure against the live page, found the renamed element, and updated the locator.&lt;/p&gt;

&lt;p&gt;It even respected each suite's idiom — CSS selectors were repaired as CSS selectors, accessible names as accessible names, test-ids as test-ids. It read the suite's style and stayed in its lane. As a tool, this is impressive and I want to be fair to it: &lt;strong&gt;the healer did its job perfectly.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Which is exactly the problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The finding the demos won't show you
&lt;/h2&gt;

&lt;p&gt;Then I ran the freshly-healed suite against v3 — the &lt;em&gt;next&lt;/em&gt; release:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Healed suite (repaired at v2)&lt;/th&gt;
&lt;th&gt;vs v3&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CSS legacy&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0/7 — all broken again&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ARIA-first&lt;/td&gt;
&lt;td&gt;7/7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;test-ids&lt;/td&gt;
&lt;td&gt;7/7&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The healed CSS suite survived exactly one release. &lt;code&gt;#username&lt;/code&gt; had been faithfully repaired to &lt;code&gt;#field-user&lt;/code&gt;, which promptly became &lt;code&gt;#fld_9a2b&lt;/code&gt;. Round two of healing took another 3 minutes 23 seconds and repaired all seven again — this time to hashed CSS-modules classnames like &lt;code&gt;.Login_submit__w6f4&lt;/code&gt;. The ARIA and test-id suites, healed once, never needed touching again.&lt;/p&gt;

&lt;p&gt;And here's my favourite detail of the whole experiment. The healer &lt;em&gt;knew&lt;/em&gt;. Its own round-two report ends with a warning that the repaired classnames are "stable for this build but likely to regenerate on the next rebuild, so this legacy-selector suite remains structurally fragile." The healer diagnosed the disease, then prescribed another dose — because translation is the only move it has. No vendor demo will ever show you that sentence.&lt;/p&gt;

&lt;p&gt;This is the mechanism the marketing leaves out: &lt;strong&gt;a healer restores your suite to exactly the fragility it had before.&lt;/strong&gt; It's a locator-translation machine, not a quality-improvement machine. Feed it brittleness and you get freshly-broken brittleness back next release — forever. The vendors call this "eliminating test maintenance." It's actually a subscription: healing services your locator debt, on every release, without ever paying down the principal.&lt;/p&gt;

&lt;p&gt;Count the repairs across two releases: the CSS suite consumed &lt;strong&gt;14 healing repairs&lt;/strong&gt;. The ARIA-first suite needed 2. The test-id suite needed 1. Locator strategy — the boring, decade-old advice — did more for maintenance cost than the AI did.&lt;/p&gt;

&lt;h2&gt;
  
  
  The subtler problem: healing can eat signal
&lt;/h2&gt;

&lt;p&gt;Look at &lt;em&gt;what&lt;/em&gt; broke in the ARIA suite: two buttons whose accessible names changed when they became icon buttons (&lt;code&gt;Done&lt;/code&gt; → &lt;code&gt;Complete&lt;/code&gt;, &lt;code&gt;Add&lt;/code&gt; → &lt;code&gt;Add task&lt;/code&gt;). The healer silently repaired both.&lt;/p&gt;

&lt;p&gt;But an accessible-name change is a user-facing change. Screen-reader users experience it. A test failing on it is arguably doing its job — surfacing that the redesign altered what users perceive. A healer that auto-repairs it has quietly decided, on your behalf, that this change doesn't matter. Same for the renamed &lt;code&gt;data-testid&lt;/code&gt;: that's a broken contract between the app and the suite, and the right fix might be in the app, not the test. Healing makes both failures disappear without anyone deciding anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verdict
&lt;/h2&gt;

&lt;p&gt;Three things I'd want any team to take from the numbers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Buy the tool, not the pitch.&lt;/strong&gt; Playwright's healer is fast, accurate, and honest about its work — as a &lt;em&gt;proposer&lt;/em&gt; of fixes in a PR, it's genuinely useful. The claim that self-healing eliminates test maintenance is what fails the measurement.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Healing is a complement to locator strategy, not a substitute.&lt;/strong&gt; If the healer keeps repairing the same suite every release, that's not the tool working — that's a dashboard telling you where your locator debt lives. The fix for &lt;code&gt;#username&lt;/code&gt; isn't &lt;code&gt;#field-user&lt;/code&gt;; it's &lt;code&gt;getByLabel('Username')&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep a human on the loop for &lt;em&gt;why&lt;/em&gt; it broke.&lt;/strong&gt; Some failures are drift. Some are the app changing what users actually experience. Only one of those should be silently repaired, and the healer can't tell them apart.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is the same conclusion the &lt;a href="https://garyparker.dev/blog/hands-on-with-playwright-test-agents" rel="noopener noreferrer"&gt;Playwright test agents experiment&lt;/a&gt; reached from the other side: healed code preserves the quality level of the code that broke. AI removes the toil from test maintenance — it doesn't remove the judgment. That division of labour is the thread running through &lt;a href="https://garyparker.dev/playbook" rel="noopener noreferrer"&gt;the playbook&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Everything here is reproducible: &lt;a href="https://github.com/qa-gary-parker/poc-self-healing-selectors" rel="noopener noreferrer"&gt;qa-gary-parker/poc-self-healing-selectors&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://garyparker.dev/blog/self-healing-tests-what-vendors-arent-telling-you" rel="noopener noreferrer"&gt;https://garyparker.dev/blog/self-healing-tests-what-vendors-arent-telling-you&lt;/a&gt;&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>ai</category>
      <category>automation</category>
    </item>
    <item>
      <title>Running Only the Affected Playwright Tests on a Pull Request: 4 Bugs That Exited 0</title>
      <dc:creator>Gary Parker</dc:creator>
      <pubDate>Sat, 28 Nov 2026 20:56:33 +0000</pubDate>
      <link>https://dev.to/garyparker/running-only-the-affected-playwright-tests-on-a-pull-request-4-bugs-that-exited-0-4nbb</link>
      <guid>https://dev.to/garyparker/running-only-the-affected-playwright-tests-on-a-pull-request-4-bugs-that-exited-0-4nbb</guid>
      <description>&lt;p&gt;Playwright can run only the tests a pull request changed, with one flag. On 8 seeded pull requests against a 12-test suite, &lt;code&gt;--only-changed&lt;/code&gt; caught 13 of the 27 tests the bugs broke. In 5 of the 8 pull requests it ran 0 tests, printed nothing and exited 0. 4 of those 5 had a bug that failed between 1 and 9 tests on the full suite.&lt;/p&gt;

&lt;p&gt;This guide sets up both ways to run only the affected tests on a pull request: Playwright's &lt;code&gt;--only-changed&lt;/code&gt;, and a map with &lt;a href="https://garyparker.dev/projects/playwright-affected" rel="noopener noreferrer"&gt;playwright-affected&lt;/a&gt;, a tool I maintain. The map caught 27 of 27 and ran 67 of the 96 tests the full suite ran. The shop, the tests, the map, the workflow and the raw output of every run are in &lt;a href="https://github.com/qa-gary-parker/poc-playwright-affected-tests-pr" rel="noopener noreferrer"&gt;the PoC repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The suite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A small static shop in &lt;code&gt;app/&lt;/code&gt;: search, cart and checkout in three JavaScript files, a stylesheet, and a static file server that Playwright starts with &lt;code&gt;webServer&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;12 tests in 4 spec files, one tag per file: &lt;code&gt;@search&lt;/code&gt; (3), &lt;code&gt;@cart&lt;/code&gt; (3), &lt;code&gt;@checkout&lt;/code&gt; (4) and &lt;code&gt;@smoke&lt;/code&gt; (2).&lt;/li&gt;
&lt;li&gt;The search, cart and checkout specs use page objects in &lt;code&gt;tests/pages/&lt;/code&gt;. Every page object extends &lt;code&gt;base-page.ts&lt;/code&gt;. The smoke spec uses no page object.&lt;/li&gt;
&lt;li&gt;Playwright 1.65.1 with Chromium, playwright-affected 0.1.2, Node v24.14.1, macOS on arm64. &lt;code&gt;workers: 4&lt;/code&gt;, no retries.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each scenario is one commit on top of &lt;code&gt;main&lt;/code&gt;, and &lt;code&gt;main&lt;/code&gt; is the base for both methods. 7 of the 8 commits add a bug:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Scenario&lt;/th&gt;
&lt;th&gt;Changed file&lt;/th&gt;
&lt;th&gt;The change&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;test-edit&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tests/search.spec.ts&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A spec edit with a wrong expectation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;page-object&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tests/pages/checkout-page.ts&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A page object with a wrong locator&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;base-page&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tests/pages/base-page.ts&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The base page opens the wrong URL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;app-checkout&lt;/td&gt;
&lt;td&gt;&lt;code&gt;app/checkout.js&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The coupon comes off as pounds, not percent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;app-search&lt;/td&gt;
&lt;td&gt;&lt;code&gt;app/search.js&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Search shows only the first 3 products&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;app-css&lt;/td&gt;
&lt;td&gt;&lt;code&gt;app/styles.css&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A rule hides the Place order button&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;config&lt;/td&gt;
&lt;td&gt;&lt;code&gt;playwright.config.ts&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;JavaScript is turned off for every test&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;docs&lt;/td&gt;
&lt;td&gt;&lt;code&gt;README.md&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A README edit only&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Every scenario ran three ways: the full suite, &lt;code&gt;--only-changed&lt;/code&gt;, and playwright-affected. "Broken" means a test failed on the full suite. "Caught" means the method ran that test and saw it fail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option 1: --only-changed
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;--only-changed&lt;/code&gt; takes a git ref and runs the test files that changed between that ref and &lt;code&gt;HEAD&lt;/code&gt;, plus the test files that import a changed file:&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; --only-changed=origin/main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On a pull request in GitHub Actions, check out the full history so the base branch is there:&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="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v7&lt;/span&gt;
  &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;fetch-depth&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="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx playwright test --only-changed=origin/$GITHUB_BASE_REF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The results:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Scenario&lt;/th&gt;
&lt;th&gt;Full suite&lt;/th&gt;
&lt;th&gt;&lt;code&gt;--only-changed&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;test-edit&lt;/td&gt;
&lt;td&gt;12 run, 1 failed&lt;/td&gt;
&lt;td&gt;3 run, 1 caught, exit 1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;page-object&lt;/td&gt;
&lt;td&gt;12 run, 2 failed&lt;/td&gt;
&lt;td&gt;4 run, 2 caught, exit 1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;base-page&lt;/td&gt;
&lt;td&gt;12 run, 10 failed&lt;/td&gt;
&lt;td&gt;10 run, 10 caught, exit 1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;app-checkout&lt;/td&gt;
&lt;td&gt;12 run, 1 failed&lt;/td&gt;
&lt;td&gt;0 run, 0 caught, exit 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;app-search&lt;/td&gt;
&lt;td&gt;12 run, 2 failed&lt;/td&gt;
&lt;td&gt;0 run, 0 caught, exit 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;app-css&lt;/td&gt;
&lt;td&gt;12 run, 2 failed&lt;/td&gt;
&lt;td&gt;0 run, 0 caught, exit 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;config&lt;/td&gt;
&lt;td&gt;12 run, 9 failed&lt;/td&gt;
&lt;td&gt;0 run, 0 caught, exit 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;docs&lt;/td&gt;
&lt;td&gt;12 run, 0 failed&lt;/td&gt;
&lt;td&gt;0 run, 0 caught, exit 0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;It works for changes inside the test code. A changed spec selected its own file. A changed page object selected the specs that import it: 4 checkout tests for &lt;code&gt;checkout-page.ts&lt;/code&gt;, and 10 tests in 3 spec files for &lt;code&gt;base-page.ts&lt;/code&gt;, which every page object extends. It caught every broken test in those 3 scenarios.&lt;/p&gt;

&lt;p&gt;It does not see the app. The tests reach the shop over HTTP and import nothing from &lt;code&gt;app/&lt;/code&gt;, so the 3 app changes selected 0 tests. That is the normal shape of an end-to-end suite. A change to &lt;code&gt;playwright.config.ts&lt;/code&gt; also selected 0 tests, though it broke 9 of 12.&lt;/p&gt;

&lt;p&gt;The empty runs did not fail. With 0 tests selected, &lt;code&gt;--only-changed&lt;/code&gt; printed nothing and exited 0. Two controls on &lt;code&gt;main&lt;/code&gt; show the difference. A &lt;code&gt;--grep&lt;/code&gt; that matches no test printed &lt;code&gt;Error: No tests found&lt;/code&gt; and exited 1. &lt;code&gt;--only-changed&lt;/code&gt; with no change printed nothing and exited 0. So a pull request that changes only app code gets a green check from a run that tested nothing. The &lt;a href="https://garyparker.dev/blog/playwright-165-empty-shards" rel="noopener noreferrer"&gt;empty shards post&lt;/a&gt; found the same exit 0 on Playwright 1.64.1 and 1.65.1.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://playwright.dev/docs/ci" rel="noopener noreferrer"&gt;Playwright CI docs&lt;/a&gt; call &lt;code&gt;--only-changed&lt;/code&gt; a heuristic that might miss tests. Their example runs it as a first step for fast feedback, then runs the full suite. Used that way, the full suite still runs the tests it skips. Used alone, it missed 14 of 27 broken tests here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option 2: a map with playwright-affected
&lt;/h2&gt;

&lt;p&gt;playwright-affected maps changed files to tags, test paths or Playwright projects, and emits one &lt;code&gt;--grep&lt;/code&gt;. When it cannot decide, it runs the full suite. This is the map for the shop, &lt;code&gt;e2e-map.yml&lt;/code&gt;:&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;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="na"&gt;test_dir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;tests&lt;/span&gt;

&lt;span class="na"&gt;always_run_tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"@smoke"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;full_run_triggers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;package-lock.json&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;playwright.config.ts&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;e2e-map.yml&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;tests/pages/base-page.ts&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;app/server.mjs&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;app/index.html&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;.github/workflows/**&lt;/span&gt;

&lt;span class="na"&gt;ignore_paths&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"**/*.md"&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;scenarios/**&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;scripts/**&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;results/**&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;video/**&lt;/span&gt;

&lt;span class="na"&gt;mappings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="c1"&gt;# cart and checkout tests add items through the search page
&lt;/span&gt;  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"app/search.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"tests/pages/search-page.ts"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"@search"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"@cart"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"@checkout"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"app/cart.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"tests/pages/cart-page.ts"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"@cart"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"@checkout"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"app/checkout.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"tests/pages/checkout-page.ts"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"@checkout"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;unmapped_behavior&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;full&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each changed file goes through the steps in order, and the first match decides:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;full_run_triggers&lt;/code&gt; runs the full suite: the config, the lockfile, the map itself, the base page, the server, &lt;code&gt;index.html&lt;/code&gt; and the workflows.&lt;/li&gt;
&lt;li&gt;A changed spec file selects itself.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ignore_paths&lt;/code&gt; skips the file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mappings&lt;/code&gt; add tags. The app files and their page objects map to the tests that use them.&lt;/li&gt;
&lt;li&gt;Anything else runs the full suite, because &lt;code&gt;unmapped_behavior&lt;/code&gt; is &lt;code&gt;full&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;always_run_tags&lt;/code&gt; adds the 2 &lt;code&gt;@smoke&lt;/code&gt; tests to every selection.&lt;/p&gt;

&lt;p&gt;To run it, list the tests, select, then pass the grep to Playwright:&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="nv"&gt;PLAYWRIGHT_JSON_OUTPUT_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;list.json npx playwright &lt;span class="nb"&gt;test&lt;/span&gt; --list --reporter=json &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null
npx playwright-affected &lt;span class="k"&gt;select&lt;/span&gt; --config e2e-map.yml --base origin/main --list list.json --out result.json
&lt;span class="nv"&gt;GREP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;jq -r &lt;span class="s1"&gt;'.grep // empty'&lt;/span&gt; result.json&lt;span class="o"&gt;)&lt;/span&gt;
npx playwright &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nv"&gt;${GREP:+--grep "$GREP"}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When &lt;code&gt;result.json&lt;/code&gt; has &lt;code&gt;mode: full&lt;/code&gt;, &lt;code&gt;grep&lt;/code&gt; is &lt;code&gt;null&lt;/code&gt;, and the last line runs the full suite.&lt;/p&gt;

&lt;p&gt;The results:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Scenario&lt;/th&gt;
&lt;th&gt;Full suite&lt;/th&gt;
&lt;th&gt;playwright-affected&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;test-edit&lt;/td&gt;
&lt;td&gt;12 run, 1 failed&lt;/td&gt;
&lt;td&gt;5 run, 1 caught (selected)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;page-object&lt;/td&gt;
&lt;td&gt;12 run, 2 failed&lt;/td&gt;
&lt;td&gt;6 run, 2 caught (selected)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;base-page&lt;/td&gt;
&lt;td&gt;12 run, 10 failed&lt;/td&gt;
&lt;td&gt;12 run, 10 caught (full: global_trigger)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;app-checkout&lt;/td&gt;
&lt;td&gt;12 run, 1 failed&lt;/td&gt;
&lt;td&gt;6 run, 1 caught (selected)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;app-search&lt;/td&gt;
&lt;td&gt;12 run, 2 failed&lt;/td&gt;
&lt;td&gt;12 run, 2 caught (selected)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;app-css&lt;/td&gt;
&lt;td&gt;12 run, 2 failed&lt;/td&gt;
&lt;td&gt;12 run, 2 caught (full: unmapped_paths)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;config&lt;/td&gt;
&lt;td&gt;12 run, 9 failed&lt;/td&gt;
&lt;td&gt;12 run, 9 caught (full: global_trigger)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;docs&lt;/td&gt;
&lt;td&gt;12 run, 0 failed&lt;/td&gt;
&lt;td&gt;2 run, 0 caught (selected)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;It caught 27 of 27, and every pull request with a bug exited 1.&lt;/li&gt;
&lt;li&gt;It ran 67 tests across the 8 pull requests; the full suite ran 96.&lt;/li&gt;
&lt;li&gt;It ran all 12 tests in 4 pull requests: twice for a full-run trigger, once for an unmapped file (&lt;code&gt;app/styles.css&lt;/code&gt;), and once because the mapping for &lt;code&gt;app/search.js&lt;/code&gt; selects all 4 tags.&lt;/li&gt;
&lt;li&gt;The docs-only pull request ran the 2 smoke tests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The app-search row shows why the map has the search page selecting cart and checkout tests too. Showing only 3 products broke &lt;code&gt;applies a coupon&lt;/code&gt;, a checkout test, because it adds the 4th product. A map that sent &lt;code&gt;app/search.js&lt;/code&gt; to &lt;code&gt;@search&lt;/code&gt; alone would have missed it.&lt;/p&gt;

&lt;p&gt;The app-css row shows the safety net. Nobody mapped the stylesheet, so the change ran the full suite and caught both broken checkout tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  The workflow
&lt;/h2&gt;

&lt;p&gt;This is the workflow in the repo. On a pull request, it selects and runs the affected tests. On &lt;code&gt;main&lt;/code&gt;, there is no &lt;code&gt;result.json&lt;/code&gt;, so it runs the full suite:&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="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Playwright Tests&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;main&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;pull_request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;main&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;workflow_dispatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;playwright-tests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="p"&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="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v7&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="c1"&gt;# select diffs against the base branch, so it needs the history
&lt;/span&gt;          &lt;span class="na"&gt;fetch-depth&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="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/setup-node@v7&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;node-version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;lts/*&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm ci&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx playwright install --with-deps chromium&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="s"&gt;Select the affected tests&lt;/span&gt;
        &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github.event_name == 'pull_request'&lt;/span&gt;
        &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;BASE_REF&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ github.base_ref }}&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;rm -f result.json&lt;/span&gt;
          &lt;span class="s"&gt;PLAYWRIGHT_JSON_OUTPUT_NAME=list.json npx playwright test --list --reporter=json &amp;gt; /dev/null&lt;/span&gt;
          &lt;span class="s"&gt;npx playwright-affected select --config e2e-map.yml --base "origin/$BASE_REF" --list list.json --out result.json&lt;/span&gt;
          &lt;span class="s"&gt;jq '{mode, full_reason, selected, total, grep}' result.json&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="s"&gt;Run the affected tests, or all of them on main&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;GREP=""&lt;/span&gt;
          &lt;span class="s"&gt;if [ -f result.json ]; then GREP=$(jq -r '.grep // empty' result.json); fi&lt;/span&gt;
          &lt;span class="s"&gt;npx playwright test ${GREP:+--grep "$GREP"}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;fetch-depth: 0&lt;/code&gt; gives &lt;code&gt;select&lt;/code&gt; the base branch history.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rm -f result.json&lt;/code&gt; stops a later step from reading a stale selection.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;jq&lt;/code&gt; line prints the mode, the reason for a full run and the counts in the job log, so a reviewer can see what ran and why.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/qa-gary-parker/poc-playwright-affected-tests-pr/pull/1" rel="noopener noreferrer"&gt;Pull request #1&lt;/a&gt; in the repo is the app-checkout bug. In GitHub Actions (&lt;a href="https://github.com/qa-gary-parker/poc-playwright-affected-tests-pr/blob/main/results/ci/pr-1.txt" rel="noopener noreferrer"&gt;job log&lt;/a&gt;), &lt;code&gt;select&lt;/code&gt; chose 6 of 12 tests, and &lt;code&gt;applies a coupon&lt;/code&gt; failed: the total was &lt;code&gt;£23.90&lt;/code&gt;, where the test expects &lt;code&gt;£21.60&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One 12-test suite with one tag per spec file, and a map written for this app with all of it in view. A real map starts with fewer files mapped, so more pull requests run the full suite.&lt;/li&gt;
&lt;li&gt;The map is only as good as the person who writes it. The app-search row caught both broken tests only because I knew the checkout tests use the search page.&lt;/li&gt;
&lt;li&gt;Each scenario changes one file. Larger pull requests touch more mappings, and any unmapped file runs the full suite.&lt;/li&gt;
&lt;li&gt;I did not compare wall times. The matrix ran once, and each run is mostly browser and server start-up.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'd do
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Never use &lt;code&gt;--only-changed&lt;/code&gt; as the only test run on a pull request. Run it first for fast feedback, then the full suite, as the Playwright docs show.&lt;/li&gt;
&lt;li&gt;For a selection you can trust on its own, map the app to tags and keep &lt;code&gt;unmapped_behavior: full&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Put the config, the lockfile, shared page objects and the map itself in &lt;code&gt;full_run_triggers&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Keep the full suite on &lt;code&gt;main&lt;/code&gt; or the merge queue, and on a schedule.&lt;/li&gt;
&lt;li&gt;Before you make selection blocking, run it in shadow mode next to the full suite. The &lt;a href="https://github.com/qa-gary-parker/playwright-affected#shadow-mode" rel="noopener noreferrer"&gt;playwright-affected README&lt;/a&gt; has the steps.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For selection on a unit-test suite, see &lt;a href="https://garyparker.dev/blog/code-graph-test-impact-analysis" rel="noopener noreferrer"&gt;Code Graph Test Selection&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The shop, the tests, the map, the workflow and the raw results: &lt;a href="https://github.com/qa-gary-parker/poc-playwright-affected-tests-pr" rel="noopener noreferrer"&gt;poc-playwright-affected-tests-pr&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://garyparker.dev/blog/run-only-affected-playwright-tests-pull-request" rel="noopener noreferrer"&gt;https://garyparker.dev/blog/run-only-affected-playwright-tests-pull-request&lt;/a&gt;&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>ci</category>
      <category>github</category>
    </item>
    <item>
      <title>Code Graph Test Selection: 99.6% of Faults Caught, 3.4% of Suite Time</title>
      <dc:creator>Gary Parker</dc:creator>
      <pubDate>Mon, 23 Nov 2026 13:24:24 +0000</pubDate>
      <link>https://dev.to/garyparker/code-graph-test-selection-996-of-faults-caught-34-of-suite-time-28hh</link>
      <guid>https://dev.to/garyparker/code-graph-test-selection-996-of-faults-caught-34-of-suite-time-28hh</guid>
      <description>&lt;p&gt;A code-intelligence graph can tell you which tests to run for a change, but only its file-level answer is good enough. On hono, &lt;code&gt;code-review-graph impact&lt;/code&gt; picked tests that caught 236 of 237 seeded faults (99.6%) and ran a mean 3.4% of the suite's test time; &lt;code&gt;vitest related&lt;/code&gt; caught all 237 at 16.1%, and the graph's function-level query caught only 146 (61.6%).&lt;/p&gt;

&lt;p&gt;Every script and raw result is in &lt;a href="https://github.com/qa-gary-parker/poc-test-impact-graph" rel="noopener noreferrer"&gt;the PoC repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/tirth8205/code-review-graph" rel="noopener noreferrer"&gt;code-review-graph&lt;/a&gt; builds a local map of a codebase (files, functions, calls, imports, tests) so that AI tools can ask what a change touches. Test selection asks the same question, so I tested it as a test selector against the import graph Vitest already has.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Target: &lt;a href="https://github.com/honojs/hono" rel="noopener noreferrer"&gt;honojs/hono&lt;/a&gt; at &lt;code&gt;a8ae5b1d&lt;/code&gt;. The suite is the Vitest project &lt;code&gt;main&lt;/code&gt;, test files under &lt;code&gt;src/&lt;/code&gt;: 123 files and 5,110 tests, about 5.2 s wall-clock.&lt;/li&gt;
&lt;li&gt;Tools: &lt;code&gt;code-review-graph&lt;/code&gt; 2.4.0, with the graph built once at that commit. Vitest 5.0.1, Node 24.21.0, macOS 15.7.4 on arm64.&lt;/li&gt;
&lt;li&gt;Faults: a script found 1,373 operator sites in 155 source files and drew 300 with a fixed seed, at most 6 per file. Each fault swaps one operator: &lt;code&gt;===&lt;/code&gt;/&lt;code&gt;!==&lt;/code&gt;, &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;/&lt;code&gt;||&lt;/code&gt;, &lt;code&gt;&amp;lt;&lt;/code&gt;/&lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;/&lt;code&gt;&amp;gt;=&lt;/code&gt;, &lt;code&gt;+ 1&lt;/code&gt;/&lt;code&gt;- 1&lt;/code&gt;, &lt;code&gt;true&lt;/code&gt;/&lt;code&gt;false&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Ground truth: apply the fault, run the whole suite, and record the test files that fail. Then run those files again on their own with the fault applied and keep only the files that fail again. No file dropped out in this run.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each selector gets the changed file and returns test files:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Selector&lt;/th&gt;
&lt;th&gt;What it picks&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;impact, depth 1, 2 or 3&lt;/td&gt;
&lt;td&gt;test files in &lt;code&gt;code-review-graph impact --files &amp;lt;file&amp;gt; --depth N&lt;/code&gt;. Depth 2 is the default&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;tests_for&lt;/td&gt;
&lt;td&gt;test files from &lt;code&gt;code-review-graph query tests_for&lt;/code&gt; for each function &lt;code&gt;detect-changes&lt;/code&gt; reports as changed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;vitest related&lt;/td&gt;
&lt;td&gt;the test files &lt;code&gt;vitest related &amp;lt;file&amp;gt;&lt;/code&gt; runs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;same name&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;&amp;lt;file&amp;gt;.test.ts&lt;/code&gt; or &lt;code&gt;&amp;lt;file&amp;gt;.test.tsx&lt;/code&gt;, if it exists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;full&lt;/td&gt;
&lt;td&gt;all 123 test files&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A selector "caught" a fault when it picked at least one failing test file, so CI goes red. It "picked all" when it picked every failing test file. Share of suite time is the sum of the picked files' durations divided by the sum for all files, from the median of 3 clean runs.&lt;/p&gt;

&lt;p&gt;These are the two commands, run from the hono checkout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uvx --python 3.12 code-review-graph@2.4.0 impact --files src/middleware/jwk/jwk.ts
node node_modules/vitest/vitest.mjs related src/middleware/jwk/jwk.ts --run --project main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;impact&lt;/code&gt; prints JSON. Its &lt;code&gt;impacted_files&lt;/code&gt; list holds source and test files, so the harness keeps only the files that are in the suite.&lt;/p&gt;

&lt;h2&gt;
  
  
  The results
&lt;/h2&gt;

&lt;p&gt;Of the 300 faults, 237 made at least one test file fail, 61 made none fail, 1 timed out and 1 did not parse. The last two are excluded. The 237 are in 73 source files, and the median fault broke 1 test file.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Selector&lt;/th&gt;
&lt;th&gt;Caught&lt;/th&gt;
&lt;th&gt;Picked all failing files&lt;/th&gt;
&lt;th&gt;Median test files&lt;/th&gt;
&lt;th&gt;Mean share of suite time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;impact, depth 1&lt;/td&gt;
&lt;td&gt;219 (92.4%)&lt;/td&gt;
&lt;td&gt;162 (68.4%)&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1.3%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;impact, depth 2 (default)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;236 (99.6%)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;198 (83.5%)&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;3.4%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;impact, depth 3&lt;/td&gt;
&lt;td&gt;236 (99.6%)&lt;/td&gt;
&lt;td&gt;203 (85.7%)&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;5.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;tests_for&lt;/td&gt;
&lt;td&gt;146 (61.6%)&lt;/td&gt;
&lt;td&gt;104 (43.9%)&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1.2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;vitest related&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;237 (100%)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;237 (100%)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;16.1%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;same name&lt;/td&gt;
&lt;td&gt;190 (80.2%)&lt;/td&gt;
&lt;td&gt;117 (49.4%)&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;full&lt;/td&gt;
&lt;td&gt;237 (100%)&lt;/td&gt;
&lt;td&gt;237 (100%)&lt;/td&gt;
&lt;td&gt;123&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The default &lt;code&gt;impact&lt;/code&gt; call is the interesting row. It turned CI red for all but one fault and ran about a fifth of the test time &lt;code&gt;vitest related&lt;/code&gt; ran. The cost is completeness: for 38 of the 236 faults it caught, at least one other failing test file was not picked. CI goes red, but the developer sees only part of the damage until the full suite runs.&lt;/p&gt;

&lt;p&gt;Depth 3 picked all failing files for 5 more faults than depth 2 and ran 1.5 points more suite time (4.97% against 3.44%). It missed the same one fault.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fault the graph missed
&lt;/h2&gt;

&lt;p&gt;Fault #218 is in &lt;code&gt;src/adapter/cloudflare-workers/websocket.ts&lt;/code&gt;. The test imports &lt;code&gt;upgradeWebSocket&lt;/code&gt; through the folder's &lt;code&gt;index.ts&lt;/code&gt;, and the changed code is an arrow function passed to &lt;code&gt;defineWebSocketHelper&lt;/code&gt;. For that file &lt;code&gt;impact&lt;/code&gt; returned 0 impacted files at every depth. &lt;code&gt;vitest related&lt;/code&gt; follows the module imports, so it picked the test.&lt;/p&gt;

&lt;p&gt;One more fault counts as caught for a reason worth knowing. Fault #295 (&lt;code&gt;src/middleware/jwk/jwk.ts&lt;/code&gt;, &lt;code&gt;||&lt;/code&gt; to &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;) failed no test. &lt;code&gt;jwk()&lt;/code&gt; now throws its "requires options" error while Vitest collects the tests, so &lt;code&gt;src/middleware/jwk/index.test.ts&lt;/code&gt; fails with a file-level error and no failed test. CI goes red, so it counts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Function-level selection did not hold up
&lt;/h2&gt;

&lt;p&gt;The graph also answers a finer question: which tests cover this function. That would be the bigger saving, so I tried it. For each fault, &lt;code&gt;detect-changes&lt;/code&gt; named the changed functions and &lt;code&gt;query tests_for&lt;/code&gt; returned the tests for each.&lt;/p&gt;

&lt;p&gt;It caught 146 of 237 faults (61.6%). For 58 faults it returned no tests at all, and for 4 of those &lt;code&gt;detect-changes&lt;/code&gt; reported no changed function. An empty selection is the dangerous case: a selector that returns nothing lets CI pass.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real commits
&lt;/h2&gt;

&lt;p&gt;Seeded faults are small, so I also replayed the last 100 hono commits that changed source under &lt;code&gt;src/&lt;/code&gt;. 88 of them also changed test files. There is no fault to catch here, so the check is whether each selector picks the test files the author changed.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Selector&lt;/th&gt;
&lt;th&gt;Median test files&lt;/th&gt;
&lt;th&gt;Mean share of suite time&lt;/th&gt;
&lt;th&gt;Empty selections&lt;/th&gt;
&lt;th&gt;Picked all the author's test files&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;impact, depth 1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;3.8%&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;73 of 88&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;impact, depth 2&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;11.1%&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;83 of 88&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;impact, depth 3&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;11.8%&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;83 of 88&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;vitest related&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;19.1%&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;84 of 88&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;same name&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0.8%&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;60 of 88&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On real commits the gap narrows. Default &lt;code&gt;impact&lt;/code&gt; picked the author's tests in 83 of 88 commits against 84 for &lt;code&gt;vitest related&lt;/code&gt;, at 11.1% of suite time against 19.1%.&lt;/p&gt;

&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The node limit.&lt;/strong&gt; &lt;code&gt;impact&lt;/code&gt; has a default limit of 500 impacted nodes (&lt;code&gt;--max-results&lt;/code&gt;). Among the 73 changed files of caught faults, the impacted node count went over it for &lt;code&gt;src/context.ts&lt;/code&gt; at every depth, and at depth 3 also for &lt;code&gt;src/request.ts&lt;/code&gt;, &lt;code&gt;src/utils/mime.ts&lt;/code&gt; and &lt;code&gt;src/utils/url.ts&lt;/code&gt;. For &lt;code&gt;src/context.ts&lt;/code&gt;, depths 1, 2 and 3 all picked the same 13 test files. I did not measure whether the limit cost any test files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Re-exports and callbacks.&lt;/strong&gt; The one miss had both: the test reached the code through an &lt;code&gt;index.ts&lt;/code&gt; re-export, and the changed code was an arrow function passed to a helper. One case does not show which of the two broke the link.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;tests_for&lt;/code&gt;&lt;/strong&gt; is not a selector on its own. Too many changed functions had no linked test.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One repository, one machine, seeded faults. Operator swaps are smaller than most real changes.&lt;/li&gt;
&lt;li&gt;The graph was built once at the measured commit. The commit replay uses that graph and today's import graph, not the state at each old commit.&lt;/li&gt;
&lt;li&gt;"The author's test files" is a proxy for the tests that matter. One commit (&lt;code&gt;859e2c2&lt;/code&gt;) only moved import sorting to a new tool. It changed 4 source files and 45 test files.&lt;/li&gt;
&lt;li&gt;hono's suite runs in about 5 s, so the time saved here is seconds. The share of suite time is the number that carries over to a larger suite.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'd do with it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If your runner already has an import graph, start there. Short of the full suite, &lt;code&gt;vitest related&lt;/code&gt; was the only selector that picked every failing file, and it needs no extra tool.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;code-review-graph impact&lt;/code&gt; at its default depth when the import graph runs too much, and run the full suite on merge. That is where its 99.6% at 3.4% of suite time is worth the 38 partial picks.&lt;/li&gt;
&lt;li&gt;Treat an empty selection, or an impacted node count over the limit, as "run everything". Do not use the function-level query to select tests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a Playwright suite, &lt;a href="https://garyparker.dev/projects/playwright-affected" rel="noopener noreferrer"&gt;playwright-affected&lt;/a&gt; selects tests from the diff with a map you write, and runs the full suite whenever it cannot decide. The &lt;a href="https://garyparker.dev/blog/mutation-testing-ai-generated-tests" rel="noopener noreferrer"&gt;mutation testing experiment&lt;/a&gt; uses seeded faults in the same way. More measured experiments are in the &lt;a href="https://garyparker.dev/playbook" rel="noopener noreferrer"&gt;playbook&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/qa-gary-parker/poc-test-impact-graph" rel="noopener noreferrer"&gt;qa-gary-parker/poc-test-impact-graph&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://garyparker.dev/blog/code-graph-test-impact-analysis" rel="noopener noreferrer"&gt;https://garyparker.dev/blog/code-graph-test-impact-analysis&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>ci</category>
      <category>ai</category>
      <category>vitest</category>
    </item>
    <item>
      <title>Writing a Custom Playwright Reporter: 8 Failures From 2 Failing Tests</title>
      <dc:creator>Gary Parker</dc:creator>
      <pubDate>Mon, 23 Nov 2026 11:01:22 +0000</pubDate>
      <link>https://dev.to/garyparker/writing-a-custom-playwright-reporter-8-failures-from-2-failing-tests-3bf2</link>
      <guid>https://dev.to/garyparker/writing-a-custom-playwright-reporter-8-failures-from-2-failing-tests-3bf2</guid>
      <description>&lt;p&gt;A custom Playwright reporter takes about 26 lines, but the obvious way to count failures in it is wrong. On a 13-test suite with 2 failing tests, a reporter that counted failed results in &lt;code&gt;onTestEnd&lt;/code&gt; reported 8 failures, in 5 of 5 runs.&lt;/p&gt;

&lt;p&gt;I wrote a minimal reporter, then measured four places where the reporter API does not do what a first version expects. The reporters, the seeded suite and the raw output of every run are in &lt;a href="https://github.com/qa-gary-parker/poc-playwright-custom-reporter" rel="noopener noreferrer"&gt;the PoC repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The suite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;13 tests against a small cart page built in the test file. 8 pass, 2 always fail, 2 fail on the first attempt and pass on retry, 1 is skipped.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;retries: 2&lt;/code&gt;, &lt;code&gt;workers: 4&lt;/code&gt;, &lt;code&gt;fullyParallel: true&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Playwright 1.65.1 with Chromium, Node v24.14.1, macOS on arm64.&lt;/li&gt;
&lt;li&gt;5 runs with three reporters at once: the minimal reporter, a probe that records every hook call to a JSON file, and a reporter with an async &lt;code&gt;onTestEnd&lt;/code&gt;. Then 1 run with &lt;code&gt;--max-failures=1 --workers=1&lt;/code&gt;, and 2 runs with &lt;code&gt;playwright-smart-reporter&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A minimal reporter
&lt;/h2&gt;

&lt;p&gt;A reporter is a class with optional hooks. This one prints one line per attempt and a summary at the end:&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="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;FullConfig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Reporter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Suite&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;TestCase&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;TestResult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;FullResult&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/reporter'&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MinimalReporter&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Reporter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;suite&lt;/span&gt;&lt;span class="o"&gt;!:&lt;/span&gt; &lt;span class="nc"&gt;Suite&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nf"&gt;onBegin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FullConfig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;suite&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Suite&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;suite&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;suite&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Running ${suite.allTests().length} tests with ${config.workers} workers`&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;onTestEnd&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="nc"&gt;TestCase&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;TestResult&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="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;retry&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="sb"&gt;` (retry ${result.retry})`&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="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${result.status.padEnd(8)} ${test.title}${attempt}`&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;onEnd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FullResult&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// test.outcome() looks at every attempt of a test, so each test counts once&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;counts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;expected&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="n"&gt;unexpected&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="n"&gt;flaky&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="n"&gt;skipped&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="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;suite&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;allTests&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="n"&gt;counts&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="nf"&gt;outcome&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="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`passed ${counts.expected}, failed ${counts.unexpected}, flaky ${counts.flaky}, skipped ${counts.skipped}: ${result.status}`&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;printsToStdio&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;return&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Point the config at the 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;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;reporter&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="s1"&gt;'./reporters/minimal-reporter.ts'&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;p&gt;&lt;code&gt;printsToStdio()&lt;/code&gt; tells Playwright whether the reporter writes to the terminal. The Playwright docs say to return &lt;code&gt;false&lt;/code&gt; when it does not, so Playwright can add its own output. This one prints, so it returns &lt;code&gt;true&lt;/code&gt;. The first run printed this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Running 13 tests with 4 workers
passed   shows the heading
passed   lists three items
passed   shows the total
passed   places an order
passed   ignores a bad coupon
passed   applies a coupon
passed   logs the item count
passed   toggles gift wrap
failed   always fails: missing button
failed   always fails: wrong total
failed   flaky: fails on the first attempt
failed   flaky: passes on retry
passed   flaky: fails on the first attempt (retry 1)
skipped  skipped: saved carts
passed   flaky: passes on retry (retry 1)
failed   always fails: missing button (retry 1)
failed   always fails: wrong total (retry 1)
failed   always fails: missing button (retry 2)
failed   always fails: wrong total (retry 2)
passed 8, failed 2, flaky 2, skipped 1: failed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That output already shows the first trap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trap 1: onTestEnd runs once per attempt, not once per test
&lt;/h2&gt;

&lt;p&gt;13 tests made 19 &lt;code&gt;onTestEnd&lt;/code&gt; calls in every run. Each retry is a new &lt;code&gt;TestResult&lt;/code&gt; for the same &lt;code&gt;TestCase&lt;/code&gt;. 8 of the 19 calls had &lt;code&gt;status: 'failed'&lt;/code&gt;: 3 attempts for each of the 2 failing tests, and 1 for each of the 2 flaky tests.&lt;/p&gt;

&lt;p&gt;So a reporter that counts failed results in &lt;code&gt;onTestEnd&lt;/code&gt; reports 8 failures. The suite has 2 failing tests and 2 flaky ones. &lt;code&gt;test.outcome()&lt;/code&gt; in &lt;code&gt;onEnd&lt;/code&gt; gave the right answer in 5 of 5 runs: 2 failed, 2 flaky, 8 passed, 1 skipped. It returns &lt;code&gt;expected&lt;/code&gt;, &lt;code&gt;unexpected&lt;/code&gt;, &lt;code&gt;flaky&lt;/code&gt; or &lt;code&gt;skipped&lt;/code&gt; from all the attempts of a test.&lt;/p&gt;

&lt;p&gt;The fix is to count tests, not results. Do the counting in &lt;code&gt;onEnd&lt;/code&gt; with &lt;code&gt;suite.allTests()&lt;/code&gt; and &lt;code&gt;test.outcome()&lt;/code&gt;, as the minimal reporter does. Use &lt;code&gt;onTestEnd&lt;/code&gt; for things that are about one attempt, such as a log line or an attachment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trap 2: the order of onTestEnd changes from run to run
&lt;/h2&gt;

&lt;p&gt;The 19 &lt;code&gt;onTestEnd&lt;/code&gt; calls came in a different order in each of the 5 runs: 5 runs, 5 distinct orders. With 4 workers, a test's result arrives when its worker finishes it. A reporter that writes results in arrival order produces a different file for the same suite every run. That breaks a diff of two reports. If the output needs a stable order, sort it in &lt;code&gt;onEnd&lt;/code&gt;, for example by file and line from &lt;code&gt;test.location&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trap 3: Playwright does not wait for an async onTestEnd
&lt;/h2&gt;

&lt;p&gt;This trap loses data without an error. I gave a reporter an &lt;code&gt;async onTestEnd&lt;/code&gt; that waits 200 ms, as a stand-in for an upload or a file write, and counted how many of those steps had finished:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When &lt;code&gt;onEnd&lt;/code&gt; ran: 18 of 19.&lt;/li&gt;
&lt;li&gt;When &lt;code&gt;onExit&lt;/code&gt; ran: still 18 of 19.&lt;/li&gt;
&lt;li&gt;Same in 5 of 5 runs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last step had not finished when the run ended. The reporter types in 1.65.1 explain why. &lt;code&gt;onTestEnd&lt;/code&gt; returns &lt;code&gt;void&lt;/code&gt;, so Playwright does not await the Promise. &lt;code&gt;onEnd&lt;/code&gt; and &lt;code&gt;onExit&lt;/code&gt; can return a Promise. A reporter that uploads each result from &lt;code&gt;onTestEnd&lt;/code&gt; can lose the last ones, and nothing in the output says so.&lt;/p&gt;

&lt;p&gt;The types point to the fix: keep the Promises from &lt;code&gt;onTestEnd&lt;/code&gt; in an array and &lt;code&gt;await Promise.all()&lt;/code&gt; on them in &lt;code&gt;onEnd&lt;/code&gt;. I did not measure that version. The 18 of 19 result depends on the 200 ms delay and on how long the last tests take. A longer step can leave more calls unfinished.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trap 4: --max-failures hides tests from your hooks
&lt;/h2&gt;

&lt;p&gt;With &lt;code&gt;--max-failures=1 --workers=1&lt;/code&gt;, the run stopped after the first failing test used its 3 attempts. 9 of the 13 tests reached &lt;code&gt;onTestEnd&lt;/code&gt;, in 11 calls: 8 passes and 3 attempts of &lt;code&gt;always fails: wrong total&lt;/code&gt;. The other 4 tests got no &lt;code&gt;onTestBegin&lt;/code&gt; and no &lt;code&gt;onTestEnd&lt;/code&gt; call.&lt;/p&gt;

&lt;p&gt;3 of those 4 would have run: the second always-failing test and both flaky tests. The 4th is the skipped test, which gets an &lt;code&gt;onTestBegin&lt;/code&gt; and an &lt;code&gt;onTestEnd&lt;/code&gt; call with &lt;code&gt;status: 'skipped'&lt;/code&gt; in a full run.&lt;/p&gt;

&lt;p&gt;A reporter that builds its list of tests from &lt;code&gt;onTestEnd&lt;/code&gt; sees 9 tests and does not know that 4 are missing. &lt;code&gt;test.outcome()&lt;/code&gt; in &lt;code&gt;onEnd&lt;/code&gt; still sees all 13. It reports all 4 as &lt;code&gt;skipped&lt;/code&gt;. So the run shows 4 skipped tests where a full run shows 1, and a failing test and two flaky tests disappear into that count. Playwright also made 1 &lt;code&gt;onError&lt;/code&gt; call in that run.&lt;/p&gt;

&lt;p&gt;In this run, the cut-off tests and the marked skip looked the same: no hook calls, outcome &lt;code&gt;skipped&lt;/code&gt;. If your reporter shows a skipped count after &lt;code&gt;--max-failures&lt;/code&gt;, say that the run stopped early instead of reporting the count as it is.&lt;/p&gt;

&lt;h2&gt;
  
  
  The other hooks are busy
&lt;/h2&gt;

&lt;p&gt;Hook calls per run of 13 tests:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Hook&lt;/th&gt;
&lt;th&gt;Calls&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;onBegin&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;onTestBegin&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;19&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;onTestEnd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;19&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;onStepBegin&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;255&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;onStepEnd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;255&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;onStdOut&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;onEnd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;onStepBegin&lt;/code&gt; and &lt;code&gt;onStepEnd&lt;/code&gt; ran about 13 times as often as &lt;code&gt;onTestEnd&lt;/code&gt;. Work you put in a step hook runs 255 times for 13 small tests. The one &lt;code&gt;onStdOut&lt;/code&gt; call is the one &lt;code&gt;console.log&lt;/code&gt; in a test.&lt;/p&gt;

&lt;h2&gt;
  
  
  What playwright-smart-reporter does with the same suite
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://garyparker.dev/projects/playwright-smart-reporter" rel="noopener noreferrer"&gt;playwright-smart-reporter&lt;/a&gt; is a reporter I maintain. I ran version 4.0.1 on the same suite, once in each mode, and read its JSON export.&lt;/p&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;Default run&lt;/th&gt;
&lt;th&gt;&lt;code&gt;--max-failures=1 --workers=1&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Total&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Passed&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Failed&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Flaky&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Skipped&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pass rate&lt;/td&gt;
&lt;td&gt;83&lt;/td&gt;
&lt;td&gt;89&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Failure clusters&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;It counts tests, not attempts: 2 failed, not 8. It reports the 2 flaky tests as flaky and also counts them as passed, so passed is 10.&lt;/li&gt;
&lt;li&gt;The pass rate leaves skipped tests out: 10 of 12 in the default run, 8 of 9 in the stopped run.&lt;/li&gt;
&lt;li&gt;It groups failures into clusters. Here that is 2 clusters, one per failing test, because the two tests fail with different errors.&lt;/li&gt;
&lt;li&gt;It has the same blind spot as &lt;code&gt;test.outcome()&lt;/code&gt; in trap 4. The stopped run shows 4 skipped tests: the 3 that were cut off and the 1 marked skip. Its pass rate of 89 is higher than the 83 of the full run, because the 3 cut-off tests are out of the sum.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The async fix in trap 3 comes from the reporter types. I did not run it.&lt;/li&gt;
&lt;li&gt;One seeded suite of 13 tests on one machine. The &lt;code&gt;onTestEnd&lt;/code&gt; order depends on worker scheduling, and the async result depends on the delay and on the timing of the last tests.&lt;/li&gt;
&lt;li&gt;I ran &lt;code&gt;playwright-smart-reporter&lt;/code&gt; once per mode, without history. Its flakiness scores across runs need history, so this test does not cover them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'd do
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Count failures in &lt;code&gt;onEnd&lt;/code&gt; with &lt;code&gt;test.outcome()&lt;/code&gt;. Never count failed results in &lt;code&gt;onTestEnd&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Sort the output in &lt;code&gt;onEnd&lt;/code&gt; if anyone diffs it.&lt;/li&gt;
&lt;li&gt;Await any async work from &lt;code&gt;onTestEnd&lt;/code&gt; in &lt;code&gt;onEnd&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;With &lt;code&gt;--max-failures&lt;/code&gt;, do not trust a skipped count or a pass rate. The tests that were cut off count as skipped.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a reporter that only prints, 26 lines are enough; for a reporter that counts, uploads or diffs, test it with retries, workers and &lt;code&gt;--max-failures&lt;/code&gt; before you trust its numbers. For more on what reports leave out, see &lt;a href="https://garyparker.dev/blog/playwright-165-only-failures" rel="noopener noreferrer"&gt;Playwright 1.65 onlyFailures&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The reporters, the suite and the raw results: &lt;a href="https://github.com/qa-gary-parker/poc-playwright-custom-reporter" rel="noopener noreferrer"&gt;poc-playwright-custom-reporter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://garyparker.dev/blog/writing-a-custom-playwright-reporter" rel="noopener noreferrer"&gt;https://garyparker.dev/blog/writing-a-custom-playwright-reporter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>typescript</category>
      <category>automation</category>
    </item>
    <item>
      <title>Your AI's Tests Pass. Here's What They Don't Check</title>
      <dc:creator>Gary Parker</dc:creator>
      <pubDate>Mon, 23 Nov 2026 10:14:16 +0000</pubDate>
      <link>https://dev.to/garyparker/your-ais-tests-pass-heres-what-they-dont-check-4f8</link>
      <guid>https://dev.to/garyparker/your-ais-tests-pass-heres-what-they-dont-check-4f8</guid>
      <description>&lt;p&gt;There's a claim doing the rounds that AI-written tests cover "about half" of the failure space. Rather than argue with the number, I measured it — and found something more useful than a percentage: a repeatable way to find out what &lt;em&gt;your&lt;/em&gt; AI's tests are missing.&lt;/p&gt;

&lt;p&gt;The experiment (&lt;a href="https://github.com/qa-gary-parker/poc-ai-code-test-coverage" rel="noopener noreferrer"&gt;public repo, rerun it yourself&lt;/a&gt;): give a coding agent a deliberately boundary-rich spec — a voucher engine with min-spend thresholds, expiry-inclusive dates, half-up rounding, discount caps and stacking rules — and ask it to implement the module &lt;em&gt;and write the test suite it would ship to production&lt;/em&gt;. No hints about what comes next.&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;p&gt;The agent produced 92 lines of correct implementation and 31 passing tests in under three minutes. The suite scored &lt;strong&gt;100% line coverage&lt;/strong&gt;. Every dashboard in your org would call this done.&lt;/p&gt;

&lt;p&gt;Then I ran &lt;a href="https://stryker-mutator.io/" rel="noopener noreferrer"&gt;StrykerJS&lt;/a&gt; over it. Mutation testing makes small changes to the code — flip a comparison, delete a condition, blank a string — and checks whether any test notices. A mutant that survives is a defect your suite would wave through.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Seven mutants survived. Mutation score: 90.67%.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Better than the "about half" discourse suggests — that's worth saying plainly, because the honest finding here is that modern agents write &lt;em&gt;good&lt;/em&gt; tests. But look at where the missing 9% lives:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Surviving mutant&lt;/th&gt;
&lt;th&gt;The production defect it represents&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;price &amp;lt; 0&lt;/code&gt; → &lt;code&gt;price &amp;lt;= 0&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Free items suddenly throw errors — nothing tested a zero price&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Error messages → &lt;code&gt;""&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Exceptions checked by type only; the messages nobody verified&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stackable check deleted&lt;/td&gt;
&lt;td&gt;Stackable vouchers quietly join the "best voucher" race&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best-discount comparison → always true&lt;/td&gt;
&lt;td&gt;The &lt;em&gt;last&lt;/em&gt; voucher wins instead of the &lt;em&gt;best&lt;/em&gt; one&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;&amp;gt;&lt;/code&gt; → &lt;code&gt;&amp;gt;=&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;A tie between equal vouchers flips to the other code&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Boundaries. Tie-breaks. Interactions between rules. Not one of these is exotic — they're the exact anatomy of the pricing incidents that make it to your postmortems. Line coverage couldn't see any of them, because &lt;strong&gt;coverage measures what tests execute, not what they verify&lt;/strong&gt;. The agent's tests walked through every line and asserted the happy outcomes it had thought of. So do most human suites — the difference is that AI generates plausible-looking suites so fast that nobody reads them with the suspicion they'd apply to a colleague's.&lt;/p&gt;

&lt;h2&gt;
  
  
  The feedback loop is the point
&lt;/h2&gt;

&lt;p&gt;Here's where it gets practical. I fed the seven survivors back to the agent and asked it to strengthen the tests. Six targeted tests later — each named after the defect it prevents — the score hit &lt;strong&gt;98.67%&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The seventh mutant is the finding I didn't expect. The agent analysed it, proved it was &lt;em&gt;equivalent&lt;/em&gt; — the mutated code is behaviourally identical to the original for every possible input (the mutation collapses into a comparison with &lt;code&gt;undefined&lt;/code&gt; that's always false) — verified that empirically, and declined to write a test for it, recommending a &lt;code&gt;// Stryker disable&lt;/code&gt; annotation instead.&lt;/p&gt;

&lt;p&gt;If you've run mutation testing on a real team, you know equivalent-mutant triage is exactly where the practice goes to die: someone burns an afternoon proving a mutant can't be killed, the team decides the tool cries wolf, the config quietly disappears. The agent did that triage unprompted, correctly, in seconds. The most tedious objection to mutation testing just became cheap.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd take into your team
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Stop treating coverage as the acceptance bar for AI-written tests.&lt;/strong&gt; It's the one metric agents saturate by default — every line executed, nothing necessarily verified.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make mutation score the honesty check where it counts.&lt;/strong&gt; You don't need it everywhere; run it on the modules where a silent boundary bug costs real money. That's also &lt;a href="https://garyparker.dev/blog/the-80-20-of-test-automation" rel="noopener noreferrer"&gt;where suite investment should concentrate anyway&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wire the loop, not the tool.&lt;/strong&gt; Generate → mutate → feed survivors back → regenerate. Each step is a one-line prompt or a CI job. The gap between 90.67% and 98.67% took one round trip and three minutes of agent time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep a human on the verdicts.&lt;/strong&gt; The agent proposed; the numbers and the equivalence proof were checkable. That's the shape of review worth doing — judging evidence, not reading 262 lines of generated assertions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One module, one agent, one run — indicative, not a benchmark. But the mechanism doesn't depend on the sample size: if your AI writes your tests, something other than the AI has to check what those tests actually hold in place. Mutation testing is the cheapest something I know, and it just got a lot less tedious to operate.&lt;/p&gt;

&lt;p&gt;This is a chapter in the wider argument about &lt;a href="https://garyparker.dev/playbook" rel="noopener noreferrer"&gt;what your test suite is for in the AI era&lt;/a&gt; — because agents don't just write tests now, they rely on them as their feedback loop. A suite that verifies nothing teaches your agents nothing.&lt;/p&gt;

&lt;p&gt;Everything above is reproducible: &lt;a href="https://github.com/qa-gary-parker/poc-ai-code-test-coverage" rel="noopener noreferrer"&gt;qa-gary-parker/poc-ai-code-test-coverage&lt;/a&gt;. Measured with StrykerJS 9.6.1 and Vitest 4.1.10.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://garyparker.dev/blog/mutation-testing-ai-generated-tests" rel="noopener noreferrer"&gt;https://garyparker.dev/blog/mutation-testing-ai-generated-tests&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>ai</category>
      <category>mutationtesting</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Playwright WebMCP: Calls Pass 50 of 50, First Read Misses Late Tools</title>
      <dc:creator>Gary Parker</dc:creator>
      <pubDate>Fri, 20 Nov 2026 11:51:52 +0000</pubDate>
      <link>https://dev.to/garyparker/playwright-webmcp-calls-pass-50-of-50-first-read-misses-late-tools-484n</link>
      <guid>https://dev.to/garyparker/playwright-webmcp-calls-pass-50-of-50-first-read-misses-late-tools-484n</guid>
      <description>&lt;p&gt;Playwright 1.65.1 can list and call the tools a page registers through WebMCP, and the calls were reliable whenever the tools existed at the moment of the call: the same task passed in 50 of 50 runs, in a median of 9.64 ms. The failures were around the calls. &lt;code&gt;page.webmcp.tools()&lt;/code&gt; did not wait for tools the page registered late, nothing checked the input against the schema, and a tool that threw reached the test as "Tool execution failed" with no reason.&lt;/p&gt;

&lt;p&gt;The page, the tests and every raw result are in &lt;a href="https://github.com/qa-gary-parker/poc-playwright-webmcp" rel="noopener noreferrer"&gt;the PoC repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;WebMCP lets a page register tools that an agent can call instead of clicking through the UI. Playwright exposes them as &lt;code&gt;page.webmcp&lt;/code&gt;. I wanted to know if a test can use them reliably, what breaks, and how that compares with driving the same page through selectors.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Playwright 1.65.1 and Chromium 159.0.8154.6 (the Playwright build, headless), launched with &lt;code&gt;--enable-features=WebMCP&lt;/code&gt;. Node 24.14.1 on macOS arm64.&lt;/li&gt;
&lt;li&gt;A toy shop page with a normal UI (search, add to cart, total, checkout) and seven WebMCP tools backed by the same cart logic: &lt;code&gt;search_products&lt;/code&gt;, &lt;code&gt;add_to_cart&lt;/code&gt;, &lt;code&gt;get_cart&lt;/code&gt;, &lt;code&gt;checkout&lt;/code&gt;, plus three awkward ones for the failure cases (&lt;code&gt;echo_qty&lt;/code&gt;, &lt;code&gt;boom&lt;/code&gt;, &lt;code&gt;hang&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;No model is involved. Every figure is a scripted run, 50 runs per row, each in a fresh browser context. The median is the 26th of the 50 sorted values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The page registers each tool with a name, an input schema and an &lt;code&gt;execute&lt;/code&gt; function. This is &lt;code&gt;add_to_cart&lt;/code&gt;. The &lt;code&gt;text&lt;/code&gt; helper wraps a value in a &lt;code&gt;content&lt;/code&gt; array.&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="n"&gt;mc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;modelContext&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;modelContext&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;mc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;registerTool&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;'add_to_cart'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Add a quantity of a product to the cart.'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;inputSchema&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="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'object'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;sku&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="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'string'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;qty&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="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'integer'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;minimum&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="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'sku'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'qty'&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="n"&gt;execute&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;sku&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;qty&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isInteger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qty&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;qty&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&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="n"&gt;isError&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="n"&gt;content&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="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'text'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'qty must be a positive integer'&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;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;addToCart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;qty&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;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&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="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;isError&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="n"&gt;content&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="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'text'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&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="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 test side is plain Playwright. This is a condensed version of the task script. It adds the mugs, and the full script adds the lamp in the same way.&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="n"&gt;tools&lt;/span&gt; &lt;span class="o"&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="n"&gt;webmcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tools&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;found&lt;/span&gt; &lt;span class="o"&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;parse&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="n"&gt;webmcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;callTool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'search_products'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'enamel'&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="n"&gt;content&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="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&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="n"&gt;webmcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;callTool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'add_to_cart'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;found&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="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;qty&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;cart&lt;/span&gt; &lt;span class="o"&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;parse&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="n"&gt;webmcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;callTool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'get_cart'&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="n"&gt;content&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="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&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;
  
  
  Same task, tools against test ids
&lt;/h2&gt;

&lt;p&gt;The task: add 2 mugs and 1 lamp, expect a total of 54. The DOM script uses &lt;code&gt;getByTestId&lt;/code&gt;, written once against UI variant 1. Variant 2 renames every test id and label.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;UI&lt;/th&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Passed&lt;/th&gt;
&lt;th&gt;Steps&lt;/th&gt;
&lt;th&gt;Median task time&lt;/th&gt;
&lt;th&gt;p95&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;v1&lt;/td&gt;
&lt;td&gt;WebMCP&lt;/td&gt;
&lt;td&gt;50/50&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;9.64 ms&lt;/td&gt;
&lt;td&gt;10.63 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1&lt;/td&gt;
&lt;td&gt;DOM test ids&lt;/td&gt;
&lt;td&gt;50/50&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;134.77 ms&lt;/td&gt;
&lt;td&gt;150.8 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v2, renamed&lt;/td&gt;
&lt;td&gt;WebMCP&lt;/td&gt;
&lt;td&gt;50/50&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;9.12 ms&lt;/td&gt;
&lt;td&gt;9.93 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v2, renamed&lt;/td&gt;
&lt;td&gt;DOM test ids&lt;/td&gt;
&lt;td&gt;0/50&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;td&gt;1001.05 ms&lt;/td&gt;
&lt;td&gt;1002.51 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Read this table carefully, because it flatters WebMCP.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The v2 failure is by construction. I renamed the ids the script depends on, so every run stopped at the 1000 ms action timeout with &lt;code&gt;locator.fill: Timeout 1000ms exceeded.&lt;/code&gt; It shows that test ids are fragile. It does not show that DOM driving is worse in general: role and text locators would survive some renames.&lt;/li&gt;
&lt;li&gt;Steps are the calls the script made. The DOM figure is low because the locators were known in advance. An agent without them would also need snapshots to find them.&lt;/li&gt;
&lt;li&gt;I did not measure where the DOM time goes. The likely cause is that a DOM action does more than a tool call: Playwright waits until the element is ready and then sends real input. With a model in the loop, the model's time per step is added to both methods. I did not measure that.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The part that does carry over: the tools are not tied to the markup. Variant 2 changed only the UI, so the same WebMCP script passed on both variants. That is the case for testing the tools directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Late registration: tools() does not wait
&lt;/h2&gt;

&lt;p&gt;The page registered the tools 0, 50, 200 and 1000 ms after its script ran. Straight after &lt;code&gt;goto&lt;/code&gt; I read &lt;code&gt;page.webmcp.tools()&lt;/code&gt; once, then read it again every 10 ms until the tools were there. The time in the last column runs from the first read.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Registration delay&lt;/th&gt;
&lt;th&gt;Found on immediate read&lt;/th&gt;
&lt;th&gt;Found when polling&lt;/th&gt;
&lt;th&gt;Median time until found&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0 ms&lt;/td&gt;
&lt;td&gt;50/50&lt;/td&gt;
&lt;td&gt;50/50&lt;/td&gt;
&lt;td&gt;3.15 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;50 ms&lt;/td&gt;
&lt;td&gt;0/50&lt;/td&gt;
&lt;td&gt;50/50&lt;/td&gt;
&lt;td&gt;59.12 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;200 ms&lt;/td&gt;
&lt;td&gt;0/50&lt;/td&gt;
&lt;td&gt;50/50&lt;/td&gt;
&lt;td&gt;209.21 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1000 ms&lt;/td&gt;
&lt;td&gt;0/50&lt;/td&gt;
&lt;td&gt;50/50&lt;/td&gt;
&lt;td&gt;1008.5 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;With any delay, the immediate read returned an empty list and no error, in all 150 runs. A test that reads the tool list straight after navigation sees no tools, and nothing says they are on the way. Poll until the tools you need are there:&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="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;expect&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;poll&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="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="n"&gt;webmcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tools&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="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5000&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;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;7&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;
  
  
  What callTool does not do for you
&lt;/h2&gt;

&lt;p&gt;Each benchmark case below ran 50 times, with the same outcome every time.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No schema check.&lt;/strong&gt; &lt;code&gt;echo_qty&lt;/code&gt; declares &lt;code&gt;qty&lt;/code&gt; as a required integer with a minimum of 1 and no extra properties. Through &lt;code&gt;callTool&lt;/code&gt;, a string &lt;code&gt;"3"&lt;/code&gt;, the value 0, a missing &lt;code&gt;qty&lt;/code&gt; and an extra property all reached the page's &lt;code&gt;execute&lt;/code&gt; function unchanged and returned normally. In this Playwright and Chromium build, nothing between the test and the page checked the input, so the page has to.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Page errors are results.&lt;/strong&gt; &lt;code&gt;add_to_cart&lt;/code&gt; checks its own input. For an unknown SKU it returned &lt;code&gt;isError: true&lt;/code&gt; with the text "Unknown sku NOPE", and &lt;code&gt;callTool&lt;/code&gt; handed that back as a normal result. It did not throw. A test has to check &lt;code&gt;result.isError&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thrown errors lose the reason.&lt;/strong&gt; A tool that throws &lt;code&gt;new Error('boom')&lt;/code&gt; reached the test as &lt;code&gt;OperationError: Tool execution failed.&lt;/code&gt; The word "boom" is not in it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unknown tool&lt;/strong&gt; throws, and the message lists the available tools. A browser without the flag throws "WebMCP is not enabled". A page that registers nothing returns an empty list.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A tool that never resolves.&lt;/strong&gt; With &lt;code&gt;{ timeout: 500 }&lt;/code&gt;, &lt;code&gt;callTool&lt;/code&gt; threw &lt;code&gt;Timeout 500ms exceeded.&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without a timeout, the result depends on where the code runs. I ran each of these checks once, outside the 50-run benchmark. In a plain library script, the call threw &lt;code&gt;Timeout 30000ms exceeded.&lt;/code&gt; Under the Playwright test runner, with the test timeout raised to 50 seconds, the call was still pending after 42 seconds. With the default settings, the call failed after 30 seconds with &lt;code&gt;Test timeout of 30000ms exceeded.&lt;/code&gt; That is the test timeout, not a timeout of the call.&lt;/p&gt;

&lt;p&gt;Pass a timeout, and check the result:&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="n"&gt;result&lt;/span&gt; &lt;span class="o"&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="n"&gt;webmcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;callTool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s1"&gt;'add_to_cart'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'NOPE'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;qty&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="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;timeout&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="p"&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="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isError&lt;/span&gt;&lt;span class="p"&gt;)&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="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;p&gt;There are two naming traps, and neither gives an error.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In this Chromium build the page-side object is &lt;code&gt;document.modelContext&lt;/code&gt;. &lt;code&gt;navigator.modelContext&lt;/code&gt; is undefined. A page that only looks at &lt;code&gt;navigator.modelContext&lt;/code&gt; registers nothing, and nothing says why.&lt;/li&gt;
&lt;li&gt;The page-side hint for a consequential tool is &lt;code&gt;consequentialHint&lt;/code&gt;, which Playwright reports as &lt;code&gt;annotations.consequential&lt;/code&gt;. A tool that I registered with &lt;code&gt;consequential&lt;/code&gt; came back from &lt;code&gt;tools()&lt;/code&gt; with no annotations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;No model is involved. This says nothing about whether a model picks WebMCP tools better than DOM clicks, and I did not measure tokens.&lt;/li&gt;
&lt;li&gt;I called the tools through Playwright only. I did not test what a browser's own agent does with the schema before it calls a tool.&lt;/li&gt;
&lt;li&gt;One toy page on localhost, one machine, one browser build, headless. The timings are from a warm local run on macOS. Read them as orders of magnitude.&lt;/li&gt;
&lt;li&gt;Not tested: Playwright MCP's own WebMCP support, Firefox, other Chromium builds, headed mode.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'd do with it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Test your page's tools with &lt;code&gt;page.webmcp.callTool&lt;/code&gt;. Wait for registration before you read the tool list.&lt;/li&gt;
&lt;li&gt;Pass a timeout on every &lt;code&gt;callTool&lt;/code&gt;, and check &lt;code&gt;isError&lt;/code&gt; on every result.&lt;/li&gt;
&lt;li&gt;Validate input inside &lt;code&gt;execute&lt;/code&gt;. Do not rely on the declared schema.&lt;/li&gt;
&lt;li&gt;When a tool can fail, return &lt;code&gt;isError&lt;/code&gt; with a message. Do not throw: the message of a thrown error did not reach the test.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/qa-gary-parker/poc-playwright-webmcp" rel="noopener noreferrer"&gt;qa-gary-parker/poc-playwright-webmcp&lt;/a&gt;. The &lt;a href="https://garyparker.dev/blog/playwright-mcp-vs-cli-tokens" rel="noopener noreferrer"&gt;MCP vs CLI experiment&lt;/a&gt; measures the token cost of driving a page through Playwright MCP and the CLI. More are in the &lt;a href="https://garyparker.dev/playbook" rel="noopener noreferrer"&gt;playbook&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://garyparker.dev/blog/playwright-webmcp" rel="noopener noreferrer"&gt;https://garyparker.dev/blog/playwright-webmcp&lt;/a&gt;&lt;/p&gt;

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