<?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: Dmytro Shyshko</title>
    <description>The latest articles on DEV Community by Dmytro Shyshko (@dmytroshyshko).</description>
    <link>https://dev.to/dmytroshyshko</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%2F4234884%2Ff5d08df8-3154-42d7-9d41-3cc280c2de8d.jpg</url>
      <title>DEV Community: Dmytro Shyshko</title>
      <link>https://dev.to/dmytroshyshko</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dmytroshyshko"/>
    <language>en</language>
    <item>
      <title>How I reduced Chromatic snapshot usage for 500 generated icons</title>
      <dc:creator>Dmytro Shyshko</dc:creator>
      <pubDate>Wed, 25 Nov 2026 10:16:53 +0000</pubDate>
      <link>https://dev.to/dmytroshyshko/how-i-reduced-chromatic-snapshot-usage-for-500-generated-icons-7po</link>
      <guid>https://dev.to/dmytroshyshko/how-i-reduced-chromatic-snapshot-usage-for-500-generated-icons-7po</guid>
      <description>&lt;p&gt;I've been working on &lt;a href="https://github.com/nudge-icons/nudge-icons" rel="noopener noreferrer"&gt;nudge-icons&lt;/a&gt;, a library of animated icons for React and Vue. It started with 50 icons and now has 500. With filled and half variants that's 546 components.&lt;/p&gt;

&lt;p&gt;I use Storybook and Chromatic to catch visual regressions. Each icon has a story that shows its variants and states at five sizes, and Chromatic takes snapshots of them on every push to &lt;code&gt;main&lt;/code&gt; and on every pull request.&lt;/p&gt;

&lt;p&gt;That was fine with 50 icons. With 500, even a README fix meant 500 new snapshots. On Chromatic's free plan, with 5,000 snapshots a month, that's 10% of the allowance in one push.&lt;/p&gt;

&lt;p&gt;So I started looking at &lt;a href="https://www.chromatic.com/docs/turbosnap/" rel="noopener noreferrer"&gt;TurboSnap&lt;/a&gt;. It only takes new snapshots of the stories a commit can affect and copies the rest from the last accepted build. Copies aren't free, but Chromatic &lt;a href="https://www.chromatic.com/docs/billing/" rel="noopener noreferrer"&gt;bills them&lt;/a&gt; at a fifth of a snapshot.&lt;/p&gt;

&lt;p&gt;Enabling it is one CLI flag, &lt;code&gt;--only-changed&lt;/code&gt;. My setup needed a few more changes, because my icon components are generated and aren't tracked by git.&lt;/p&gt;

&lt;h2&gt;
  
  
  One story file per icon
&lt;/h2&gt;

&lt;p&gt;TurboSnap works per story file. It takes the files changed in a commit, follows the module graph of the Storybook build, and retakes every story file that imports one of them, directly or through other modules.&lt;/p&gt;

&lt;p&gt;All my icon stories used to be in one generated file that imported the whole package. Any change to any icon touched that file, so TurboSnap would have retaken all 500 stories every time.&lt;/p&gt;

&lt;p&gt;Now the story generator writes one file per icon, and each file imports only that icon's components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// apps/storybook/src/generated/icons/bell.stories.tsx&lt;/span&gt;
&lt;span class="c1"&gt;// Generated by apps/storybook/scripts/gen-stories.ts. Do not edit.&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Meta&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;StoryObj&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"@storybook/react-vite"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Bell&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"../../../../../packages/react/src/generated/icons/bell"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;BellFilled&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"../../../../../packages/react/src/generated/icons/bell-filled"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;IconMatrix&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"../../icon-matrix"&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;meta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Icons/Bell"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;component&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;IconMatrix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;toggle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;variants&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;variant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"outline"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Icon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bell&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;variant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"filled"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Icon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;BellFilled&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;satisfies&lt;/span&gt; &lt;span class="nc"&gt;Meta&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nc"&gt;IconMatrix&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;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="n"&gt;meta&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="nc"&gt;Matrix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;StoryObj&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="n"&gt;meta&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="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 stories import each icon's own module, not the package index. The index re-exports every component, so importing it would put all icons back into every story's graph.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with generated components
&lt;/h2&gt;

&lt;p&gt;Each icon starts as two source files: &lt;code&gt;icons/bell.svg&lt;/code&gt; with the drawing and &lt;code&gt;icons/bell.json&lt;/code&gt; with the metadata and motion. A Node script reads them and writes the React and Vue components into &lt;code&gt;packages/*/src/generated/&lt;/code&gt;. The generated files are in &lt;code&gt;.gitignore&lt;/code&gt;, because CI rebuilds them anyway.&lt;/p&gt;

&lt;p&gt;That breaks the way TurboSnap matches changes. Take a change to &lt;code&gt;icons/bell.svg&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The git diff contains &lt;code&gt;icons/bell.svg&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The Storybook module graph contains &lt;code&gt;generated/icons/bell.ts&lt;/code&gt;, but not &lt;code&gt;icons/bell.svg&lt;/code&gt;. The SVG is read by a Node script with &lt;code&gt;readFileSync&lt;/code&gt;; nothing that Vite bundles imports it.&lt;/li&gt;
&lt;li&gt;So the changed file matches no story, and TurboSnap would retake nothing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The bell would look different, but Chromatic would copy the old snapshot and show no diff to review.&lt;/p&gt;

&lt;h2&gt;
  
  
  Importing the original SVG and JSON files
&lt;/h2&gt;

&lt;p&gt;The fix is a few extra lines in each generated story file, importing the icon's own sources for their side effect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Sources, for TurboSnap only.&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s2"&gt;"../../../../../icons/bell.json"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s2"&gt;"../../../../../icons/bell.svg"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s2"&gt;"../../../../../icons/filled/bell.svg"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The story doesn't use them. Vite bundles the JSON and turns each SVG import into an asset URL, and that's enough to put both files in the graph. Now a change to &lt;code&gt;icons/bell.svg&lt;/code&gt; reaches &lt;code&gt;bell.stories.tsx&lt;/code&gt; and nothing else.&lt;/p&gt;

&lt;p&gt;TypeScript also has to accept &lt;code&gt;.svg&lt;/code&gt; imports. In the Storybook package that was one line in &lt;code&gt;tsconfig.json&lt;/code&gt;: &lt;code&gt;"types": ["node", "vite/client"]&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Changes to the generator itself
&lt;/h2&gt;

&lt;p&gt;Some files affect every icon but aren't imported by any story: the generator script and its helpers, which turn SVG into components and motion metadata into CSS. A change there should retake everything.&lt;/p&gt;

&lt;p&gt;TurboSnap has &lt;code&gt;--externals&lt;/code&gt; for this: if a changed file matches one of these patterns, every story is retaken. This is the Chromatic step in my CI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v7&lt;/span&gt;
  &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Chromatic compares against earlier builds by git history.
&lt;/span&gt;    &lt;span class="na"&gt;fetch-depth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="c1"&gt;# ...install...
&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pnpm build:storybook&lt;/span&gt; &lt;span class="c1"&gt;# runs `storybook build --stats-json`
&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="s"&gt;pnpm --filter @nudge-icons/storybook exec chromatic&lt;/span&gt;
    &lt;span class="s"&gt;--storybook-build-dir storybook-static&lt;/span&gt;
    &lt;span class="s"&gt;--only-changed&lt;/span&gt;
    &lt;span class="s"&gt;--storybook-base-dir apps/storybook&lt;/span&gt;
    &lt;span class="s"&gt;--externals 'scripts/build-icons.ts'&lt;/span&gt;
    &lt;span class="s"&gt;--externals 'scripts/lib/**'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The other settings TurboSnap needs here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;storybook build --stats-json&lt;/code&gt; writes &lt;code&gt;preview-stats.json&lt;/code&gt;, the module graph that TurboSnap reads.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--storybook-base-dir&lt;/code&gt; points to the Storybook project inside the monorepo, so the paths in git and in the stats file match.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fetch-depth: 0&lt;/code&gt;, because a shallow clone doesn't have the history Chromatic compares against.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Testing the dependency graph
&lt;/h2&gt;

&lt;p&gt;Chromatic's CLI has a &lt;code&gt;trace&lt;/code&gt; command that shows which stories a changed file would retake, without running a build. Paths are relative to the repository root:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx chromatic trace -b apps/storybook -m compact icons/bell.svg
ℹ Traced 1 changed file to 1 affected story file:
— apps/storybook/src/generated/icons/bell.stories.tsx

$ npx chromatic trace -b apps/storybook -m compact packages/react/src/lib/create-icon.tsx
ℹ Traced 1 changed file to 501 affected story files
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One icon source reaches one story. The shared component factory reaches all 500 icon stories plus the playground story used by the animation tests. If an icon source ever traces to zero stories, the problem from above is back.&lt;/p&gt;

&lt;h2&gt;
  
  
  How many snapshots do I save?
&lt;/h2&gt;

&lt;p&gt;These are three real builds. The billed column is my estimate, with a copy counted as 0.2 of a snapshot:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh83f36chculerpvaiqar.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh83f36chculerpvaiqar.png" alt="Chromatic build 30: 500 tests, 51 changes, and the TurboSnap summary with 51 captured and 449 copied snapshots" width="800" height="155"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Build 30 in Chromatic: the 51 new icon stories were captured, the other 449 copied by TurboSnap.&lt;/em&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Change&lt;/th&gt;
&lt;th&gt;Captured&lt;/th&gt;
&lt;th&gt;Copied&lt;/th&gt;
&lt;th&gt;Billed (approx.)&lt;/th&gt;
&lt;th&gt;Without TurboSnap&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Adding 50 icons&lt;/td&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;td&gt;99&lt;/td&gt;
&lt;td&gt;70&lt;/td&gt;
&lt;td&gt;149&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Redrawing paperclip&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;148&lt;/td&gt;
&lt;td&gt;31&lt;/td&gt;
&lt;td&gt;149&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Adding 51 icons&lt;/td&gt;
&lt;td&gt;51&lt;/td&gt;
&lt;td&gt;449&lt;/td&gt;
&lt;td&gt;141&lt;/td&gt;
&lt;td&gt;500&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The paperclip fix is my favourite example: I changed one icon, and Chromatic took one new snapshot instead of 149.&lt;/p&gt;

&lt;p&gt;A change to shared code still retakes everything, which is what I want: if &lt;code&gt;create-icon.tsx&lt;/code&gt; changes, every icon can look different.&lt;/p&gt;

&lt;p&gt;Copied snapshots are now most of the bill, and their share grows with the library. With 1,000 icons, changing one would still cost around 200 billed snapshots. I'll probably need to revisit this as the library grows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Animation tests
&lt;/h2&gt;

&lt;p&gt;Snapshots don't cover the motion, so I test the animations separately, with Playwright against the built Storybook. The tests hover icons, read the running animations with &lt;code&gt;getAnimations()&lt;/code&gt;, and check that nothing is left attached when they finish. I wrote about that in &lt;a href="https://dev.to/dmytroshyshko/how-i-test-css-animations-with-playwright-and-getanimations-4bnl"&gt;How I test CSS animations with Playwright and getAnimations()&lt;/a&gt;. The live playground story those tests use is excluded from Chromatic with &lt;code&gt;parameters: { chromatic: { disableSnapshot: true } }&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The code is on GitHub: &lt;a href="https://github.com/nudge-icons/nudge-icons/blob/main/apps/storybook/scripts/gen-stories.ts" rel="noopener noreferrer"&gt;the story generator&lt;/a&gt; and &lt;a href="https://github.com/nudge-icons/nudge-icons/blob/main/.github/workflows/ci.yml" rel="noopener noreferrer"&gt;the CI workflow&lt;/a&gt;. The icons are at &lt;a href="https://nudge-icons.github.io/nudge-icons/" rel="noopener noreferrer"&gt;nudge-icons.github.io/nudge-icons&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>storybook</category>
      <category>testing</category>
      <category>chromatic</category>
      <category>react</category>
    </item>
    <item>
      <title>How I test CSS animations with Playwright and getAnimations()</title>
      <dc:creator>Dmytro Shyshko</dc:creator>
      <pubDate>Mon, 09 Nov 2026 10:54:13 +0000</pubDate>
      <link>https://dev.to/dmytroshyshko/how-i-test-css-animations-with-playwright-and-getanimations-4bnl</link>
      <guid>https://dev.to/dmytroshyshko/how-i-test-css-animations-with-playwright-and-getanimations-4bnl</guid>
      <description>&lt;p&gt;I build &lt;a href="https://github.com/nudge-icons/nudge-icons" rel="noopener noreferrer"&gt;nudge-icons&lt;/a&gt;, a set of 500 animated line icons for React and Vue. Every icon has its own small motion: the bell rings, the arrow sinks into the tray, the menu folds into a cross. All of it is plain CSS, with no animation library.&lt;/p&gt;

&lt;p&gt;Testing these animations turned out to be harder than testing the icons themselves. jsdom doesn't run CSS animations, and visual snapshots only capture a single frame. I needed to check whether animations start, how many times they repeat, and whether anything is left on the icon after they finish. So the tests run in a real browser, in real time, and ask the browser what is moving.&lt;/p&gt;

&lt;h2&gt;
  
  
  One playground story, driven by args
&lt;/h2&gt;

&lt;p&gt;Storybook already renders every icon for visual review. For motion I added one more story, &lt;code&gt;Testing/Playground&lt;/code&gt;, that renders a single live icon from args:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;Playground&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;variant&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;active&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PlaygroundProps&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;icon&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;iconByName&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="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nc"&gt;Icon&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;icon&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;variants&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&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;v&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;variant&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;variant&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="nc"&gt;Icon&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="nc"&gt;Icon&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${name} has no ${variant} variant`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Icon&lt;/span&gt;
      &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;testid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"icon"&lt;/span&gt;
      &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="n"&gt;animate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;toAnimate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;icon&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;toggle&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;active&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Playwright opens it with args in the URL, so each test starts from a known state:&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;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`/iframe.html?id=testing-playground--live&amp;amp;args=name:bell;animate:once`&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;Some behaviour only shows when props change on a mounted component, like a menu turning into a cross and back. Reloading the page would remount the icon and skip that change. Instead, the test changes args in place through the Storybook channel, the same way the Controls panel does:&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;evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;updatedArgs&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="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__STORYBOOK_ADDONS_CHANNEL__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"updateStoryArgs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;storyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"testing-playground--live"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;updatedArgs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;active&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The component re-renders like it would in an app. The channel global is internal to Storybook, so this helper is the one place to fix if it ever changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading what moves
&lt;/h2&gt;

&lt;p&gt;The Web Animations API lists the CSS animations and transitions on an element and its children. One helper turns the running ones into something a test can compare:&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="n"&gt;running&lt;/span&gt; &lt;span class="o"&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="nc"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByTestId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"icon"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;svg&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;svg&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAnimations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;subtree&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;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;a&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;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;playState&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"running"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&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="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nc"&gt;CSSTransition&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;"transition"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"animation"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;effect&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"data-part"&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="n"&gt;iterations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;effect&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getComputedTiming&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;iterations&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;CSSTransition&lt;/code&gt; versus &lt;code&gt;CSSAnimation&lt;/code&gt; tells the two mechanisms apart: hover motion uses keyframe animations, the second state uses transitions. Each moving piece of an icon has a &lt;code&gt;data-part&lt;/code&gt; name, so a test can say which part moved. &lt;code&gt;iterations&lt;/code&gt; tells &lt;code&gt;once&lt;/code&gt; (1), a loop (&lt;code&gt;Infinity&lt;/code&gt;) and &lt;code&gt;animate={3}&lt;/code&gt; apart without waiting for them to finish.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"loop repeats without end"&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="nf"&gt;open&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="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"bell"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"loop"&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;moving&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;running&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;moving&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toBeGreaterThan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;moving&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;every&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iterations&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;Infinity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;Hover on a sample of components. The test hovers the icon, waits until something runs, moves the pointer away and waits until nothing runs. When the set had 121 components, it hovered all of them. At 546, that check alone would grow with every release, so it now covers the components of the latest release, which is the batch under review, plus the first component that uses each of the 14 motion presets: about 170 in all. Older icons keep their snapshots in Chromatic and their drawing rules in a separate check that runs on every icon.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;once&lt;/code&gt;, &lt;code&gt;loop&lt;/code&gt;, a number of runs and &lt;code&gt;false&lt;/code&gt;, on a few chosen icons rather than on every component.&lt;/li&gt;
&lt;li&gt;The second state on and off for every component that has one (13 of them).&lt;/li&gt;
&lt;li&gt;The same checks with &lt;code&gt;reducedMotion: "reduce"&lt;/code&gt;, where nothing may move and the second state must switch at once.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most tests poll until animations stop. I still use fixed waits in four places: to check that a loop is still running after 2.5 seconds, and to check that nothing starts within 300 ms when motion is turned off. I tried fake time first, but in my setup it did not advance reverse transitions, which are half of what a second state is. With real time the whole suite takes under a minute.&lt;/p&gt;

&lt;h2&gt;
  
  
  Breaking it on purpose
&lt;/h2&gt;

&lt;p&gt;I wanted to check whether the tests could catch actual regressions, so I deliberately reintroduced two bugs and ran the suite against each broken build.&lt;/p&gt;

&lt;p&gt;First, I removed the &lt;code&gt;prefers-reduced-motion&lt;/code&gt; rule. Three tests failed.&lt;/p&gt;

&lt;p&gt;Second, I brought back a bug I had fixed earlier. The animations used &lt;code&gt;animation-fill-mode: both&lt;/code&gt;, and the icons looked slightly blurred in Chrome after they finished moving. The suite passed.&lt;/p&gt;

&lt;p&gt;It passed because every motion in the set ends exactly where it started. With &lt;code&gt;fill: both&lt;/code&gt;, the finished animation keeps holding its last frame, but the last frame equals the resting drawing, so every computed style the tests compared was identical.&lt;/p&gt;

&lt;p&gt;I had measured the blur on screenshots, as the share of half-grey pixels along the stroke edges:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;State of the icon&lt;/th&gt;
&lt;th&gt;Half-grey edge pixels&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Static&lt;/td&gt;
&lt;td&gt;0.090&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Transform animation running&lt;/td&gt;
&lt;td&gt;0.145–0.158&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Animation finished, &lt;code&gt;fill: both&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;0.116&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Animation finished, &lt;code&gt;fill: backwards&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;0.090&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In my Chrome screenshots, SVG strokes stayed slightly blurred while a finished transform animation remained attached. With &lt;code&gt;fill: backwards&lt;/code&gt;, the animation is released when it ends and the edges go back to the static value.&lt;/p&gt;

&lt;p&gt;So the tests needed to check for an animation that is still attached, not for a style value. That is one more helper and one more assertion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;attached&lt;/span&gt; &lt;span class="o"&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="nc"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByTestId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"icon"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;svg&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;svg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAnimations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;subtree&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;settled&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="c1"&gt;// No animation left holding its last frame, so the lines are drawn crisp again.&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="nf"&gt;attached&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;toBe&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;p&gt;&lt;code&gt;getAnimations()&lt;/code&gt; also returns finished animations that keep their effect through the fill mode, which is why this check sees what the style comparison missed. It does not prove that rendering is sharp in every case; it checks the cause of this particular regression.&lt;/p&gt;

&lt;p&gt;The new assertion failed with &lt;code&gt;fill: both&lt;/code&gt; and passed after restoring &lt;code&gt;fill: backwards&lt;/code&gt;. The original tests had missed the regression.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chromatic and Playwright
&lt;/h2&gt;

&lt;p&gt;Every icon also has a story with all its variants and states at five sizes, standing still. Chromatic snapshots those on every pull request and catches a moved point or a changed stroke.&lt;/p&gt;

&lt;p&gt;With hundreds of icons, snapshotting everything on every push stopped making sense, so Chromatic runs with TurboSnap: it uses the Storybook build's dependency graph to capture only the stories whose files changed and copies the rest from the baseline. That needed one change. The icon components are generated from SVG and JSON sources and the generated files are not in git, so a git diff never touches them and TurboSnap cannot connect a changed source to its story. Each icon now has its own story file, and that file imports its own sources directly, which puts them in the graph. When a batch of 51 new icons landed, Chromatic captured 51 snapshots and copied 449. The playground story is excluded from snapshots (&lt;code&gt;parameters: { chromatic: { disableSnapshot: true } }&lt;/code&gt;), because a frame of live motion is not a stable baseline. Motion is checked by Playwright against the built Storybook, in CI, in Chromium.&lt;/p&gt;

&lt;p&gt;The code is on GitHub: &lt;a href="https://github.com/nudge-icons/nudge-icons/blob/main/apps/storybook/src/playground.stories.tsx" rel="noopener noreferrer"&gt;the playground story&lt;/a&gt;, &lt;a href="https://github.com/nudge-icons/nudge-icons/blob/main/apps/storybook/e2e/playground.ts" rel="noopener noreferrer"&gt;the helpers&lt;/a&gt; and &lt;a href="https://github.com/nudge-icons/nudge-icons/blob/main/apps/storybook/e2e/motion.spec.ts" rel="noopener noreferrer"&gt;the tests&lt;/a&gt;. The icons are at &lt;a href="https://nudge-icons.github.io/nudge-icons/" rel="noopener noreferrer"&gt;nudge-icons.github.io/nudge-icons&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>css</category>
      <category>playwright</category>
      <category>storybook</category>
    </item>
  </channel>
</rss>
