<?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: Christian Sotelo Gutierrez</title>
    <description>The latest articles on DEV Community by Christian Sotelo Gutierrez (@chsotelo).</description>
    <link>https://dev.to/chsotelo</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%2F4272831%2Fa994c7ae-ac5a-4d41-be7d-b01e68a05697.jpg</url>
      <title>DEV Community: Christian Sotelo Gutierrez</title>
      <link>https://dev.to/chsotelo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chsotelo"/>
    <language>en</language>
    <item>
      <title>How I cut a Vitest run from 5 minutes to 19 seconds with a per-file result cache</title>
      <dc:creator>Christian Sotelo Gutierrez</dc:creator>
      <pubDate>Tue, 01 Dec 2026 17:16:37 +0000</pubDate>
      <link>https://dev.to/chsotelo/how-i-cut-a-vitest-run-from-5-minutes-to-19-seconds-with-a-per-file-result-cache-3378</link>
      <guid>https://dev.to/chsotelo/how-i-cut-a-vitest-run-from-5-minutes-to-19-seconds-with-a-per-file-result-cache-3378</guid>
      <description>&lt;p&gt;Our test suite re-ran hundreds of Vitest files on every push, even when a change touched one module. Go has avoided that for years: &lt;code&gt;go test&lt;/code&gt; caches a package's result until its inputs change. I built the same thing for Vitest: &lt;strong&gt;testcache&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;

&lt;p&gt;Each test file gets a key made of its own content and everything it actually loaded during its last passing run: the modules it executed (from V8 coverage), the files and environment variables it read. While none of those change, the stored result is replayed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Staying correct
&lt;/h2&gt;

&lt;p&gt;A cache that returns a stale pass is worse than no cache. testcache:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;never stores a file that spawns a process or opens a network connection;&lt;/li&gt;
&lt;li&gt;drops results whose inputs changed during the run;&lt;/li&gt;
&lt;li&gt;re-runs 2% of hits and quarantines a file whose re-run disagrees;&lt;/li&gt;
&lt;li&gt;offers &lt;code&gt;tc verify&lt;/code&gt; to re-run everything before a merge.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;1,248-file suite: ~5 min cold; after editing a few modules the next full run took 19 s (1,208 files replayed, 40 run).&lt;/li&gt;
&lt;li&gt;CI, a React app with 563 test files on self-hosted GitHub Actions runners: the test steps took 3 min 38 s cold and 1 min 08 s on the next push, which brought in 7 commits; 465 files were replayed and 103 run.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;It's a single Go binary that wraps your existing &lt;code&gt;vitest&lt;/code&gt; command. Install steps, how keys are computed and the known limits are in the repo: &lt;a href="https://github.com/chsotelo/testcache" rel="noopener noreferrer"&gt;https://github.com/chsotelo/testcache&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I first shared it on X, replies welcome there too: &lt;a href="https://x.com/chsotelogutdev/status/2126312904698028536" rel="noopener noreferrer"&gt;https://x.com/chsotelogutdev/status/2126312904698028536&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vitest</category>
      <category>testing</category>
      <category>javascript</category>
      <category>go</category>
    </item>
  </channel>
</rss>
