<?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: Tayguara Reis</title>
    <description>The latest articles on DEV Community by Tayguara Reis (@tayguara).</description>
    <link>https://dev.to/tayguara</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%2F4154832%2F8a2a1961-a75e-4fc2-925c-e906f46a9fb2.jpg</url>
      <title>DEV Community: Tayguara Reis</title>
      <link>https://dev.to/tayguara</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tayguara"/>
    <language>en</language>
    <item>
      <title>My accessibility tests fail on purpose. Two of them corrected my own audit</title>
      <dc:creator>Tayguara Reis</dc:creator>
      <pubDate>Thu, 26 Nov 2026 18:01:38 +0000</pubDate>
      <link>https://dev.to/tayguara/my-accessibility-tests-fail-on-purpose-two-of-them-corrected-my-own-audit-1i59</link>
      <guid>https://dev.to/tayguara/my-accessibility-tests-fail-on-purpose-two-of-them-corrected-my-own-audit-1i59</guid>
      <description>&lt;p&gt;My &lt;a href="https://dev.to/tayguara/axe-core-found-10-accessibility-issues-in-a-health-app-manual-testing-found-7-more-58h5"&gt;last article&lt;/a&gt; was about a WCAG 2.2 audit of &lt;a href="https://openmrs.org" rel="noopener noreferrer"&gt;OpenMRS O3&lt;/a&gt; 3.7.1, an open source electronic health record. axe-core found ten problems, and a manual pass with the keyboard, zoom and screen readers found more. Near the end I wrote that some of the manual findings could become plain Playwright tests, and that I had not written them yet.&lt;/p&gt;

&lt;p&gt;Now I have. Five manual findings are encoded as Playwright tests that run against a local OpenMRS 3.7.1:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;M1: focus order on a paginated table;&lt;/li&gt;
&lt;li&gt;M3: an unannounced status message;&lt;/li&gt;
&lt;li&gt;M6: focus hidden behind a toolbar at 200% zoom;&lt;/li&gt;
&lt;li&gt;M7: reflow at 320 pixels;&lt;/li&gt;
&lt;li&gt;M8: page titles.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of them fail today, on purpose, and the suite is still green. The day OpenMRS fixes one of these bugs, the matching test turns red and tells me so.&lt;/p&gt;

&lt;p&gt;Writing them also showed me two places where my own audit report was wrong. I wrote the spec for the suite and reviewed every result; an AI coding agent wrote most of the code against that spec, and a separate review and QA pass checked it before it was merged. The code is in &lt;a href="https://github.com/tayguara/accessibility-audits/tree/main/audits/2026-10-openmrs-o3/regression" rel="noopener noreferrer"&gt;accessibility-audits&lt;/a&gt;, next to the audit it comes from.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the tests fail on purpose
&lt;/h2&gt;

&lt;p&gt;A regression test for a bug that still exists has two jobs. It must stay out of the way while the bug is known, and it must speak up when the bug changes. If I skip the test, it never speaks up. If I leave it red, people learn to ignore a red suite. Playwright has &lt;code&gt;test.fail()&lt;/code&gt; for this: it marks a test as expected to fail, reports it as passing while it fails, and reports "Expected to fail, but passed" when it starts passing.&lt;/p&gt;

&lt;p&gt;The catch is that &lt;code&gt;test.fail()&lt;/code&gt; on its own accepts any failure. If a selector breaks after an OpenMRS upgrade, the test fails for the wrong reason and still counts as expected. So I call it in the middle of the test, after the preconditions, never at the top:&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;expectFindingToFail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FindingId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;void&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;fail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;showKnownFailures&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sb"&gt;`${id} (WCAG ${findings[id].sc}) is still present in OpenMRS O3 3.7.1. If this test passes, the bug is fixed: remove this call.`&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;Every finding test has the same three parts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Preconditions&lt;/strong&gt; prove the test is looking at the right thing. If one fails, the test is red, as it should be.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;expectFindingToFail('M1')&lt;/code&gt;&lt;/strong&gt; marks the rest as the known bug.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One assertion&lt;/strong&gt; reproduces the finding.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is the whole M1 test. The vitals table on the patient chart is paginated. In the audit, changing the page with the keyboard dropped focus from the page selector to &lt;code&gt;&amp;lt;body&amp;gt;&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="s1"&gt;'M1 · 2.4.3 Focus Order (A) · focus stays on the page selector after changing the page'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nf"&gt;findingDetails&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'M1'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;chartPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;readFixture&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;patientUuid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Patient Summary'&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;widget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;vitalsWidget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;widget&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toBeVisible&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;pageSelect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;widget&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// 12 vitals encounters at 5 per page: 3 pages.&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;locator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'option'&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;toHaveCount&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="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toHaveValue&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="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;focus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toBeFocused&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="c1"&gt;// Change the page with the keyboard, as the finding describes.&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;keyboard&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;press&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'ArrowDown'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toHaveValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nf"&gt;expectFindingToFail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'M1'&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;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="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="nf"&gt;focusDescription&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="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;5_000&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="s1"&gt;'[M1] keyboard focus was lost after changing the page. Actual focus'&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;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'page select'&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;Before the mark, the test proves four things: the widget rendered, there are three pages, the selector had focus, and the page really changed. After the mark there is a single question: where is the focus now? On 3.7.1 the answer is &lt;code&gt;BODY&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Before I wrote any of this, I checked one behavior with a throwaway spike on Playwright 1.63.0, and it changed how I wrote every test. A failed precondition before the mark is red, as I expected. But an assertion that times out &lt;em&gt;after&lt;/em&gt; the mark also counts as an expected failure. Only the 120-second test timeout stays red. So if the final assertion waits on an element that no longer exists, a broken selector looks exactly like the known bug. The rule I took from that is that everything the final assertion reads must already be proven by a precondition.&lt;/p&gt;

&lt;p&gt;For debugging there is a switch. With &lt;code&gt;SHOW_KNOWN_FAILURES=1&lt;/code&gt; the mark is off, and the eight finding tests fail with their real values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[M1] keyboard focus was lost after changing the page. Actual focus
    Expected: "page select"
    Received: "BODY (not the page select)"
[M6] 1 focus stop(s) entirely behind a fixed bar at 200% zoom (viewport 640x400). Actual: #37 &amp;lt;button&amp;gt; "Options" top 352 bottom 400
[M7] main content scrolls sideways on P5 patient registration (&amp;lt;div&amp;gt; overflow-x auto). Actual: scrollWidth 531, clientWidth 320
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That switch caught a bug in my own test, too. The first version of one M7 test passed in that mode when it should have failed. The anchor element I measured was an outer container, 320 pixels wide in a 320-pixel viewport. The region that actually scrolls sits inside it. Under the normal run, that test would have reported "Expected to fail, but passed", and I would have believed that OpenMRS had fixed something.&lt;/p&gt;

&lt;h2&gt;
  
  
  Proving the tests can turn red
&lt;/h2&gt;

&lt;p&gt;A test that fails on purpose is only useful if it can stop failing. So I sabotaged the tests and injected fixes, without changing any test code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Breaking a precondition&lt;/strong&gt; turned the test red in M1, M3 and M8, and it was not counted as an expected failure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Injecting the fix.&lt;/strong&gt; I made temporary copies of three specs with one extra &lt;code&gt;context.addInitScript&lt;/code&gt; that applies the fix the audit recommends:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;M8:&lt;/strong&gt; a distinct &lt;code&gt;document.title&lt;/code&gt; per route.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;M6:&lt;/strong&gt; &lt;code&gt;scroll-padding-bottom&lt;/code&gt; set to the height of the fixed toolbar.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;M3:&lt;/strong&gt; a &lt;code&gt;role="status"&lt;/code&gt; region that exists before the user types.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three reported "Expected to fail, but passed", so the suite will notice when OpenMRS ships those fixes. I did not run this check for M1 or for the M7 assertions.&lt;/p&gt;

&lt;p&gt;The rest of the numbers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;npm test&lt;/code&gt; runs 24 tests (setup, 13 unit tests for the geometry helpers, and 10 end-to-end tests) in about a minute. Eight of them are expected failures.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--repeat-each=3&lt;/code&gt; gave 31 passed and no flaky tests.&lt;/li&gt;
&lt;li&gt;The setup creates its own patient, with an active visit and 12 vitals records, through the REST API. A second run finds that patient and creates nothing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Encoding each finding
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;M8, page titles,&lt;/strong&gt; was the easy one. Seven screens, signed out and signed in, each proven rendered before its title is read. All seven are &lt;code&gt;OpenMRS&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;M3, status messages.&lt;/strong&gt; In the patient search, the "N search results" counter is a plain &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;. A screen reader only announces changes inside a live region it already knows about, so a region created together with the results does not count. Before typing, the test marks every live region already on the page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;locator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;LIVE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;evaluateAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;els&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="n"&gt;els&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'data-m3-preexisting'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="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;After typing, it walks up from the counter with &lt;code&gt;closest()&lt;/code&gt; and checks for that marker. On 3.7.1 the only live region before typing is an unrelated &lt;code&gt;&amp;lt;tbody aria-live="polite"&amp;gt;&lt;/code&gt;, and the counter is in none at all.&lt;/p&gt;

&lt;p&gt;This test checks the DOM; it does not run a screen reader. It also accepts any live region above the counter: during the fix check, &lt;code&gt;role="status"&lt;/code&gt; on &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; was enough to make it pass.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;M6, focus not obscured at 200% zoom.&lt;/strong&gt; Playwright cannot drive browser zoom, so I emulated 200% of a 1280×800 window as a 640×400 viewport with &lt;code&gt;deviceScaleFactor: 2&lt;/code&gt;. That is what the page sees at that zoom, and it switches OpenMRS to the tablet layout with a fixed toolbar at the bottom. The test tabs through the vitals card and measures each focused element against the fixed bars. The classification is a pure function, written test-first:&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;obscuredState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Rect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;viewport&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;width&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;height&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="n"&gt;bars&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Rect&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;tolerance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.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="nc"&gt;ObscuredState&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;visible&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;intersect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;top&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;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;viewport&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;viewport&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;left&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="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;visible&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'full'&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;bars&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bar&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;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;visible&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tolerance&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="s1"&gt;'full'&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;bars&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bar&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;intersect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;visible&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&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="s1"&gt;'partial'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'none'&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;WCAG 2.4.11 at level AA only fails when the focused element is entirely hidden, so only &lt;code&gt;full&lt;/code&gt; fails the test. Partly covered stops go into an annotation.&lt;/p&gt;

&lt;p&gt;Timing was the hard part. OpenMRS scrolls focus into view with smooth scrolling. When I measured two animation frames after each Tab, the positions changed from run to run. For "Table view", two frames after Tab, it was at &lt;code&gt;top 400&lt;/code&gt; with &lt;code&gt;scrollY 0&lt;/code&gt;; once the scroll settled, it was at &lt;code&gt;top 180&lt;/code&gt; with &lt;code&gt;scrollY 220&lt;/code&gt;. Now the test waits until &lt;code&gt;scrollY&lt;/code&gt; holds still for six frames before it measures anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;M7, reflow at 320 pixels,&lt;/strong&gt; is where checking the page as a whole gives the wrong answer. The obvious check is &lt;code&gt;document.documentElement.scrollWidth &amp;lt;= clientWidth&lt;/code&gt;. I kept it as a test that passes on purpose, on both screens, because it shows why it is not enough. The clipping happens inside the page, where a page-level check cannot see it.&lt;/p&gt;

&lt;p&gt;So M7 has two tests per screen:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Controls cut off.&lt;/strong&gt; The first collects every interactive or text element and compares its box with the viewport and with the clipping boxes of its ancestors. On registration, 4 of 10 elements are cut off, all of them header buttons beyond the 320-pixel edge. On the chart, 7 of 19 are cut off: the same header buttons, "Search patient" and "Patient lists" in the bottom toolbar.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Content scrolling sideways.&lt;/strong&gt; The second measures the region that holds the main content.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The second one is where my audit was wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the tests corrected
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;M7: the form can be reached.&lt;/strong&gt; My report said the registration form is clipped "with no way to reach it" and cannot be completed at 320 pixels. The last article repeated that: no horizontal scrollbar, so registering a patient is impossible. The test disagrees.&lt;/p&gt;

&lt;p&gt;The form sits inside a &lt;code&gt;div&lt;/code&gt; with &lt;code&gt;overflow-x: auto&lt;/code&gt;. In that region, &lt;code&gt;scrollWidth&lt;/code&gt; is 531 against a &lt;code&gt;clientWidth&lt;/code&gt; of 320 on registration. On the chart it was 755 in one run and 828 in a later one, against the same 320. The content is there, 211 pixels to the right of the registration form.&lt;/p&gt;

&lt;p&gt;During the manual pass I saw no scrollbar and concluded there was no way to scroll. A follow-up check showed why there was no scrollbar: the container has &lt;code&gt;scrollbar-width: none&lt;/code&gt;. It scrolls sideways and down (a &lt;code&gt;scrollHeight&lt;/code&gt; of 2148 in a 208-pixel window); it just does not show it. Shift+wheel moved it the full 211 pixels. Tabbing through the form scrolled each cut-off field into view, except one "Edit" button that stayed partly past the edge. My observation was right and my conclusion was wrong.&lt;/p&gt;

&lt;p&gt;It is still a 1.4.10 failure, just a different one. Reflow allows two-dimensional scrolling only for content that needs a two-dimensional layout, such as data tables, maps and diagrams. A registration form is linear content. Filling it in at 320 pixels means scrolling that one region down and sideways, field by field. So the finding stays, with a different description, and I have corrected it in the report.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;M6: a different control.&lt;/strong&gt; The report names "Table view" and "Add" as the controls that end up behind the toolbar. In the test run, both are fully visible once the smooth scroll settles. The control that ends up completely hidden is an "Options" button on a table row (top 352, bottom 400, under a toolbar that starts at about 335). The row button just before it is partly covered.&lt;/p&gt;

&lt;p&gt;I trust neither result blindly here. The manual pass used real browser zoom in Firefox and Chrome. The test emulates 200% zoom in Chromium. Smooth scrolling and the point where the browser decides an element is "in view" can differ between them. The finding stands, because a focused control does end up entirely behind the toolbar. But which control it is depends on how you zoom, and I now say so instead of naming one as fact.&lt;/p&gt;

&lt;p&gt;Both corrections came from the same habit: making the test print the measured value instead of just pass or fail. The screenshot from the audit looked conclusive. The measured &lt;code&gt;scrollWidth&lt;/code&gt; was 531.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Chromium only, English locale, OpenMRS 3.7.1. Another version may need different locators.&lt;/li&gt;
&lt;li&gt;200% zoom is emulated, not real browser zoom.&lt;/li&gt;
&lt;li&gt;No screen reader runs. M3 checks the DOM conditions for an announcement, not the announcement itself.&lt;/li&gt;
&lt;li&gt;The M7 probe cannot see text cut by &lt;code&gt;text-overflow&lt;/code&gt; inside an element's own box, or content hidden by a transform.&lt;/li&gt;
&lt;li&gt;The first start of the OpenMRS Docker stack took about 90 minutes on my machine before the tests could run at all.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The audit found these problems by hand, with a keyboard and a zoomed browser. The tests do not replace that pass. They remember what it found, and they told me where I had written it down wrong.&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>playwright</category>
      <category>testing</category>
      <category>typescript</category>
    </item>
    <item>
      <title>axe-core found 10 accessibility issues in a health app. Manual testing found 7 more</title>
      <dc:creator>Tayguara Reis</dc:creator>
      <pubDate>Tue, 17 Nov 2026 20:51:49 +0000</pubDate>
      <link>https://dev.to/tayguara/axe-core-found-10-accessibility-issues-in-a-health-app-manual-testing-found-7-more-58h5</link>
      <guid>https://dev.to/tayguara/axe-core-found-10-accessibility-issues-in-a-health-app-manual-testing-found-7-more-58h5</guid>
      <description>&lt;p&gt;In October I audited &lt;a href="https://openmrs.org" rel="noopener noreferrer"&gt;OpenMRS O3&lt;/a&gt;, an open source electronic health record, against WCAG 2.2 level AA. I ran it locally from the official Docker images, pinned to version 3.7.1, and scanned eight screens with axe-core 4.13.0: login, location picker, the service queues home, patient search, patient registration, the patient chart, the vitals form and appointments.&lt;/p&gt;

&lt;p&gt;axe reported ten distinct problems. Then I put the mouse away and went through the same screens with the keyboard, 200% zoom, a 320-pixel viewport and two screen readers. That found seven more failures. axe had not reported any of them, although it had flagged one of the elements for a different reason.&lt;/p&gt;

&lt;p&gt;This article is about that gap: what the scanner saw, what it could not see and why, and how I still run axe on every pull request without the suite turning into noise. The full audit, with the raw scan, the evidence screenshots and the source verification, is public in &lt;a href="https://github.com/tayguara/accessibility-audits/tree/main/audits/2026-10-openmrs-o3" rel="noopener noreferrer"&gt;accessibility-audits&lt;/a&gt;. The CI code comes from &lt;a href="https://github.com/tayguara/playwright-qa-showcase" rel="noopener noreferrer"&gt;playwright-qa-showcase&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What axe found
&lt;/h2&gt;

&lt;p&gt;I ran the WCAG 2.0, 2.1 and 2.2 A and AA rule tags. Per screen, the counts look like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Screen&lt;/th&gt;
&lt;th&gt;Violations (rules)&lt;/th&gt;
&lt;th&gt;Checks axe could not decide&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Login&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Location picker&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;Home (service queues)&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Patient search&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Patient registration&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Patient chart&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;54&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vitals form&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;52&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Appointments&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Added up, that is 28 rule hits, which overstates the problem. Nineteen of them involve two global components, the help button and the user menu, which show up on almost every screen. Grouped by cause, they come down to ten findings under five success criteria: 1.3.1, 1.4.1, 1.4.3, 2.5.8 and 4.1.2. A few examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The floating help button has no accessible name, so a screen reader announces only "button".&lt;/li&gt;
&lt;li&gt;The user menu puts &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; elements directly inside a &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt;, which breaks the list semantics on six of the eight screens.&lt;/li&gt;
&lt;li&gt;The date placeholders on the registration form have a contrast ratio of 1.72:1, against a minimum of 4.5:1.&lt;/li&gt;
&lt;li&gt;"Vitals history" is 16 pixels tall, below the 24-pixel minimum target size that WCAG 2.2 added.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of these are real, and axe found them in seconds. When I checked the findings against the current OpenMRS source, two of the ten were already fixed upstream, including the help button. This is what automated scanning is good at, and it costs nothing to run again after every change.&lt;/p&gt;

&lt;p&gt;The third column matters too. axe marks a check as "incomplete" when it cannot decide by itself. On these eight screens, that was 165 checks: 76 for color contrast (mostly text over the colored alert bands in the vitals tables), 87 for ARIA attributes and two others. A scan that passes with 165 undecided checks has not shown that the page is accessible. It has handed you a to-do list.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it missed
&lt;/h2&gt;

&lt;p&gt;The manual pass ran in Firefox and Chrome on Linux (keyboard, zoom, responsive mode, DOM inspection), with Orca on Linux and TalkBack on an Android phone as screen readers. I did not test NVDA, JAWS or VoiceOver in this round, and the report says so.&lt;/p&gt;

&lt;p&gt;These are the seven failures, grouped by the reason a scanner cannot catch them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The page had to change first.&lt;/strong&gt; axe looks at the DOM at the moment you call it. Two failures only happen after an interaction:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;2.4.3 Focus Order.&lt;/strong&gt; The vitals, biometrics and conditions tables are paginated. When you change the page with the keyboard, the table re-renders, the page selector (a &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt;) is recreated with a new &lt;code&gt;id&lt;/code&gt;, and &lt;code&gt;document.activeElement&lt;/code&gt; drops from the selector to &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;. A keyboard or screen reader user loses their place.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2.4.7 Focus Visible.&lt;/strong&gt; In the date-of-birth calendar, Tab moves focus into the grid of days and the arrow keys change the date, but the focused day has no visible style. The date in the field changed from 06/02/1959 to 26/03/1959 while I watched nothing move on screen.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The viewport had to change.&lt;/strong&gt; I scanned at 1280×800. Both of these failures appear only in a different layout:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;2.4.11 Focus Not Obscured (Minimum)&lt;/strong&gt;, new in WCAG 2.2. At 200% zoom, the chart's actions become a fixed bar at the bottom of the screen. Tabbing through the vitals card puts focus behind that bar, first partly and then completely hidden. The browser does not scroll, because as far as it knows the element is already in view.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1.4.10 Reflow.&lt;/strong&gt; At 320 pixels wide, the registration form keeps its two-column layout and gets cut off on the right: half-labels, a clipped "No" button, an unreadable date field. There is no horizontal scrollbar to reach the rest, so registering a patient at that width is impossible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Update, 26 Nov 2026: this was wrong. The form sits in a container that scrolls sideways, with its scrollbar hidden by &lt;code&gt;scrollbar-width: none&lt;/code&gt;, and Tab or Shift+wheel reach the cut-off fields. It still fails 1.4.10, because filling in a form should not need scrolling in two directions. The tests that found this are in &lt;a href="https://dev.to/tayguara/my-accessibility-tests-fail-on-purpose-two-of-them-corrected-my-own-audit-1i59"&gt;the follow-up article&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Something had to be announced.&lt;/strong&gt; In the global patient search, the "N search results" counter updates on every keystroke, but it is a plain &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; with no &lt;code&gt;role="status"&lt;/code&gt; or &lt;code&gt;aria-live&lt;/code&gt; anywhere above it. Sighted users see the count. Screen reader users have to leave the field to find out whether the search found anyone. That is &lt;strong&gt;4.1.3 Status Messages&lt;/strong&gt;, and no static scan can hear what is not announced.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No rule exists for it.&lt;/strong&gt; Each result in that same search is a link that contains a button ("Active Visit"). Interactive content inside a link is invalid HTML, and screen readers handle it inconsistently. I wondered whether axe missed it only because I never scanned the open search panel, so I tested a minimal page with a &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; inside an &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; against axe-core 4.13.0. It passed. axe's &lt;code&gt;nested-interactive&lt;/code&gt; rule only applies to roles whose children are presentational, such as &lt;code&gt;button&lt;/code&gt; or &lt;code&gt;checkbox&lt;/code&gt;, and in axe's ARIA table the &lt;code&gt;link&lt;/code&gt; role does not have that flag.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The element was flagged, for a different reason.&lt;/strong&gt; The header of the vitals card is a &lt;code&gt;div&lt;/code&gt; with &lt;code&gt;role="button"&lt;/code&gt; and &lt;code&gt;tabindex="0"&lt;/code&gt; that contains a link and a button. axe did flag it, as nested interactive controls. What axe could not tell is what happens when you reach it with Tab: focus lands on it with no visible indicator, Enter does nothing, and Space scrolls the page. It is a dead tab stop that announces itself as a button. The manual finding (2.4.7 and 4.1.2) is the one a keyboard user actually feels.&lt;/p&gt;

&lt;p&gt;So the seven failures are four about focus, two about semantics and announcements, and one about reflow. The focus failures share a pattern: OpenMRS works with the keyboard almost everywhere, but it does not always show where the focus is. One consistent &lt;code&gt;:focus-visible&lt;/code&gt; style and &lt;code&gt;scroll-padding&lt;/code&gt; on the fixed bars would fix most of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running axe in CI without drowning in it
&lt;/h2&gt;

&lt;p&gt;None of this makes axe less useful. It makes it a regression guard, not an audit. I use it that way in my showcase suite, which scans four pages of &lt;a href="https://www.saucedemo.com" rel="noopener noreferrer"&gt;SauceDemo&lt;/a&gt; on every pull request.&lt;/p&gt;

&lt;p&gt;The first decision is which rules to run:&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;AXE_TAGS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'wcag2a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'wcag2aa'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'wcag21a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'wcag21aa'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'wcag22aa'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'best-practice'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;runAxe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AxeBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;withTags&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;AXE_TAGS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;analyze&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;I include &lt;code&gt;best-practice&lt;/code&gt;, which is advisory and not a WCAG failure. SauceDemo has no WCAG A or AA violations on these pages, so without the best-practice rules the mechanism below would have nothing real to work on.&lt;/p&gt;

&lt;p&gt;The second decision is what to do with the violations you already know about. If the suite fails on all of them, people learn to ignore the red. If you skip the rules that fire, a new problem under the same rule goes unnoticed. I keep a baseline file with the violations I knowingly accept, one entry per rule per page, each with a reason and a date:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"login"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"ruleId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"page-has-heading-one"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"reason"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Best practice: the page has no level-one heading; the 'Swag Labs' logo is a plain div."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"since"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-09"&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="nl"&gt;"ruleId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"region"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"reason"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Best practice: the logo text sits outside any landmark region."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"since"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-09"&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 reason is required. An entry that says only "known issue" does not tell the next person whether it is still acceptable. The file is validated with zod when the suite loads it, so an empty reason, a malformed date or a duplicated rule on the same page fails before any test runs.&lt;/p&gt;

&lt;p&gt;The comparison is a pure function, with its own unit tests:&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;diffAgainstBaseline&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;T&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;ViolationLike&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;pageKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;violations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="no"&gt;T&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;baseline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Baseline&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="nc"&gt;BaselineDiff&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;entries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;baseline&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pageKey&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="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;entryByRule&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entries&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;entry&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="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ruleId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;entry&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;firedRules&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;violations&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;violation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;violation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="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;diff&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;BaselineDiff&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;newViolations&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;stillPresent&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;resolved&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;firedRules&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ruleId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;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;violation&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;violations&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;entry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;entryByRule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;violation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="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;entry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stillPresent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;violation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;entry&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;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;newViolations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;violation&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;return&lt;/span&gt; &lt;span class="n"&gt;diff&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;Three outcomes come out of it. A violation that is not in the baseline fails the test. A known one passes and becomes an annotation in the HTML report. A baseline entry whose rule stopped firing is annotated as stale, so someone removes it in a pull request instead of letting the file rot. A Playwright fixture runs the scan, attaches the raw axe JSON and a short markdown summary to every test, and makes the assertion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Only rule ids are compared; the details go in the message.&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;diff&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;newViolations&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;violation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;violation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nf"&gt;formatNewViolations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pageKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;newViolations&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="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;Each test then reads as one line, &lt;code&gt;await auditPage('login')&lt;/code&gt;, after the test has navigated to the page.&lt;/p&gt;

&lt;p&gt;I chose two trade-offs on purpose. There is no "update baseline" mode: every entry is written by hand and goes through review, because an automatic update is how a real failure gets accepted without anyone reading it. And the baseline is keyed by rule per page, not by element selector. That keeps the file small and stable when the markup changes, but it means a second element breaking an already-baselined rule on the same page is not flagged. Keying by selector would catch it, at the cost of an entry that breaks whenever the markup changes.&lt;/p&gt;

&lt;p&gt;The latest run, on 16 November 2026 with axe-core 4.13.0: no new violations on the four pages, five best-practice findings in the baseline (the missing level-one heading on all four pages and content outside a landmark on the login page), and three color contrast checks on the inventory page that axe could not decide. Those three go on the manual list, like the 165 on OpenMRS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Narrowing the gap
&lt;/h2&gt;

&lt;p&gt;Some of the seven manual failures can become automated checks once a human has found them. The cheapest step is to scan states, not only URLs. The scanner I used for the audit takes an optional selector to click before the scan, which opens a panel or a dialog first:&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;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;waitFor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;click&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// SPAs that poll never reach "networkidle": wait for the page's own selector plus a short render pause.&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;waitUntil&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'load'&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;waitFor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;locator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;waitFor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;first&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;waitFor&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;60_000&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitForTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2_000&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;click&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;locator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;click&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitForTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2_000&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;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AxeBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;withTags&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;TAGS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;analyze&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="c1"&gt;// ...write result to disk&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is how the vitals form got scanned at all: it is a side panel that only exists after clicking "Add".&lt;/p&gt;

&lt;p&gt;The next step is to write a plain Playwright test for the behavior a manual finding describes. The focus order failure is a good candidate: change the table page with the keyboard and assert that the focused element is still the page selector. The reflow and focus-not-obscured failures need the same flows run at 320 pixels and at 200% zoom. I have not written those tests yet. When I do, each one will start from a finding a person made with a keyboard, not from a scanner rule.&lt;/p&gt;

&lt;p&gt;What does not automate is the judgment. Whether the counter needs to be announced, whether the focus indicator is visible enough, whether a cut-off form is still usable: those calls need someone who uses the page the way a disabled user would.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I split the work now
&lt;/h2&gt;

&lt;p&gt;On every pull request, axe runs with the baseline, and a new violation blocks the merge. It is fast, and it keeps fixed problems from coming back.&lt;/p&gt;

&lt;p&gt;Before a release, or when a team is about to sign an accessibility conformance report, someone does the manual pass: keyboard only through the main flows, 200% zoom, 320 pixels wide, and at least one screen reader. On OpenMRS that pass produced seven of the seventeen findings in the report, and every one of the four focus failures. If a product only has the scanner, those are the failures its keyboard users meet first.&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>a11y</category>
      <category>webdev</category>
    </item>
    <item>
      <title>I let an AI agent write my Playwright API tests. It caught a bug my suite missed</title>
      <dc:creator>Tayguara Reis</dc:creator>
      <pubDate>Sun, 25 Oct 2026 17:30:22 +0000</pubDate>
      <link>https://dev.to/tayguara/i-let-an-ai-agent-write-my-playwright-api-tests-it-caught-a-bug-my-suite-missed-i9</link>
      <guid>https://dev.to/tayguara/i-let-an-ai-agent-write-my-playwright-api-tests-it-caught-a-bug-my-suite-missed-i9</guid>
      <description>&lt;p&gt;I expected to write an article about what AI coding agents get wrong when they write tests. I built the experiment to show it: a local copy of an API with ten bugs I could switch on one at a time, my own hand-written suite as the baseline, and two suites written by an agent, one with no rules and one with a short rules file.&lt;/p&gt;

&lt;p&gt;The agent's suites caught more bugs than mine. Where it fell short was somewhere else.&lt;/p&gt;

&lt;p&gt;Everything below comes from a pre-registered, reproducible experiment in &lt;a href="https://github.com/tayguara/playwright-qa-showcase/tree/experiment/ai-written-tests/experiments/ai-written-tests" rel="noopener noreferrer"&gt;playwright-qa-showcase&lt;/a&gt;. Every number is in its &lt;code&gt;results/&lt;/code&gt; and &lt;code&gt;prompts/&lt;/code&gt; folders, and you can regenerate the stub results on your own machine without any account or network.&lt;/p&gt;

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

&lt;p&gt;The target is &lt;a href="https://restful-booker.herokuapp.com" rel="noopener noreferrer"&gt;Restful Booker&lt;/a&gt;, a public practice API for hotel bookings. Three suites test the same seven behaviours: authentication, create and read back, search by name, full update with PUT, partial update with PATCH, PUT without a token is rejected and changes nothing, and DELETE removes the booking.&lt;/p&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;Written by&lt;/th&gt;
&lt;th&gt;How&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;H&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;me&lt;/td&gt;
&lt;td&gt;the 8 API tests already in the showcase&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;A&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;an AI agent&lt;/td&gt;
&lt;td&gt;an empty project, a plain prompt, no rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;B&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;the same agent&lt;/td&gt;
&lt;td&gt;the same project and prompt, plus a 7-rule &lt;code&gt;CLAUDE.md&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The agent was Claude Code 2.1.304 running Claude Sonnet 5.5, once per suite, with no retries and no edits from me. Both sessions developed against the real public API, not against my stub.&lt;/p&gt;

&lt;p&gt;The rules file for B is generic. It says: no hard waits; assert on what the API returns and on side effects, not only status codes; validate responses with a schema; each test creates and cleans its own data; cover negative and authorization paths; run the linter and the tests before declaring done; and write one line above each test saying which bug it would catch. It never mentions a field, an endpoint or any of the bugs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The instrument: ten bugs on a switch
&lt;/h2&gt;

&lt;p&gt;I wrote a small local copy of the API in plain Node, matched to the real one with a dated probe log (the real API has quirks, like answering 418 when the &lt;code&gt;Accept&lt;/code&gt; header is missing, and the stub reproduces them). Then I added ten faults, each behind an environment variable:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;GET returns the wrong &lt;code&gt;totalprice&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;GET drops &lt;code&gt;additionalneeds&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;PATCH also resets fields you did not send&lt;/li&gt;
&lt;li&gt;PUT without a token is accepted&lt;/li&gt;
&lt;li&gt;DELETE answers success but keeps the booking&lt;/li&gt;
&lt;li&gt;Search by name ignores the filter and returns everything&lt;/li&gt;
&lt;li&gt;Login returns a token for a wrong password&lt;/li&gt;
&lt;li&gt;Check-in and check-out come back swapped&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;depositpaid&lt;/code&gt; comes back as a string&lt;/li&gt;
&lt;li&gt;Every fifth request answers 500&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each suite runs once against the clean stub and once per fault. A fault counts as &lt;strong&gt;caught&lt;/strong&gt; if a test that passed on the clean stub now fails. A test that only fails and then passes on retry counts as flaky, not caught.&lt;/p&gt;

&lt;p&gt;I wrote the fault list and committed it, with the prompt, the rules and the stub, under a git tag &lt;em&gt;before&lt;/em&gt; the agent wrote a single test. I also wrote down a prediction for my own suite: 9 of 10, missing fault 6, because my search test only checks that the booking is &lt;em&gt;in&lt;/em&gt; the result. I had run my suite against the stub while building it, so for H this was a check, not a blind prediction. The pre-registration really covers the two agent suites.&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;&lt;/th&gt;
&lt;th&gt;H (mine)&lt;/th&gt;
&lt;th&gt;A (no rules)&lt;/th&gt;
&lt;th&gt;B (rules)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Faults caught&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;9 / 10&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;10 / 10&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;10 / 10&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pass rate, clean stub&lt;/td&gt;
&lt;td&gt;8 / 8&lt;/td&gt;
&lt;td&gt;8 / 8&lt;/td&gt;
&lt;td&gt;17 / 17&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pass rate, public API (one run)&lt;/td&gt;
&lt;td&gt;8 / 8&lt;/td&gt;
&lt;td&gt;8 / 8&lt;/td&gt;
&lt;td&gt;17 / 17&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Flaky over 5 repeats&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lint violations (my project's rules)&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;17&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Type errors (&lt;code&gt;tsc&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Weak assertions (checklist, hits)&lt;/td&gt;
&lt;td&gt;1 in 1 of 8 tests&lt;/td&gt;
&lt;td&gt;3 in 2 of 8 tests&lt;/td&gt;
&lt;td&gt;9 in 5 of 17 tests&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The prediction for my suite held exactly: 9 of 10, and the miss was fault 6.&lt;/p&gt;

&lt;h3&gt;
  
  
  The bug my suite missed
&lt;/h3&gt;

&lt;p&gt;This is my search test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;bookingSearchSchema&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="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bookingid&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toContain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;booking&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It proves the booking is found. It does not prove that &lt;em&gt;other&lt;/em&gt; bookings are left out. If the API ignores the filter and returns every id, my test still passes.&lt;/p&gt;

&lt;p&gt;Suite A, with no rules at all, added a second search with a last name that cannot exist:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;none&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/booking&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;firstname&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;firstname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;lastname&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`nobody&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nf"&gt;uniq&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;none&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;toEqual&lt;/span&gt;&lt;span class="p"&gt;([]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two lines, and fault 6 is caught. Suite B went further and wrote a separate test for it ("searching with a non-matching last name finds nothing"). This is the kind of negative check I tell teams to write, and I had skipped it in my own showcase.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where the agent fell short
&lt;/h3&gt;

&lt;p&gt;Not on the bugs. On the code.&lt;/p&gt;

&lt;p&gt;I ran both agent suites through the same ESLint rules my showcase enforces in CI (type-aware &lt;code&gt;typescript-eslint&lt;/code&gt; plus the Playwright plugin). Suite A had 17 errors, all from the same family: &lt;code&gt;no-unsafe-assignment&lt;/code&gt;, &lt;code&gt;no-unsafe-member-access&lt;/code&gt;, &lt;code&gt;no-unsafe-return&lt;/code&gt;. The cause is one habit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toBeTruthy&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;token&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;res.json()&lt;/code&gt; returns &lt;code&gt;any&lt;/code&gt;, and the agent kept reading fields from it without parsing. The tests work, &lt;code&gt;tsc&lt;/code&gt; is happy, and the code is untyped exactly where a contract change would hurt. Suite A also never ran a linter or a type check during its session.&lt;/p&gt;

&lt;p&gt;Suite B, told to "run the linter and the tests before declaring done" and to "validate response contracts", created its own ESLint config, ran &lt;code&gt;tsc&lt;/code&gt; and ESLint twice, and parsed responses with zod schemas in its helpers. Against my stricter rule set it still had 4 of the same errors, down from 17.&lt;/p&gt;

&lt;h3&gt;
  
  
  Weak assertions: the rules did not fix everything
&lt;/h3&gt;

&lt;p&gt;Catching a fault is one signal. The other is how each test asserts. I used an eight-item checklist, written before the runs: status-only checks, &lt;code&gt;toBeTruthy&lt;/code&gt; where the exact value is known, no read-back after a write, no contract validation, search checked only for inclusion, negative paths that never check the state, lenient status codes, and assertions that may never run.&lt;/p&gt;

&lt;p&gt;My suite had one hit, the search test above. Suite A had three, in two tests: a &lt;code&gt;toBeTruthy&lt;/code&gt; on the error reason and two response bodies read without any type check. Suite B, with the rules, had nine, in five of its seventeen tests. Most of them are in the negative tests it added: three check only a &lt;code&gt;404&lt;/code&gt; or &lt;code&gt;ok() === false&lt;/code&gt;, and two of those never verify that nothing changed.&lt;/p&gt;

&lt;p&gt;More tests meant more places to be shallow. The rules made the agent write negative tests; they did not make it finish them.&lt;/p&gt;

&lt;p&gt;One assertion in suite B is worth showing, even though the checklist pass left it out of the count:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;object&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;()&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="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reason&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bad credentials&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;not&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toHaveProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;token&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;z.object()&lt;/code&gt; drops unknown keys, so &lt;code&gt;body&lt;/code&gt; can never have a &lt;code&gt;token&lt;/code&gt;, and the last line can never fail. Suite B still caught the "login accepts any password" fault, but only because the faulty response had no &lt;code&gt;reason&lt;/code&gt; and the schema threw. The test caught the bug through a different line than the one written to catch it. A fault score alone would never show that.&lt;/p&gt;

&lt;h3&gt;
  
  
  How the two sessions behaved
&lt;/h3&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;A (no rules)&lt;/th&gt;
&lt;th&gt;B (rules)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Time&lt;/td&gt;
&lt;td&gt;32 s&lt;/td&gt;
&lt;td&gt;81 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Turns&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;Cost&lt;/td&gt;
&lt;td&gt;US$ 0.06&lt;/td&gt;
&lt;td&gt;US$ 0.14&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tests&lt;/td&gt;
&lt;td&gt;8 in one file&lt;/td&gt;
&lt;td&gt;17 in two files, plus a helpers file with fixtures&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ran lint and &lt;code&gt;tsc&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;td&gt;yes, twice&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Read the API docs&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Neither agent opened the documentation. Both relied on what the model already knew about this API, and both got the quirks right (DELETE answers 201, a PUT without a token answers 403).&lt;/p&gt;

&lt;p&gt;Suite B also hit a real API behaviour on its first run: a PUT that omits &lt;code&gt;additionalneeds&lt;/code&gt; keeps the old value. Its test failed, and the agent changed the test to always send the field and added a separate test marked &lt;code&gt;test.fail&lt;/code&gt; that documents the quirk. That is a reasonable call, and one I'd want to see in review: the agent turned a surprising behaviour into an expected failure on its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I take from it
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The rules file was cheap and it worked where it was aimed.&lt;/strong&gt; Seven generic lines cost 49 more seconds and 7 cents, and they moved the result in the direction I care about in a real codebase: typed responses, a lint config, a run of the tools before saying "done". They did not change the fault score, because the agent without rules already caught everything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My suite was not better because a human wrote it.&lt;/strong&gt; It was better in code quality because my project has rules in CI, and it was worse on one bug because I skipped a negative check. The agent did not have my blind spot. It had a different one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Measure before you trust, in both directions.&lt;/strong&gt; I would not have found the gap in my own search test without switching fault 6 on. I would not have seen the untyped response handling without running the agent's code through the same lint gate as mine. Reading the tests would not have shown me either gap; switching the faults on did.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this experiment does not show
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One run per suite.&lt;/strong&gt; Model output varies. This shows what one generation produced, not a rate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I wrote everything else.&lt;/strong&gt; The faults, the stub, the rules file and the checklist all come from the same person who wrote suite H. The faults are not a neutral sample of API bugs, and none of them touches status codes or validation errors, where broad negative tests would score more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fault 10 is almost free.&lt;/strong&gt; Any suite that makes five or more requests without retrying a 500 catches it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The lint rules are mine.&lt;/strong&gt; Neither agent was told about them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The agent probably knew this API.&lt;/strong&gt; Restful Booker is a popular practice API, and neither agent read its documentation yet both handled its quirks. A private API with no public docs could give a very different result.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The weak-assertion count&lt;/strong&gt; was first marked by an AI assistant that knew which suite was which, then reviewed and accepted by me. Borderline cases were not counted, and the second, blind AI rater in the original plan was not run.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Running an agent safely was its own project
&lt;/h2&gt;

&lt;p&gt;The part that took longest was not the experiment. It was running an AI agent on my own workstation without giving it my workstation.&lt;/p&gt;

&lt;p&gt;The agent reads data from a public sandbox that anyone can write to, so a prompt injection was a real possibility. My first isolation only blocked the file tool; the agent's shell could still read my home folder. The next version, built on bubblewrap, hid the files but shared my network, and a reviewer reached local database services from inside it. Then the Docker bridge addresses. Then the IPv6 link-local address. Then a symlink planted in the results folder that my own harness would have followed. The final version runs the agent in its own network namespace with &lt;code&gt;pasta&lt;/code&gt;, IPv4 only, private ranges blocked, a minimal environment, and a dedicated config folder. Every step is in the repository.&lt;/p&gt;

&lt;p&gt;One more surprise: SELinux on my machine silently replaced the prompt file with &lt;code&gt;/dev/null&lt;/code&gt; when it crossed into the sandbox. Without catching that in a control run, both sessions would have received an empty prompt.&lt;/p&gt;

&lt;p&gt;If you run coding agents on your own machine, assume they can see and reach everything you can, and test the boundary instead of trusting it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reproduce it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/tayguara/playwright-qa-showcase.git
&lt;span class="nb"&gt;cd &lt;/span&gt;playwright-qa-showcase &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; git checkout experiment/ai-written-tests &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm ci
npm run exp:faults &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm run exp:summary
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Suite H needs only Node 22. Suites A and B run inside a sandbox, so they need Linux with bubblewrap. The prompt, the rules, the transcripts of both sessions, the stub's fidelity log and every raw result are in the &lt;a href="https://github.com/tayguara/playwright-qa-showcase/tree/experiment/ai-written-tests/experiments/ai-written-tests" rel="noopener noreferrer"&gt;experiment folder&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>ai</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Running Playwright in GitHub Actions: named checks, sharding, one merged report, and a flakiness policy</title>
      <dc:creator>Tayguara Reis</dc:creator>
      <pubDate>Wed, 07 Oct 2026 17:22:57 +0000</pubDate>
      <link>https://dev.to/tayguara/running-playwright-in-github-actions-named-checks-sharding-one-merged-report-and-a-flakiness-4dk5</link>
      <guid>https://dev.to/tayguara/running-playwright-in-github-actions-named-checks-sharding-one-merged-report-and-a-flakiness-4dk5</guid>
      <description>&lt;p&gt;A test pipeline has one job: give the team a fast signal it can trust. When a pull request goes red, the author should know &lt;em&gt;what&lt;/em&gt; broke without opening a log. When it goes green, nobody should wonder whether a retry quietly hid a problem.&lt;/p&gt;

&lt;p&gt;This article walks through the pipeline of &lt;a href="https://github.com/tayguara/playwright-qa-showcase" rel="noopener noreferrer"&gt;playwright-qa-showcase&lt;/a&gt;, a small public repository I use to show how I set up test automation when I lead QA on a project. It has 56 tests: BDD UI flows against SauceDemo, typed API tests against Restful Booker, axe-core accessibility scans, and unit tests for the test-support code. Every snippet below is taken from the real files, shortened for reading. Every number comes from a real run.&lt;/p&gt;

&lt;h2&gt;
  
  
  One check per validation
&lt;/h2&gt;

&lt;p&gt;My first version had a single &lt;code&gt;Lint, typecheck, format&lt;/code&gt; job. It worked, but a red check told you only that "something in quality" failed. So I split it into five parallel jobs, each with its own &lt;code&gt;name:&lt;/code&gt;, and each shows up as its own check on the pull request:&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;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;lint&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Lint&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;timeout-minutes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v7&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;persist-credentials&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/setup-node@v7&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;node-version-file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.nvmrc&lt;/span&gt;
          &lt;span class="na"&gt;cache&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm ci&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm run lint&lt;/span&gt;
  &lt;span class="c1"&gt;# typecheck (Typecheck), format (Format), unit (Unit tests), gherkin (Gherkin): same shape&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;None of the five needs a browser. &lt;code&gt;Unit tests&lt;/code&gt; runs the pure-Node Playwright project that covers the helpers (money math, the accessibility baseline diff, a test data builder). &lt;code&gt;Gherkin&lt;/code&gt; runs &lt;code&gt;bddgen&lt;/code&gt;, which fails when a step has no definition, and then a guard I will come back to. In the real run of the PR that introduced this split, the five jobs finished in 10 to 18 seconds each.&lt;/p&gt;

&lt;p&gt;The browser tests wait for all of them:&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;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Tests (shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})&lt;/span&gt;
    &lt;span class="na"&gt;needs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;lint&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;typecheck&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;format&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;unit&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;gherkin&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Duplicating &lt;code&gt;checkout&lt;/code&gt;, &lt;code&gt;setup-node&lt;/code&gt; and &lt;code&gt;npm ci&lt;/code&gt; five times looks wasteful, and on paper it is. In practice the npm cache makes each copy cheap, and the payoff is a PR page that reads like a checklist. A composite action could remove the repetition. At five short jobs I chose readability over DRY.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sharding, and an honest note about it
&lt;/h2&gt;

&lt;p&gt;The browser suites (&lt;code&gt;ui&lt;/code&gt;, &lt;code&gt;a11y&lt;/code&gt;, &lt;code&gt;api&lt;/code&gt;) run as a two-shard matrix:&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;strategy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;fail-fast&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
      &lt;span class="na"&gt;matrix&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;shardIndex&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;2&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
        &lt;span class="na"&gt;shardTotal&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;2&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="c1"&gt;# checkout, setup-node, npm ci&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx playwright install --with-deps chromium&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx bddgen&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Run Playwright tests&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx playwright test --project=ui --project=a11y --project=api --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Upload blob report&lt;/span&gt;
        &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ !cancelled() }}&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/upload-artifact@v7&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;blob-report-${{ matrix.shardIndex }}&lt;/span&gt;
          &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;blob-report&lt;/span&gt;
          &lt;span class="na"&gt;retention-days&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
          &lt;span class="na"&gt;if-no-files-found&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three details matter. &lt;code&gt;fail-fast: false&lt;/code&gt; keeps one failing shard from cancelling the other, so you see every failure in one run instead of discovering them one at a time. The unit project is left out of the shards because it needs no browser and already ran in its own job. And &lt;code&gt;if-no-files-found: error&lt;/code&gt; makes a shard that produced no report fail loudly instead of silently shrinking the merged report.&lt;/p&gt;

&lt;p&gt;Now the honest part. At this size, sharding demonstrates the pattern; it does not save time. Each shard ran 14 tests. In that same run, the Playwright step took 7.3 seconds of test time per shard, while &lt;code&gt;playwright install --with-deps chromium&lt;/code&gt; took 58 seconds on one shard and 26 on the other. A single job would finish sooner than two jobs that each install a browser. I kept the matrix because the pattern is the point of the repository, and because scaling it is a one-line change: &lt;code&gt;shardIndex: [1, 2, 3, 4]&lt;/code&gt; with &lt;code&gt;shardTotal: [4]&lt;/code&gt;. On a real project I would add shards when test time, not setup time, dominates the job.&lt;/p&gt;

&lt;h2&gt;
  
  
  One merged report, plus a summary nobody has to download
&lt;/h2&gt;

&lt;p&gt;Sharding creates a reporting problem: two partial reports are worse than one. In CI the config uses the blob reporter (&lt;code&gt;reporter: isCI ? [['blob'], ['github'], ['list']] : ...&lt;/code&gt;), and a final job merges the blobs:&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;merge-reports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Merge reports&lt;/span&gt;
    &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ !cancelled() &amp;amp;&amp;amp; needs.test.result != 'skipped' }}&lt;/span&gt;
    &lt;span class="na"&gt;needs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="c1"&gt;# checkout, setup-node, npm ci&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/download-artifact@v8&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;all-blob-reports&lt;/span&gt;
          &lt;span class="na"&gt;pattern&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;blob-report-*&lt;/span&gt;
          &lt;span class="na"&gt;merge-multiple&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Merge into one HTML report&lt;/span&gt;
        &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;PLAYWRIGHT_HTML_OPEN&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;never&lt;/span&gt;
          &lt;span class="na"&gt;PLAYWRIGHT_JSON_OUTPUT_NAME&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ runner.temp }}/merged-results.json&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx playwright merge-reports --reporter html,json ./all-blob-reports&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;if:&lt;/code&gt; condition is the part people get wrong. The default &lt;code&gt;success()&lt;/code&gt; would skip this job exactly when you need the report most, after a shard failed. &lt;code&gt;always()&lt;/code&gt; goes too far: when &lt;code&gt;Lint&lt;/code&gt; fails, the shards are skipped and there is nothing to merge. &lt;code&gt;!cancelled() &amp;amp;&amp;amp; needs.test.result != 'skipped'&lt;/code&gt; covers both cases.&lt;/p&gt;

&lt;p&gt;The HTML report is uploaded as an artifact kept for 14 days. Downloading an artifact is friction, though, so a short inline Node script reads the merged JSON and writes a table to the job summary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;stats&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;RESULTS_JSON&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Passed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;expected&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Failed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;unexpected&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Flaky (passed on retry)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flaky&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Skipped&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;skipped&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 "Flaky" row is there on purpose. It is the bridge to the flakiness policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  A flakiness policy, enforced by config and lint
&lt;/h2&gt;

&lt;p&gt;"We don't tolerate flaky tests" is a slogan. A policy is something the tooling enforces. From &lt;code&gt;playwright.config.ts&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;forbidOnly&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;isCI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;isCI&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;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Retries are off locally, so keep the trace of a failure instead of waiting for a retry.&lt;/span&gt;
  &lt;span class="nl"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;isCI&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;on-first-retry&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;retain-on-failure&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;screenshot&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;only-on-failure&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Retries exist only in CI, so a flaky test is visible while you develop instead of being absorbed. &lt;code&gt;on-first-retry&lt;/code&gt; would never fire locally with zero retries, so locally the trace is kept on failure. &lt;code&gt;forbidOnly&lt;/code&gt; stops a stray &lt;code&gt;test.only&lt;/code&gt; from turning a full run into a one-test run.&lt;/p&gt;

&lt;p&gt;The trade-off I state openly: a test that passes on retry leaves the run green. That is why the summary shows the flaky count, and why the policy says it gets investigated. Someone has to own that number.&lt;/p&gt;

&lt;p&gt;Lint closes the usual escape hatches, with &lt;code&gt;eslint --max-warnings=0&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="nx"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;playwright/no-wait-for-timeout&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;playwright/no-skipped-test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;playwright/no-force-option&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hard waits, forced clicks and skipped tests are the three most common ways a flaky test gets "fixed" without being fixed. Gherkin has the same escape hatch in tags, so the &lt;code&gt;Gherkin&lt;/code&gt; job greps for it:&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="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Reject disabled scenarios&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;if grep -rnE '(^|[[:space:]])@(skip|fixme|only)([[:space:]]|$)' features --include='*.feature'; then&lt;/span&gt;
            &lt;span class="s"&gt;echo '::error::A scenario is disabled with @skip, @fixme or @only. Fix it or track it with @fail.'&lt;/span&gt;
            &lt;span class="s"&gt;exit 1&lt;/span&gt;
          &lt;span class="s"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A known product defect is tracked with &lt;code&gt;@fail&lt;/code&gt;, an expected failure that asserts the correct behavior, rather than hidden with &lt;code&gt;@skip&lt;/code&gt;. If the site gets fixed, Playwright reports it as unexpectedly passing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Supply chain and security, sized for a test repo
&lt;/h2&gt;

&lt;p&gt;Test repositories run code on every pull request, so they deserve the same hygiene as product code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;permissions: contents: read&lt;/code&gt; at the workflow level. Only the CodeQL job gets &lt;code&gt;security-events: write&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;persist-credentials: false&lt;/code&gt; on every checkout, so the token is not left in &lt;code&gt;.git/config&lt;/code&gt; for later steps.&lt;/li&gt;
&lt;li&gt;No &lt;code&gt;pull_request_target&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Pinned action versions. &lt;code&gt;dependency-review-action&lt;/code&gt; is pinned to &lt;code&gt;v5.0.0&lt;/code&gt; because the project publishes no floating &lt;code&gt;v5&lt;/code&gt; tag.&lt;/li&gt;
&lt;li&gt;A concurrency group with &lt;code&gt;cancel-in-progress: true&lt;/code&gt;, so a new push cancels the superseded run.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Three extra workflows add checks. &lt;code&gt;codeql.yml&lt;/code&gt; analyzes both &lt;code&gt;javascript-typescript&lt;/code&gt; and &lt;code&gt;actions&lt;/code&gt; (the workflow files themselves), on PRs, on pushes to &lt;code&gt;main&lt;/code&gt; and weekly. &lt;code&gt;dependency-review.yml&lt;/code&gt; fails a PR that adds a dependency with a known vulnerability of &lt;code&gt;moderate&lt;/code&gt; severity or worse. &lt;code&gt;actionlint.yml&lt;/code&gt; lints the workflows.&lt;/p&gt;

&lt;p&gt;Dependency review taught me a real lesson. Its first run failed with "Dependency review is not supported on this repository. Please ensure that Dependency graph is enabled". The YAML was correct; a repository setting was off. After enabling the Dependency graph, the re-run passed. A security check can depend on configuration that lives outside the repository, so check the settings page, not only the diff.&lt;/p&gt;

&lt;p&gt;actionlint is path-filtered to &lt;code&gt;.github/workflows/**&lt;/code&gt;, and that is exactly why it is not a required check. A workflow skipped by a path filter never reports, and a required check that never reports leaves every unrelated PR waiting on a pending status.&lt;/p&gt;

&lt;h2&gt;
  
  
  Branch protection, nightly runs and an honest badge
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;main&lt;/code&gt; requires ten checks: &lt;code&gt;Lint&lt;/code&gt;, &lt;code&gt;Typecheck&lt;/code&gt;, &lt;code&gt;Format&lt;/code&gt;, &lt;code&gt;Unit tests&lt;/code&gt;, &lt;code&gt;Gherkin&lt;/code&gt;, &lt;code&gt;Tests (shard 1/2)&lt;/code&gt;, &lt;code&gt;Tests (shard 2/2)&lt;/code&gt;, &lt;code&gt;CodeQL (javascript-typescript)&lt;/code&gt;, &lt;code&gt;CodeQL (actions)&lt;/code&gt; and &lt;code&gt;Dependency review&lt;/code&gt;. Dependency review can be required because it runs on every pull request; actionlint cannot, for the reason above. Named jobs make this list readable, and it is also why stable job names matter: rename a job and branch protection waits for a check that no longer exists. The shard names embed the shard count, so raising the matrix means updating this list too. &lt;code&gt;Merge reports&lt;/code&gt; stays optional, since the shards themselves already block the merge.&lt;/p&gt;

&lt;p&gt;The Playwright workflow also runs nightly (&lt;code&gt;cron: '0 6 * * *'&lt;/code&gt;) to catch drift in the public sandboxes. Those sandboxes go down from time to time, and I do not want that to make the project look broken. The README badge is filtered to push events:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;![Playwright&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;https://github.com/tayguara/playwright-qa-showcase/actions/workflows/playwright.yml/badge.svg?branch=main&amp;amp;event=push&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;](...)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The nightly run still reports failures in the Actions tab, where the team looks, while the badge reflects the state of the code on &lt;code&gt;main&lt;/code&gt;. GitHub also disables scheduled workflows after 60 days without repository activity, which is worth knowing before trusting a nightly job on a quiet repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dependabot, with two deliberate exceptions
&lt;/h2&gt;

&lt;p&gt;Dependabot updates npm packages and GitHub Actions weekly, grouped into one PR per ecosystem. Two major updates are ignored:&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;ignore&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="c1"&gt;# typescript-eslint does not support TypeScript 7 yet; revisit when it does.&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;dependency-name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;typescript&lt;/span&gt;
        &lt;span class="na"&gt;update-types&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;version-update:semver-major'&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
      &lt;span class="c1"&gt;# The project runs on Node 22 (.nvmrc); @types/node majors must follow the Node version.&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;dependency-name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;@types/node'&lt;/span&gt;
        &lt;span class="na"&gt;update-types&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;version-update:semver-major'&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;@types/node&lt;/code&gt; rule came from a real PR: Dependabot proposed 22.20.4 to 26.6.3, and CI passed. Green CI did not make it correct. Types for Node 26 on a Node 22 runtime let you compile calls to APIs that do not exist at runtime. I closed the PR, and closing a grouped PR does not ignore future versions, so the rule went into config. Automated updates need a human to decide which versions the project actually targets.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Give every validation its own named job. A PR check list that reads like a checklist saves more time than the duplicated setup costs.&lt;/li&gt;
&lt;li&gt;Shard when test time dominates, not before. Measure the browser install against the test step; here it was 26 to 58 seconds of setup against about 7 seconds of tests.&lt;/li&gt;
&lt;li&gt;Merge sharded reports with &lt;code&gt;!cancelled() &amp;amp;&amp;amp; needs.test.result != 'skipped'&lt;/code&gt;, and put a results table, including flaky count, in the job summary.&lt;/li&gt;
&lt;li&gt;Enforce the flakiness policy in tooling: retries only in CI, &lt;code&gt;forbidOnly&lt;/code&gt;, lint bans on hard waits, forced clicks and skips, and a guard for Gherkin tags.&lt;/li&gt;
&lt;li&gt;Treat the pipeline as product code: least-privilege tokens, pinned actions, required checks with stable names, and settings you verify, not assume.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;em&gt;Tayguara Dias Reis is a Tech Lead with 14+ years in software quality and ISTQB CTFL certification. The full pipeline is at &lt;a href="https://github.com/tayguara/playwright-qa-showcase" rel="noopener noreferrer"&gt;github.com/tayguara/playwright-qa-showcase&lt;/a&gt;. For the Jenkins side of the same ideas, see &lt;a href="https://dev.to/tayguara/from-scripted-to-declarative-what-10-years-of-jenkins-pipelines-taught-me-about-shared-libraries-2k40"&gt;From scripted to declarative: what 10+ years of Jenkins pipelines taught me about shared libraries and quality gates&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>githubactions</category>
      <category>cicd</category>
    </item>
    <item>
      <title>From scripted to declarative: what 10+ years of Jenkins pipelines taught me about shared libraries and quality gates</title>
      <dc:creator>Tayguara Reis</dc:creator>
      <pubDate>Sat, 03 Oct 2026 18:10:52 +0000</pubDate>
      <link>https://dev.to/tayguara/from-scripted-to-declarative-what-10-years-of-jenkins-pipelines-taught-me-about-shared-libraries-2k40</link>
      <guid>https://dev.to/tayguara/from-scripted-to-declarative-what-10-years-of-jenkins-pipelines-taught-me-about-shared-libraries-2k40</guid>
      <description>&lt;p&gt;I wrote my first Jenkins pipeline in 2016. Ten years later, the repository it started has more than 260 pipeline files: deploy jobs, end-to-end suites, a Selenium grid, health checks, scheduled maintenance. Most of them are scripted. A newer project, started in 2021, runs on six declarative pipelines and puts releases through a chain of quality gates before a blue-green deploy.&lt;/p&gt;

&lt;p&gt;This is not a syntax tutorial; the Jenkins documentation covers syntax well. It is about the decisions behind those files: why I started scripted, what shared libraries fixed, how I order quality gates, how blue-green rollback fits in, and when an old scripted job is worth migrating. Some of those decisions I would make differently today, and I will say which.&lt;/p&gt;

&lt;p&gt;The snippets below are simplified. A complete, runnable version of the same patterns lives in a public repository, &lt;a href="https://github.com/tayguara/jenkins-declarative-pipelines" rel="noopener noreferrer"&gt;jenkins-declarative-pipelines&lt;/a&gt;: a tested shared library, a declarative Jenkinsfile with quality gates and a simulated blue-green deploy, all started with &lt;code&gt;make up&lt;/code&gt; on Docker Compose.&lt;/p&gt;

&lt;h2&gt;
  
  
  2016: why I started scripted
&lt;/h2&gt;

&lt;p&gt;The honest reason is that I did not know the declarative syntax yet, and scripted felt easier. In an internal review at the end of that year I noted, half-jokingly, that the build script was written in Groovy only because Jenkins Pipeline required it. Scripted pipeline is Groovy with a few Jenkins steps: open a &lt;code&gt;node {}&lt;/code&gt;, split the work into &lt;code&gt;stage()&lt;/code&gt; blocks, call &lt;code&gt;sh&lt;/code&gt;. If you can write a loop and an &lt;code&gt;if&lt;/code&gt;, you can ship a pipeline on day one. There is no grammar to learn and no rule about where a block may appear.&lt;/p&gt;

&lt;p&gt;That freedom paid off at first. I could load a helper file, parse a JSON parameter into a map and generate stages from a list. In that first year the main product shipped around 1,000 production builds, about 2.7 a day. Parallelizing the end-to-end suite cut a production run from roughly 40–50 minutes to 6–8, and a development run from 90–100 minutes to 25–30. A small pre-checkout verification script cut checkout from about 4 minutes to 2 at most. For a small team, that speed mattered more than consistency.&lt;/p&gt;

&lt;p&gt;The cost showed up later, when other people had to read those jobs. Every pipeline had its own shape. Error handling lived in &lt;code&gt;try/catch&lt;/code&gt; blocks, and when I went back to my oldest jobs I found empty &lt;code&gt;catch&lt;/code&gt; blocks that swallowed exceptions, so a step could fail and the build would carry on as if nothing happened. Notification logic was duplicated in the success path and in the &lt;code&gt;catch&lt;/code&gt; block. It is a legacy pattern that no longer earns its keep, and the migration to declarative retires it: the &lt;code&gt;post&lt;/code&gt; conditions take over both jobs. For the first years, "reuse" meant &lt;code&gt;load&lt;/code&gt;-ing Groovy helper files from the same repository: better than copy-paste, but with no versioning and no clear boundary between helper and job.&lt;/p&gt;

&lt;p&gt;None of this is a flaw of scripted syntax itself. It lets you do anything, and nothing pushes back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Shared libraries as the backbone
&lt;/h2&gt;

&lt;p&gt;The change that mattered most in both eras was moving reusable logic into shared libraries. The first payoff was the end of copy-paste: pipelines with similar steps stopped carrying their own copies of the same code, and each step got one clear responsibility. The best example runs in every pipeline: the summary posted to Slack after each build. The logic that sanitizes and formats that message lives once in the library, and each pipeline only calls the notification step with its own project details.&lt;/p&gt;

&lt;p&gt;The layout that survived is one common library plus one library per product:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ci-common/                  # shared by most jobs
  vars/
    notifyBuild.groovy      # build summary to the chat channel
    runGate.groovy          # run a check, keep its report, fail with a clear message
    coverageGate.groovy
    loadEnvConfig.groovy
  src/com/example/ci/       # plain Groovy classes, when a step needs them
ci-payments/                # one per product, only what is specific to it
  vars/
    deployBlueGreen.groovy
    smokeCheck.groovy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The common library is imported by dozens of jobs; around ten product libraries sit next to it. Each file in &lt;code&gt;vars/&lt;/code&gt; becomes a global step that a Jenkinsfile calls by name. A step is a &lt;code&gt;call&lt;/code&gt; method that takes a map, so call sites read like configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight groovy"&gt;&lt;code&gt;&lt;span class="c1"&gt;// vars/runGate.groovy&lt;/span&gt;
&lt;span class="kt"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Map&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;      &lt;span class="c1"&gt;// e.g. 'Static analysis'&lt;/span&gt;
    &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;cmd&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;command&lt;/span&gt;   &lt;span class="c1"&gt;// exits non-zero on violations&lt;/span&gt;
    &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;report&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;report&lt;/span&gt;    &lt;span class="c1"&gt;// machine-readable output, read later by the summary&lt;/span&gt;

    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sh&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;script:&lt;/span&gt; &lt;span class="s2"&gt;"${cmd} &amp;gt; '${report}'"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;returnStatus:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&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;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"${name} gate failed (exit code ${status}). Findings: ${report}"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two rules decide what goes where. A library holds &lt;em&gt;how&lt;/em&gt;: how we run a gate, notify, or switch a blue-green slot. The Jenkinsfile holds &lt;em&gt;what&lt;/em&gt;: which gates this service runs, in which order, with which thresholds. Groovy repeated in two Jenkinsfiles belongs in a library; a value that differs per service never gets hardcoded in one.&lt;/p&gt;

&lt;p&gt;The second rule is versioning, and I learned it late. My Jenkinsfiles load libraries by name only, &lt;code&gt;@Library('ci-common') _&lt;/code&gt;, which means every job follows whatever default version is configured in Jenkins. That is convenient until a library change breaks a job nobody has touched in a year. Jenkins lets you pin a branch, tag or commit in the annotation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight groovy"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Library&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'ci-common@v3.4.0'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pin production pipelines to a tag, let a staging or canary job track the main branch, and bump the tag in a reviewed change. A shared library is a dependency like any other, and an unpinned dependency is a deploy you did not schedule. Pinning is on my own list: it comes with the migration, job by job.&lt;/p&gt;

&lt;h2&gt;
  
  
  2021: going declarative
&lt;/h2&gt;

&lt;p&gt;When I started the newer project in 2021, I wrote it declarative from day one. What changed was not the steps. &lt;code&gt;sh&lt;/code&gt;, &lt;code&gt;checkout&lt;/code&gt;, &lt;code&gt;junit&lt;/code&gt; and the library calls are the same. What changed is that the file now has a fixed shape:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight groovy"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Library&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'ci-common@v3.4.0'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;

&lt;span class="n"&gt;pipeline&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;agent&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="s1"&gt;'linux'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;time:&lt;/span&gt; &lt;span class="mi"&gt;45&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;unit:&lt;/span&gt; &lt;span class="s1"&gt;'MINUTES'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;timestamps&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;disableConcurrentBuilds&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;parameters&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;name:&lt;/span&gt; &lt;span class="s1"&gt;'TARGET_ENV'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;choices:&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'staging'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'production'&lt;/span&gt;&lt;span class="o"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;name:&lt;/span&gt; &lt;span class="s1"&gt;'GIT_REF'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;defaultValue:&lt;/span&gt; &lt;span class="s1"&gt;'main'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;booleanParam&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;name:&lt;/span&gt; &lt;span class="s1"&gt;'ROLLBACK'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;defaultValue:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;environment&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;APP_DIR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"${WORKSPACE}/app"&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;stages&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;stage&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Static analysis'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;when&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;not&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;expression&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ROLLBACK&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
            &lt;span class="n"&gt;steps&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;runGate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;name:&lt;/span&gt; &lt;span class="s1"&gt;'Static analysis'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                        &lt;span class="nl"&gt;command:&lt;/span&gt; &lt;span class="s1"&gt;'make static-analysis'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                        &lt;span class="nl"&gt;report:&lt;/span&gt; &lt;span class="s1"&gt;'reports/static-analysis.json'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="c1"&gt;// more gates, then deploy&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;post&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;always&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;junit&lt;/span&gt; &lt;span class="nl"&gt;allowEmptyResults:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;testResults:&lt;/span&gt; &lt;span class="s1"&gt;'reports/junit/*.xml'&lt;/span&gt;
            &lt;span class="n"&gt;notifyBuild&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;reportsDir:&lt;/span&gt; &lt;span class="s1"&gt;'reports'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;// result comes from currentBuild.currentResult&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What I gained, in order of how much it mattered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Readability for people who did not write it.&lt;/strong&gt; A new engineer finds the timeout, the parameters and the failure handling in the same place in every job.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;post&lt;/code&gt; instead of &lt;code&gt;try/catch&lt;/code&gt;.&lt;/strong&gt; &lt;code&gt;always&lt;/code&gt;, &lt;code&gt;success&lt;/code&gt;, &lt;code&gt;failure&lt;/code&gt;, &lt;code&gt;unstable&lt;/code&gt;, &lt;code&gt;fixed&lt;/code&gt;, &lt;code&gt;regression&lt;/code&gt;, &lt;code&gt;aborted&lt;/code&gt; and &lt;code&gt;cleanup&lt;/code&gt; replace the hand-written error paths. Notification moved out of &lt;code&gt;catch&lt;/code&gt; blocks and could no longer be skipped by an exception thrown in the wrong place.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;when&lt;/code&gt; instead of &lt;code&gt;if&lt;/code&gt;.&lt;/strong&gt; A stage skipped by &lt;code&gt;when&lt;/code&gt; still appears in the stage view, marked as skipped, so the run tells you what it chose not to do.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;options&lt;/code&gt; as policy.&lt;/strong&gt; A timeout, timestamps and no concurrent deploys are one line each, and their absence is visible in review.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validation before running.&lt;/strong&gt; The declarative linter (the &lt;code&gt;declarative-linter&lt;/code&gt; command in the Jenkins CLI, or a POST to the controller's &lt;code&gt;pipeline-model-converter/validate&lt;/code&gt; endpoint) catches structural mistakes before a build starts. Scripted pipeline only tells you at runtime.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The escape hatch is &lt;code&gt;script {}&lt;/code&gt;, which runs scripted Groovy inside a declarative step. My first declarative pipeline leaned on it far too much: most stages were a &lt;code&gt;script {}&lt;/code&gt; block that returned early on a rollback run. It was scripted pipeline in declarative clothing, and the stage view showed those stages as green although they did nothing. The &lt;code&gt;when&lt;/code&gt; condition above is what I would write today, and rewriting those stages is part of the same improvement plan. The Jenkins docs agree: when a &lt;code&gt;script {}&lt;/code&gt; block grows, move it into a library step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quality gates before a blue-green deploy
&lt;/h2&gt;

&lt;p&gt;The newer project's quality gates live in three places, and where each one runs turned out to matter as much as what it checks. They were added one at a time over several years, not designed up front, and the complexity gate is the most recent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In the deploy pipeline, before anything is copied to a server:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Code style&lt;/strong&gt; (a formatter in dry-run mode)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Static analysis&lt;/strong&gt; (type and bug checks)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automated refactoring check&lt;/strong&gt; (a refactoring tool in dry-run mode: if it would change the code, the code is not up to the agreed standard)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unit tests&lt;/strong&gt;, with coverage collected&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Coverage threshold&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Complexity risk (CRAP)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;In the application repository's own CI:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Mutation testing&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;In separate jobs that run after the deploy:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;End-to-end tests&lt;/strong&gt; against the deployed environment, plus a dedicated security test job&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The order inside the deploy pipeline follows one rule: cheap and fast first. Style and static analysis need seconds and no database, so they fail a bad commit before anything expensive starts. Coverage and complexity read the report the unit tests produce, so they cost almost nothing extra.&lt;/p&gt;

&lt;p&gt;The two most expensive checks moved out of the deploy pipeline, for the same reason. Mutation testing re-runs the suite against many small mutations of the code. It started as the last stage of the deploy pipeline and made every build wait, so I moved it out of Jenkins and into a pipeline in the application repository itself, on GitLab CI, where it runs without holding a release hostage. End-to-end tests went the same way: they used to sit inside the deploy pipeline, and now a separate job runs them after each deploy, next to a security test job. The gates still exist; they just run where their cost does not block a deploy. That is a lesson in itself: a gate that makes releases slow enough that people want to skip it is a gate in the wrong place, not a gate to delete.&lt;/p&gt;

&lt;p&gt;The CRAP gate deserves a sentence of explanation, because coverage alone misleads. CRAP (Change Risk Anti-Patterns) combines cyclomatic complexity with coverage per method: &lt;code&gt;CRAP = complexity² × (1 − coverage)³ + complexity&lt;/code&gt;. A simple method with no tests scores low; a complex method with poor coverage scores very high. The gate fails the build when a method crosses the threshold, which catches the case a global coverage number hides: 90% overall, and the one complex method that matters is untested. The gates earn their keep in a very human situation. More than once, a developer told QA something like "Relax, I already validated everything in this task, you can skip testing and ship it straight to production." We took the advice, started the build, and the gates failed, keeping broken code out of production. That is the point of a gate: a cheap layer of safety that does not depend on anyone's confidence, including mine.&lt;/p&gt;

&lt;p&gt;Every gate follows the same pattern: write a machine-readable report, then decide pass or fail with a message a human can act on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight groovy"&gt;&lt;code&gt;&lt;span class="c1"&gt;// vars/coverageGate.groovy (simplified; the repository parses the XML in a tested class)&lt;/span&gt;
&lt;span class="kt"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Map&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;BigDecimal&lt;/span&gt; &lt;span class="n"&gt;min&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;min&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;BigDecimal&lt;/span&gt;          &lt;span class="c1"&gt;// e.g. 80&lt;/span&gt;
    &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sh&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;returnStdout:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;script:&lt;/span&gt; &lt;span class="s2"&gt;"xmllint --xpath 'string(/coverage/@line-rate)' '${args.report}'"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;trim&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;BigDecimal&lt;/span&gt; &lt;span class="n"&gt;actual&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;BigDecimal&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;

    &lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Line coverage: ${actual}% (minimum ${min}%)"&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;actual&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Coverage gate: line coverage ${actual}% is below the ${min}% minimum. "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
              &lt;span class="s2"&gt;"Add tests or lower the threshold in a reviewed change."&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The report-first habit pays off in the summary. In &lt;code&gt;post { always }&lt;/code&gt;, a library step reads each report that exists and builds one message for the team channel: style, static analysis and refactoring findings, tests run and failed, coverage, the top CRAP score, plus the commit, who started the build and the duration. When a gate fails, the message still shows what every earlier gate found, so nobody opens the console log to learn whether it was one style issue or forty.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blue-green with rollback
&lt;/h3&gt;

&lt;p&gt;Blue-green is older than my declarative pipelines. The first version shipped in 2017, in a scripted pipeline, inspired by Jez Humble and Dave Farley's &lt;em&gt;Continuous Delivery&lt;/em&gt;. The goals I wrote down at the time still hold: faster builds and rollbacks, more control over what reaches users, and lower downtime risk. When I wrote the declarative pipeline in 2021, I reused the same pattern almost step for step. The technique outlived the syntax change, which is the point: blue-green and rollback are architecture, not a scripted-versus-declarative feature.&lt;/p&gt;

&lt;p&gt;Production keeps two release directories, blue and green, and one pointer to the live one (a symlink, or the web server's root setting). A deploy goes like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read which color is live. The idle one is the target.&lt;/li&gt;
&lt;li&gt;Copy the release, already through the gates, into the idle directory.&lt;/li&gt;
&lt;li&gt;Run migrations, warm the cache and, ideally, smoke-check the idle side.&lt;/li&gt;
&lt;li&gt;Switch the symlink atomically to the idle directory and reload the PHP and web server processes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Rollback is the same switch in reverse. Since 2017 it has been a build parameter: a rollback run skips tests, file changes and library updates, and points the live pointer back at the previous slot, which still holds the previous release. No new build and no copy, so it is the fastest run the pipeline has.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight groovy"&gt;&lt;code&gt;&lt;span class="c1"&gt;// vars/deployBlueGreen.groovy (simplified)&lt;/span&gt;
&lt;span class="kt"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Map&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;live&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sh&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;returnStdout:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;script:&lt;/span&gt; &lt;span class="s2"&gt;"basename \"\$(readlink -f '${args.currentLink}')\""&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;trim&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;   &lt;span class="c1"&gt;// 'blue' or 'green'&lt;/span&gt;
    &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;live&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'blue'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'green'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'blue'&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;rollback&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;sh&lt;/span&gt; &lt;span class="s2"&gt;"rsync -a --delete --exclude=.env build/ '${args.releasesDir}/${target}/'"&lt;/span&gt;
        &lt;span class="n"&gt;smokeCheck&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;slot:&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// ln -sfn alone removes the old link before creating the new one;&lt;/span&gt;
    &lt;span class="c1"&gt;// building a temporary link and renaming it over the old one is atomic&lt;/span&gt;
    &lt;span class="n"&gt;sh&lt;/span&gt; &lt;span class="s2"&gt;"ln -sfn '${args.releasesDir}/${target}' '${args.currentLink}.next' &amp;amp;&amp;amp; "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
       &lt;span class="s2"&gt;"mv -Tf '${args.currentLink}.next' '${args.currentLink}'"&lt;/span&gt;
    &lt;span class="n"&gt;sh&lt;/span&gt; &lt;span class="s1"&gt;'sudo systemctl reload php-fpm nginx'&lt;/span&gt;
    &lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Live color is now ${target} (was ${live})"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A detail worth knowing: &lt;code&gt;ln -sfn&lt;/code&gt; on its own is not atomic. It deletes the old link and then creates the new one, so for a moment there is no live release. Creating the new link under a temporary name and renaming it with &lt;code&gt;mv -T&lt;/code&gt; closes that window, because a rename replaces the old link in a single step.&lt;/p&gt;

&lt;p&gt;Three caveats I would put in any design review. First, rollback goes back exactly one release; after two deploys, the old one is gone. Second, the symlink rolls back code, not data: migrations must be backward-compatible (expand first, contract in a later release), or the old code will meet a schema it does not understand. Third, keep one source of truth for which color is live. Reading the symlink, as above, beats a separate marker file that can drift from reality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Environment config without secrets
&lt;/h2&gt;

&lt;p&gt;The pipeline is the same for every environment; only the config changes. A parameter picks the environment, and a library step loads a small per-environment file with hosts, paths and switches. I have used Groovy files that return a map for this. Today I would use YAML read with &lt;code&gt;readYaml&lt;/code&gt;, because config should be data, and data cannot execute code.&lt;/p&gt;

&lt;p&gt;Secrets never live in those files, and never in the repository. Database passwords, API tokens and SSH keys belong in Jenkins Credentials (or a vault, with a Jenkins integration) and enter the build only for the step that needs them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight groovy"&gt;&lt;code&gt;&lt;span class="kt"&gt;def&lt;/span&gt; &lt;span class="n"&gt;cfg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;loadEnvConfig&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;TARGET_ENV&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;// hosts, paths, app env: no secrets&lt;/span&gt;

&lt;span class="n"&gt;withCredentials&lt;/span&gt;&lt;span class="o"&gt;([&lt;/span&gt;&lt;span class="n"&gt;usernamePassword&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;credentialsId:&lt;/span&gt; &lt;span class="s2"&gt;"db-${params.TARGET_ENV}"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                                  &lt;span class="nl"&gt;usernameVariable:&lt;/span&gt; &lt;span class="s1"&gt;'DB_USER'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                                  &lt;span class="nl"&gt;passwordVariable:&lt;/span&gt; &lt;span class="s1"&gt;'DB_PASS'&lt;/span&gt;&lt;span class="o"&gt;)])&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;sh&lt;/span&gt; &lt;span class="s1"&gt;'./bin/migrate'&lt;/span&gt;   &lt;span class="c1"&gt;// reads DB_USER/DB_PASS from env&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the single quotes in &lt;code&gt;sh&lt;/code&gt;. With double quotes, Groovy interpolates the secret into the command string; with single quotes, the shell reads it from the environment and Jenkins can mask it in the log. In declarative, &lt;code&gt;credentials('id')&lt;/code&gt; inside &lt;code&gt;environment {}&lt;/code&gt; does the same for a whole stage. One credential ID per environment keeps a staging job away from production secrets.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scripted vs declarative: where each one is stronger
&lt;/h2&gt;

&lt;p&gt;Both run on the same Pipeline engine. Declarative is parsed into the same CPS-transformed execution, so the Groovy sandbox, script approvals, serialization rules and &lt;code&gt;@NonCPS&lt;/code&gt; limits apply to both, and so does everything inside a &lt;code&gt;script {}&lt;/code&gt; block or a library step.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Scripted&lt;/th&gt;
&lt;th&gt;Declarative&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Learning curve&lt;/td&gt;
&lt;td&gt;Low to start if you know Groovy; the hard parts (CPS, serialization, sandbox) show up later&lt;/td&gt;
&lt;td&gt;A fixed set of directives to learn; the same engine limits still apply underneath&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Readability and onboarding&lt;/td&gt;
&lt;td&gt;Depends entirely on the author's discipline&lt;/td&gt;
&lt;td&gt;Same sections in the same order in every file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Structure enforcement&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Required &lt;code&gt;agent&lt;/code&gt;, &lt;code&gt;stages&lt;/code&gt;, &lt;code&gt;steps&lt;/code&gt;; directives only where allowed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Validation before running&lt;/td&gt;
&lt;td&gt;Groovy compile errors only, at build start&lt;/td&gt;
&lt;td&gt;Linter via CLI or HTTP endpoint, plus full structure validation before the first stage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dynamic logic (loops, generated stages)&lt;/td&gt;
&lt;td&gt;Full Groovy: generate stages and parallel branches from data&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;matrix&lt;/code&gt;, &lt;code&gt;parallel&lt;/code&gt; and &lt;code&gt;when&lt;/code&gt; cover common cases; the rest needs &lt;code&gt;script {}&lt;/code&gt; or a library&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Error handling&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;try/catch/finally&lt;/code&gt;, explicit and easy to get wrong&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;post&lt;/code&gt; conditions per pipeline and per stage; &lt;code&gt;catchError&lt;/code&gt; and &lt;code&gt;warnError&lt;/code&gt; work in both&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Restart from stage&lt;/td&gt;
&lt;td&gt;Not available (Replay only)&lt;/td&gt;
&lt;td&gt;Restart any top-level stage of a completed run, with the same parameters and SCM revision&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tooling and visualization&lt;/td&gt;
&lt;td&gt;Stages appear in the stage views; conditionally skipped stages just disappear&lt;/td&gt;
&lt;td&gt;Same views, plus &lt;code&gt;when&lt;/code&gt;-skipped stages shown as skipped; Directive Generator in the UI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reuse via shared libraries&lt;/td&gt;
&lt;td&gt;Call any library step or class&lt;/td&gt;
&lt;td&gt;Call library steps in &lt;code&gt;steps&lt;/code&gt;, or expose an entire pipeline as a template step (one declarative pipeline per build)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Testability&lt;/td&gt;
&lt;td&gt;JenkinsPipelineUnit&lt;/td&gt;
&lt;td&gt;JenkinsPipelineUnit (&lt;code&gt;DeclarativePipelineTest&lt;/code&gt;); in both worlds, library steps are the easiest unit to test&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The template option deserves a note. A &lt;code&gt;vars/&lt;/code&gt; step can contain a whole &lt;code&gt;pipeline {}&lt;/code&gt; block, so a service's Jenkinsfile shrinks to one call. That is the strongest standardization tool Jenkins has, and the most rigid: an exception for one team becomes a parameter for all of them. I use it when the gate chain must be identical across teams, not as a default.&lt;/p&gt;

&lt;h2&gt;
  
  
  When to migrate, and how to do it safely
&lt;/h2&gt;

&lt;p&gt;Migrating my scripted base to declarative is my own next step, so this section is the plan I am following, not a retrospective.&lt;/p&gt;

&lt;p&gt;Signals that it is time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;People who did not write the pipelines now maintain them, and every job reads differently.&lt;/li&gt;
&lt;li&gt;The same blocks are copied between jobs, and a fix has to be applied in several places.&lt;/li&gt;
&lt;li&gt;You need restart-from-stage or clearer visualization to recover from flaky infrastructure without re-running everything.&lt;/li&gt;
&lt;li&gt;You want the same gates across teams, enforced, not suggested.&lt;/li&gt;
&lt;li&gt;An audit needs to see, quickly, what runs before production.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Reasons not to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The pipeline generates its stages from data in loops. Declarative will push most of it into &lt;code&gt;script {}&lt;/code&gt;, and you gain little.&lt;/li&gt;
&lt;li&gt;The job is stable, rarely changes and nobody touches it. Migration risk with no payoff.&lt;/li&gt;
&lt;li&gt;You have no time to test the new job against the old one. An untested migration of a deploy pipeline is a production incident on a timer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How to do it safely:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Inventory and classify.&lt;/strong&gt; List every job, when it last ran, who owns it, whether it deploys, and how many jobs share its pattern. Delete what is dead first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Move logic into library steps first.&lt;/strong&gt; While the job is still scripted, extract the shared blocks into &lt;code&gt;vars/&lt;/code&gt; steps and switch the scripted job to call them. This is the riskiest change, and it happens with the old shape still in place.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Migrate one job per sprint,&lt;/strong&gt; starting with the most-copied pattern. The first migration becomes the template for the next ten.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run old and new side by side.&lt;/strong&gt; Point the new job at a non-production target, or run it with deploy steps disabled, and compare results for a few cycles.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep &lt;code&gt;script {}&lt;/code&gt; for the genuinely hard parts,&lt;/strong&gt; and move each of those into a library step later. Do not block the migration on making it pure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add a linter step&lt;/strong&gt; to the library repository and to the pipeline repository, so a broken Jenkinsfile fails review, not the deploy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Freeze, then delete.&lt;/strong&gt; Disable the old job, keep it for one release cycle, then remove it. Two live versions of the same deploy is how drift starts.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Start with whatever lets you ship, but expect to pay for structure later. Scripted made me fast in 2016 and expensive to read years later.&lt;/li&gt;
&lt;li&gt;Put the &lt;em&gt;how&lt;/em&gt; in shared libraries and the &lt;em&gt;what&lt;/em&gt; in the Jenkinsfile, and pin library versions in production pipelines.&lt;/li&gt;
&lt;li&gt;Order quality gates from cheap to expensive, write a report before deciding pass or fail, and summarize every gate in one message, even on failure.&lt;/li&gt;
&lt;li&gt;Blue-green and rollback are architecture, not syntax: the same pattern survived the move from scripted to declarative. Keep migrations backward-compatible, or rollback only rolls back half the system.&lt;/li&gt;
&lt;li&gt;Migrate scripted to declarative when people, copy-paste or compliance demand it, one job at a time, logic into libraries first.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;em&gt;Tayguara Dias Reis is a Tech Lead with 14+ years in software quality and ISTQB CTFL certification. He writes about test automation and CI at dev.to/tayguara. The code from this article runs end to end in &lt;a href="https://github.com/tayguara/jenkins-declarative-pipelines" rel="noopener noreferrer"&gt;jenkins-declarative-pipelines&lt;/a&gt;. For the GitHub Actions side of the same ideas, see the public &lt;a href="https://github.com/tayguara/playwright-qa-showcase" rel="noopener noreferrer"&gt;playwright-qa-showcase&lt;/a&gt; repository; the next article in this series covers it.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>jenkins</category>
      <category>cicd</category>
      <category>devops</category>
      <category>testing</category>
    </item>
    <item>
      <title>BDD with Playwright: Gherkin scenarios that business people can actually read</title>
      <dc:creator>Tayguara Reis</dc:creator>
      <pubDate>Thu, 01 Oct 2026 13:25:21 +0000</pubDate>
      <link>https://dev.to/tayguara/bdd-with-playwright-gherkin-scenarios-that-business-people-can-actually-read-om9</link>
      <guid>https://dev.to/tayguara/bdd-with-playwright-gherkin-scenarios-that-business-people-can-actually-read-om9</guid>
      <description>&lt;p&gt;I have written and maintained end-to-end suites with Cucumber on top of Playwright, using the cucumber-js runner. It works, but two risks show up in every Gherkin suite. Either the feature files turn into click-scripts with a Given/When/Then prefix ("When I click the button with id continue"), so nobody outside engineering reads them, or the step layer grows into a second framework with its own world object, its own retries and its own reporting, rebuilt next to a test runner that already does all of that.&lt;/p&gt;

&lt;p&gt;Gherkin is worth it only when a product owner can read a scenario and say "yes, that is the rule." Everything below comes from a small public repository I maintain, &lt;a href="https://github.com/tayguara/playwright-qa-showcase" rel="noopener noreferrer"&gt;playwright-qa-showcase&lt;/a&gt;, which runs 10 Gherkin scenarios (16 tests once the outlines expand) against the SauceDemo store with Playwright 1.63 and playwright-bdd 9.2.1.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why playwright-bdd instead of cucumber-js
&lt;/h2&gt;

&lt;p&gt;playwright-bdd does not run your scenarios in a separate runner. &lt;code&gt;bddgen&lt;/code&gt; compiles the &lt;code&gt;.feature&lt;/code&gt; files into ordinary Playwright spec files, and the Playwright test runner executes them. That one decision gives you everything the runner already does well: fixtures, full parallelism, traces, the HTML report, retries, sharding and blob-report merging in CI.&lt;/p&gt;

&lt;p&gt;The whole BDD setup is a few lines in &lt;code&gt;playwright.config.ts&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// BDD is used for the UI project only. `bddgen` turns the .feature files into Playwright specs.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;uiTestDir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;defineBddConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;features&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;features/**/*.feature&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;features/steps/**/*.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/fixtures/ui.fixtures.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;outputDir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.features-gen/ui&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;ui&lt;/code&gt; project then points &lt;code&gt;testDir&lt;/code&gt; at &lt;code&gt;uiTestDir&lt;/code&gt;, and the same config keeps &lt;code&gt;trace: 'on-first-retry'&lt;/code&gt; in CI and &lt;code&gt;'retain-on-failure'&lt;/code&gt; locally. Gherkin tags become native Playwright tags, so &lt;code&gt;npx playwright test --grep @smoke&lt;/code&gt; selects the two smoke scenarios with no extra tooling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where BDD pays off, and where it does not
&lt;/h2&gt;

&lt;p&gt;The repository has four Playwright projects, and only one of them uses Gherkin:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;UI business flows (login, inventory, checkout):&lt;/strong&gt; Gherkin. A readable scenario is useful to non-engineers, and the steps are reused across features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API tests:&lt;/strong&gt; plain Playwright. Their value is in assertions on status codes, headers and payload contracts. "Then the response status is 200" adds a translation layer without adding clarity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accessibility checks:&lt;/strong&gt; plain Playwright. The interesting output is a list of axe rule ids per page, not a sentence.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unit tests for test helpers:&lt;/strong&gt; plain Playwright, no browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the first judgment call I make on any engagement. BDD is a communication tool. Where there is no one to communicate with outside engineering, it is overhead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing steps in business language
&lt;/h2&gt;

&lt;p&gt;Here is the core checkout scenario:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="nt"&gt;@smoke&lt;/span&gt;
&lt;span class="kn"&gt;Scenario&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;A &lt;/span&gt;shopper completes a purchase end to end
  &lt;span class="err"&gt;Given the cart contains the following products&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nv"&gt;product&lt;/span&gt;               &lt;span class="p"&gt;|&lt;/span&gt;
    &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;Sauce&lt;/span&gt; &lt;span class="n"&gt;Labs&lt;/span&gt; &lt;span class="n"&gt;Backpack&lt;/span&gt;   &lt;span class="p"&gt;|&lt;/span&gt;
    &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;Sauce&lt;/span&gt; &lt;span class="n"&gt;Labs&lt;/span&gt; &lt;span class="n"&gt;Bike&lt;/span&gt; &lt;span class="n"&gt;Light&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
  &lt;span class="nf"&gt;When &lt;/span&gt;I open the cart
  &lt;span class="nf"&gt;And &lt;/span&gt;I start the checkout
  &lt;span class="nf"&gt;And &lt;/span&gt;I submit valid shipping information
  &lt;span class="nf"&gt;Then &lt;/span&gt;the order overview lists the same products
  &lt;span class="nf"&gt;And &lt;/span&gt;the item total equals the sum of the item prices
  &lt;span class="nf"&gt;And &lt;/span&gt;the order total equals the item total plus tax
  &lt;span class="nf"&gt;When &lt;/span&gt;I finish the order
  &lt;span class="nf"&gt;Then &lt;/span&gt;I see the order confirmation &lt;span class="s"&gt;"Thank you for your order!"&lt;/span&gt;
  &lt;span class="nf"&gt;And &lt;/span&gt;the cart badge is not shown
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are no selectors, no field names and no test data that does not matter to the rule. "I submit valid shipping information" is declarative: the step knows what valid means (a synthetic &lt;code&gt;Ada / Lovelace / 12345&lt;/code&gt; record in &lt;code&gt;src/data/checkoutData.ts&lt;/code&gt;). The imperative version, three "When I fill ..." lines, would tell a reader nothing new and break the scenario every time the form changes.&lt;/p&gt;

&lt;p&gt;When the variation &lt;em&gt;is&lt;/em&gt; the rule, I spell it out, and a Scenario Outline keeps it to one scenario:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="kn"&gt;Scenario Outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;Required shipping fields are validated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;case&amp;gt;&lt;/span&gt;
  &lt;span class="err"&gt;...&lt;/span&gt;
  &lt;span class="nf"&gt;When &lt;/span&gt;I submit the shipping form with first name &lt;span class="s"&gt;"&amp;lt;first_name&amp;gt;"&lt;/span&gt;, last name &lt;span class="s"&gt;"&amp;lt;last_name&amp;gt;"&lt;/span&gt; and postal code &lt;span class="s"&gt;"&amp;lt;postal_code&amp;gt;"&lt;/span&gt;
  &lt;span class="nf"&gt;Then &lt;/span&gt;I see the checkout error &lt;span class="s"&gt;"&amp;lt;error&amp;gt;"&lt;/span&gt;
  &lt;span class="nf"&gt;And &lt;/span&gt;I am still on the shipping information step

  &lt;span class="nn"&gt;Examples&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nv"&gt;case&lt;/span&gt;                &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nv"&gt;first_name&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nv"&gt;last_name&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nv"&gt;postal_code&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nv"&gt;error&lt;/span&gt;                          &lt;span class="p"&gt;|&lt;/span&gt;
    &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;missing&lt;/span&gt; &lt;span class="n"&gt;first&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;  &lt;span class="p"&gt;|&lt;/span&gt;            &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;Lovelace&lt;/span&gt;  &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;12345&lt;/span&gt;       &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;Error:&lt;/span&gt; &lt;span class="n"&gt;First&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="n"&gt;is&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="n"&gt;missing&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;   &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;Ada&lt;/span&gt;        &lt;span class="p"&gt;|&lt;/span&gt;           &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;12345&lt;/span&gt;       &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;Error:&lt;/span&gt; &lt;span class="n"&gt;Last&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="n"&gt;is&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="n"&gt;missing&lt;/span&gt; &lt;span class="n"&gt;postal&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;Ada&lt;/span&gt;        &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;Lovelace&lt;/span&gt;  &lt;span class="p"&gt;|&lt;/span&gt;             &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="n"&gt;Error:&lt;/span&gt; &lt;span class="n"&gt;Postal&lt;/span&gt; &lt;span class="n"&gt;Code&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;required&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two smaller choices matter as much as the wording. In the sorting outline, "Name (A to Z)" is deliberately left out of the examples, with a comment explaining why: it is the default order, so it would pass even if the sort control did nothing. And the login outline says "a  password" (&lt;code&gt;valid&lt;/code&gt;, &lt;code&gt;wrong&lt;/code&gt;, &lt;code&gt;empty&lt;/code&gt;) instead of putting the password in the feature file. The step maps the kind to a value, and the real password stays in &lt;code&gt;config/env.ts&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixtures and page objects, injected into steps
&lt;/h2&gt;

&lt;p&gt;Steps never construct page objects. They receive them as Playwright fixtures, which &lt;code&gt;createBdd&lt;/code&gt; binds to &lt;code&gt;Given&lt;/code&gt;/&lt;code&gt;When&lt;/code&gt;/&lt;code&gt;Then&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;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;UiFixtures&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;inventoryPage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;InventoryPage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;checkoutOverviewPage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CheckoutOverviewPage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// ...one fixture per page object, plus the header component&lt;/span&gt;
  &lt;span class="na"&gt;scenario&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;cartProducts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Given&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;When&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Then&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createBdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;scenario&lt;/code&gt; fixture replaces the Cucumber "world". It holds state shared between the steps of one scenario, here the products added to the cart, and because it is test-scoped it cannot leak into another test. A step asks only for what it needs:&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="nc"&gt;When&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I add {string} to the cart&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;inventoryPage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;scenario&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;productName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;inventoryPage&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="nx"&gt;productName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;scenario&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cartProducts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;productName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nc"&gt;Then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;the order overview lists the same products&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;checkoutOverviewPage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;scenario&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;checkoutOverviewPage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;productNames&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toHaveText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scenario&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cartProducts&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;No globals, no shared mutable module state, and every test runs in its own browser context, so &lt;code&gt;fullyParallel: true&lt;/code&gt; is safe. Page objects own locators (role and &lt;code&gt;data-test&lt;/code&gt; attributes, never CSS paths), and assertions are web-first, so there are no hard waits.&lt;/p&gt;

&lt;p&gt;Free-form strings from Gherkin are also narrowed at the boundary. &lt;code&gt;toSauceUser(username)&lt;/code&gt; turns &lt;code&gt;"standard_user"&lt;/code&gt; into a typed union member and throws with the list of known users if a scenario has a typo, instead of failing later on a confusing login error.&lt;/p&gt;

&lt;h2&gt;
  
  
  Login: through the UI only where login is under test
&lt;/h2&gt;

&lt;p&gt;Logging in through the form in every scenario is slow and makes the login page a failure point for tests that have nothing to do with it. SauceDemo keeps its session in a plain &lt;code&gt;session-username&lt;/code&gt; cookie, so outside &lt;code&gt;login.feature&lt;/code&gt; the suite sets the cookie and opens the inventory page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;loginViaSession&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SauceUser&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;context&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addCookies&lt;/span&gt;&lt;span class="p"&gt;([{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;session-username&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sauce&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;baseUrl&lt;/span&gt; &lt;span class="p"&gt;}]);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/inventory.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I validated this against the live site before relying on it, and the &lt;code&gt;Given I am logged in as "..."&lt;/code&gt; step still asserts that the Products page is shown. If the site ever stops honoring the cookie, only this function changes. &lt;code&gt;login.feature&lt;/code&gt; keeps a separate step, &lt;code&gt;Given I am logged in as "standard_user" using the login form&lt;/code&gt;, for the logout scenario, where the real form is part of what is being tested. In a real application the equivalent would be an API login or a stored &lt;code&gt;storageState&lt;/code&gt;. The principle is the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  Asserting business rules, not just screens
&lt;/h2&gt;

&lt;p&gt;"The order total equals the item total plus tax" is a business rule, so the step must check the arithmetic, not only that a total is visible. Money is never compared as floats (&lt;code&gt;0.1 + 0.2 !== 0.3&lt;/code&gt;). Everything goes through integer cents:&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;toCents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;number&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;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sumCents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amounts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[]):&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;amounts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;toCents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nc"&gt;Then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;the order total equals the item total plus tax&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;checkoutOverviewPage&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;itemTotal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;checkoutOverviewPage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;itemTotal&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;checkoutOverviewPage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tax&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;toCents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;checkoutOverviewPage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;total&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="nf"&gt;sumCents&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;itemTotal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tax&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 item total step does the same against the sum of the line prices. These helpers are pure functions, so they have their own unit tests in the plain Playwright &lt;code&gt;unit&lt;/code&gt; project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Known defects: tracked with &lt;a class="mentioned-user" href="https://dev.to/fail"&gt;@fail&lt;/a&gt;, not skipped
&lt;/h2&gt;

&lt;p&gt;SauceDemo's &lt;code&gt;problem_user&lt;/code&gt; is broken on purpose: every product shows the same placeholder image. Instead of skipping a test, I wrote the scenario that asserts the correct behavior and tagged it &lt;code&gt;@fail&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight gherkin"&gt;&lt;code&gt;&lt;span class="nt"&gt;@fail&lt;/span&gt;
&lt;span class="kn"&gt;Scenario&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; problem_user sees a distinct image for each product
  &lt;span class="nf"&gt;Given &lt;/span&gt;I am logged in as &lt;span class="s"&gt;"problem_user"&lt;/span&gt;
  &lt;span class="nf"&gt;Then &lt;/span&gt;every product shows its own image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;playwright-bdd turns &lt;code&gt;@fail&lt;/code&gt; into &lt;code&gt;test.fail()&lt;/code&gt; in the generated spec. Today the scenario is reported as an expected failure. If the defect is fixed, Playwright reports it as "unexpectedly passed", which is the signal to remove the tag. The defect stays visible in every run.&lt;/p&gt;

&lt;p&gt;The honest limitation: &lt;code&gt;@fail&lt;/code&gt; accepts any failure. If the site is down or a selector drifts, this scenario still "passes" as an expected failure. It relies on the other UI tests to prove the site is up. A stricter version would assert the specific failure, but for one tracked defect in a public sandbox I chose the simpler mechanism and documented the trade-off in &lt;code&gt;docs/KNOWN_ISSUES.md&lt;/code&gt;, along with the &lt;code&gt;problem_user&lt;/code&gt; defects I verified by hand but did not automate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keeping the suite honest in CI
&lt;/h2&gt;

&lt;p&gt;A Gherkin suite rots quietly in two ways: a step loses its definition, or someone disables a scenario "for now". The CI pipeline has a dedicated &lt;code&gt;Gherkin&lt;/code&gt; job, which needs no browser and runs in parallel with lint and typecheck:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Fails fast if a Gherkin step has no definition.&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx bddgen&lt;/span&gt;
&lt;span class="c1"&gt;# Lint covers test.skip in TypeScript. This covers the same escape hatch in Gherkin.&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Reject disabled scenarios&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;if grep -rnE '(^|[[:space:]])@(skip|fixme|only)([[:space:]]|$)' features --include='*.feature'; then&lt;/span&gt;
      &lt;span class="s"&gt;echo '::error::A scenario is disabled with @skip, @fixme or @only. Fix it or track it with @fail.'&lt;/span&gt;
      &lt;span class="s"&gt;exit 1&lt;/span&gt;
    &lt;span class="s"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The error message states the policy: fix it, or track it with &lt;code&gt;@fail&lt;/code&gt;. Only after this and the other fast checks pass do the browser tests run, sharded in two, with blob reports merged into a single HTML report.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use Gherkin where someone outside engineering will read it. Keep API, accessibility and unit tests in plain Playwright.&lt;/li&gt;
&lt;li&gt;Run Gherkin on the Playwright runner. You keep fixtures, parallelism, traces, reports and sharding instead of rebuilding them.&lt;/li&gt;
&lt;li&gt;Write declarative steps. Spell out values only when the variation is the business rule, and use Scenario Outlines for that.&lt;/li&gt;
&lt;li&gt;Inject page objects and scenario state as fixtures. No globals, no shared world object.&lt;/li&gt;
&lt;li&gt;Never skip silently: track known defects with &lt;code&gt;@fail&lt;/code&gt;, know its limits, and let CI reject &lt;code&gt;@skip&lt;/code&gt;, &lt;code&gt;@fixme&lt;/code&gt; and &lt;code&gt;@only&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full project, including the API and accessibility suites, is on GitHub: &lt;a href="https://github.com/tayguara/playwright-qa-showcase" rel="noopener noreferrer"&gt;github.com/tayguara/playwright-qa-showcase&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Tayguara Dias Reis is a Lead QA / SDET with 14+ years of experience and ISTQB CTFL certification. The code in this article is from &lt;a href="https://github.com/tayguara/playwright-qa-showcase" rel="noopener noreferrer"&gt;playwright-qa-showcase&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

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