<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Jest Blog</title>
        <link>https://jestjs.io/blog</link>
        <description>Jest Blog</description>
        <lastBuildDate>Wed, 04 Jun 2025 00:00:00 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <item>
            <title><![CDATA[Jest 30: Faster, Leaner, Better]]></title>
            <link>https://jestjs.io/blog/2025/06/04/jest-30</link>
            <guid>https://jestjs.io/blog/2025/06/04/jest-30</guid>
            <pubDate>Wed, 04 Jun 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[Today we are happy to announce the release of Jest 30. This release features a substantial number of changes, fixes, and improvements. While it is one of the largest major releases of Jest ever, we admit that three years for a major release is too long. In the future, we are aiming to make more frequent major releases to keep Jest great for the next decade.]]></description>
            <content:encoded><![CDATA[<p>Today we are happy to announce the release of Jest 30. This release features a substantial number of changes, fixes, and improvements. While it is one of the largest major releases of Jest ever, we admit that three years for a major release is too long. In the future, we are aiming to make more frequent major releases to keep Jest great for the next decade.</p>
<p>If you want to skip all the news and just get going, run <code>npm install jest@^30.0.0</code> and follow the migration guide: <a href="https://jestjs.io/docs/upgrading-to-jest30" target="_blank" rel="noopener noreferrer" class="">Upgrading from Jest 29 to 30</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="whats-new">What’s New?<a href="https://jestjs.io/blog/2025/06/04/jest-30#whats-new" class="hash-link" aria-label="Direct link to What’s New?" title="Direct link to What’s New?" translate="no">​</a></h2>
<p>Jest 30 is noticeably faster, uses less memory, and comes with tons of new features. First, let’s take a look at the breaking changes:</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="breaking-changes">Breaking Changes<a href="https://jestjs.io/blog/2025/06/04/jest-30#breaking-changes" class="hash-link" aria-label="Direct link to Breaking Changes" title="Direct link to Breaking Changes" translate="no">​</a></h2>
<ul>
<li class="">Jest 30 drops support for Node 14, 16, 19, and 21.</li>
<li class=""><code>jest-environment-jsdom</code> was upgraded from jsdom 21 to 26.</li>
<li class="">The minimum compatible TypeScript version is now 5.4.</li>
<li class="">Various <code>expect</code> aliases were removed. <a href="https://github.com/jest-community/eslint-plugin-jest/blob/HEAD/docs/rules/no-alias-methods.md" target="_blank" rel="noopener noreferrer" class=""><code>eslint-plugin-jest</code> has an autofixer</a> which you can run to automatically upgrade your codebase.</li>
<li class="">Non-enumerable object properties are now excluded from object matchers such as <code>toEqual</code> by default.</li>
<li class="">Jest now supports <code>.mts</code> and <code>.cts</code> files by default.</li>
<li class=""><code>--testPathPattern</code> was renamed to <code>--testPathPatterns</code>.</li>
<li class="">Jest now properly handles promises that are first rejected and then later caught to avoid false positive test failures.</li>
<li class="">We made various improvements to Jest’s printing of snapshots which might require you to update snapshots. Google deprecated <code>goo.gl</code> links which we were using in snapshots. We don’t like it either, but you’ll have to update all your snapshots.</li>
<li class="">Jest itself is now bundled into a single file per package. This improves performance, but might break if you built tools that reach into Jest's internals.</li>
</ul>
<p>These are just some of the highlights. The full list of breaking changes can be found in the <a href="https://github.com/jestjs/jest/blame/main/CHANGELOG.md" target="_blank" rel="noopener noreferrer" class="">CHANGELOG</a> and the <a href="https://jestjs.io/docs/upgrading-to-jest30" target="_blank" rel="noopener noreferrer" class="">Jest 30 migration guide</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="performance--memory-improvements">Performance &amp; Memory Improvements<a href="https://jestjs.io/blog/2025/06/04/jest-30#performance--memory-improvements" class="hash-link" aria-label="Direct link to Performance &amp; Memory Improvements" title="Direct link to Performance &amp; Memory Improvements" translate="no">​</a></h2>
<p>Jest 30 delivers real-world performance gains thanks to many optimizations, especially related to module resolution, memory usage, and test isolation. By relying on the new <a href="https://github.com/unrs/unrs-resolver" target="_blank" rel="noopener noreferrer" class="">unrs-resolver</a>, module resolution in Jest became more feature-rich, standards-compliant, and faster. Thanks to <a href="https://github.com/JounQin" target="_blank" rel="noopener noreferrer" class="">@JounQin</a> for the migration. Depending on your project, you may see significantly faster test runs and reduced memory consumption. For example, one large TypeScript app with a client and server observed 37% faster test runs and 77% lower memory usage in one part of their codebase:</p>
<table><thead><tr><th></th><th>Jest 29</th><th>Jest 30</th></tr></thead><tbody><tr><td><strong>Server tests</strong></td><td>~1350s / 7.8 GB max</td><td><strong>~850s / 1.8 GB max</strong></td></tr><tr><td><strong>Client tests</strong></td><td>~49s / 1.0 GB max</td><td><strong>~44s / 0.8 GB max</strong></td></tr></tbody></table>
<p>Jest is fast, but due to Jest's test isolation, slow user code often exacerbates performance issues and leads to slow test runs. When tests leave behind open handles like unclosed timers or connections to other services, it can cause Jest to hang or slow down. Jest 30 has gotten better at detecting and reporting these issues, which helps you identify and fix slow or problematic tests more easily. For example, tests at <a href="https://happo.io/" target="_blank" rel="noopener noreferrer" class="">Happo</a> were sped up by 50% from 14 minutes down to 9 minutes by cleaning up open handles and upgrading to Jest 30.</p>
<p>If you are using files that consolidate the exports of multiple modules into a single file (i.e. "barrel files"), we recommend using tools such as <a href="https://github.com/gtsop/babel-jest-boost" target="_blank" rel="noopener noreferrer" class=""><code>babel-jest-boost</code></a>, <a href="https://github.com/FogelAI/babel-plugin-transform-barrels" target="_blank" rel="noopener noreferrer" class=""><code>babel-plugin-transform-barrels</code></a> or <a href="https://github.com/Nergie/no-barrel-file" target="_blank" rel="noopener noreferrer" class=""><code>no-barrel-file</code></a> to avoid loading large swaths of application code for each test file. This can lead to performance improvements of up to 100x.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="globals-cleanup-between-test-files">Globals cleanup between test files<a href="https://jestjs.io/blog/2025/06/04/jest-30#globals-cleanup-between-test-files" class="hash-link" aria-label="Direct link to Globals cleanup between test files" title="Direct link to Globals cleanup between test files" translate="no">​</a></h3>
<p>Jest achieves test isolation between files by running each test in a separate <a href="https://nodejs.org/api/vm.html#vm-executing-javascript" target="_blank" rel="noopener noreferrer" class="">VM context</a>, giving each file a fresh global environment. However, if your code does not clean up globals after each test file, it can lead to memory leaks across Jest and slow down your test runs. Jest 30 introduces a new feature that notifies you about globals that are not correctly cleaned up after a test run.</p>
<p>In the future, Jest will automatically clean up globals after each test run. If you don't get any warnings about uncleaned globals with Jest 30, you can already set the globals cleanup mode to "on" now to enable this feature fully, and benefit from major memory savings and performance improvements:</p>
<div class="language-javascript codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-javascript codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token keyword module" style="color:#297a29">export</span><span class="token plain"> </span><span class="token keyword module" style="color:#297a29">default</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token literal-property property" style="color:#82772c">testEnvironmentOptions</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token literal-property property" style="color:#82772c">globalsCleanup</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token string" style="color:#c21325">'on'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p>The default in Jest is <code>globalsCleanup: 'soft'</code>. To disable this feature you can set it to <code>off</code>. If you need to protect specific global objects from being cleaned up -- for example, shared utilities or caches -- you can mark them as protected using <code>jest-util</code>:</p>
<div class="language-ts codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-ts codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token keyword" style="color:#297a29">import</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain">protectProperties</span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#297a29">from</span><span class="token plain"> </span><span class="token string" style="color:#c21325">'jest-util'</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#6b2e85">protectProperties</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">globalThis</span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#c21325">'my-property'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p>Thanks to <a href="https://github.com/eyalroth" target="_blank" rel="noopener noreferrer" class="">@eyalroth</a> for implementing this feature!</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="new-features">New Features<a href="https://jestjs.io/blog/2025/06/04/jest-30#new-features" class="hash-link" aria-label="Direct link to New Features" title="Direct link to New Features" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="improved-ecmascript-module--typescript-support">Improved ECMAScript Module &amp; TypeScript Support<a href="https://jestjs.io/blog/2025/06/04/jest-30#improved-ecmascript-module--typescript-support" class="hash-link" aria-label="Direct link to Improved ECMAScript Module &amp; TypeScript Support" title="Direct link to Improved ECMAScript Module &amp; TypeScript Support" translate="no">​</a></h3>
<p>Support for <code>import.meta.*</code> and <code>file://</code> was added <a href="https://jestjs.io/docs/ecmascript-modules" target="_blank" rel="noopener noreferrer" class="">when using native ESM with Jest</a>. In addition, you can now write your Jest config files in TypeScript, and <code>.mts</code> and <code>.cts</code> files are natively supported without requiring extra configuration. If you are using Node’s native TypeScript type stripping feature, we no longer load the TypeScript transformer to strip types, leading to faster test runs.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="spies-and-the-using-keyword">Spies and the <code>using</code> keyword<a href="https://jestjs.io/blog/2025/06/04/jest-30#spies-and-the-using-keyword" class="hash-link" aria-label="Direct link to spies-and-the-using-keyword" title="Direct link to spies-and-the-using-keyword" translate="no">​</a></h3>
<p>You can now use <a href="https://v8.dev/features/explicit-resource-management" target="_blank" rel="noopener noreferrer" class="">JavaScript’s new explicit resource management syntax (<code>using</code>)</a> with Jest spies. If your environment supports it, writing <code>using jest.spyOn(obj, 'method')</code> will automatically restore the spy when the block ends, so you don’t have to manually clean up.</p>
<div class="language-typescript codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-typescript codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#6b2e85">test</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'logs a warning'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token operator" style="color:#888">=&gt;</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  using spy </span><span class="token operator" style="color:#888">=</span><span class="token plain"> jest</span><span class="token punctuation" style="color:#393A34">.</span><span class="token function" style="color:#6b2e85">spyOn</span><span class="token punctuation" style="color:#393A34">(</span><span class="token builtin">console</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#c21325">'warn'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token function" style="color:#6b2e85">doSomeThingWarnWorthy</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token function" style="color:#6b2e85">expect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">spy</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">.</span><span class="token function" style="color:#6b2e85">toHaveBeenCalled</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p><a class="" href="https://jestjs.io/docs/jest-object#spied-methods-and-the-using-keyword">Documentation</a></p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="expectarrayof"><code>expect.arrayOf</code><a href="https://jestjs.io/blog/2025/06/04/jest-30#expectarrayof" class="hash-link" aria-label="Direct link to expectarrayof" title="Direct link to expectarrayof" translate="no">​</a></h3>
<p>Jest 30 introduces a new <a href="https://jestjs.io/docs/expect#asymmetric-matchers" target="_blank" rel="noopener noreferrer" class="">asymmetric matcher</a>, <code>expect.arrayOf</code>, which lets you validate every element of an array against a condition or type. For instance, you can expect an array of numbers ensuring all items are numbers:</p>
<div class="language-javascript codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-javascript codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#6b2e85">expect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">someArray</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">toEqual</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">expect</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">arrayOf</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">expect</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">any</span><span class="token punctuation" style="color:#393A34">(</span><span class="token known-class-name class-name">Number</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p><a class="" href="https://jestjs.io/docs/expect#expectarrayofvalue">Documentation</a></p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="new-testeach-placeholder-">New <code>test.each</code> placeholder: <code>%$</code><a href="https://jestjs.io/blog/2025/06/04/jest-30#new-testeach-placeholder-" class="hash-link" aria-label="Direct link to new-testeach-placeholder-" title="Direct link to new-testeach-placeholder-" translate="no">​</a></h3>
<p>If you use data-driven tests with <code>test.each</code>, you can now include a special placeholder <code>%$</code> in your test titles to inject the <strong>number of the test case</strong>. For example:</p>
<div class="language-javascript codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-javascript codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token plain">test</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">each</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">cases</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'Case %$ works as expected'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#888">=&gt;</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p>will replace <code>%$</code> with the test’s sequence number.</p>
<p><a class="" href="https://jestjs.io/docs/api#testeachtablename-fn-timeout">Documentation</a></p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="jestadvancetimerstonextframe"><code>jest.advanceTimersToNextFrame()</code><a href="https://jestjs.io/blog/2025/06/04/jest-30#jestadvancetimerstonextframe" class="hash-link" aria-label="Direct link to jestadvancetimerstonextframe" title="Direct link to jestadvancetimerstonextframe" translate="no">​</a></h3>
<p><a href="https://github.com/sinonjs/fake-timers" target="_blank" rel="noopener noreferrer" class=""><code>@sinonjs/fake-timers</code></a> was upgraded to v13, adding <code>jest.advanceTimersToNextFrame()</code>. This new function allows you to advance all pending <code>requestAnimationFrame</code> callbacks to the next frame boundary, making it easier to test animations or code that relies on <code>requestAnimationFrame</code> without having to guess millisecond durations.</p>
<p><a class="" href="https://jestjs.io/docs/jest-object#jestadvancetimerstonextframe">Documentation</a></p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="configurable-test-retries">Configurable test retries<a href="https://jestjs.io/blog/2025/06/04/jest-30#configurable-test-retries" class="hash-link" aria-label="Direct link to Configurable test retries" title="Direct link to Configurable test retries" translate="no">​</a></h3>
<p>Jest 30 enhances <code>jest.retryTimes()</code> with new options that give you control over how retries are handled. You can specify a delay or immediately retry a failed test instead of waiting until the entire test suite finishes:</p>
<div class="language-js codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-js codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token comment" style="color:#999988;font-style:italic">// Retry failed tests up to 3 times, waiting 1 second between attempts:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">jest</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">retryTimes</span><span class="token punctuation" style="color:#393A34">(</span><span class="token number" style="color:#1373c2">3</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token literal-property property" style="color:#82772c">waitBeforeRetry</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token number" style="color:#1373c2">1000</span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic">// Immediately retry without waiting for other tests to finish:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">jest</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">retryTimes</span><span class="token punctuation" style="color:#393A34">(</span><span class="token number" style="color:#1373c2">3</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token literal-property property" style="color:#82772c">retryImmediately</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p><a class="" href="https://jestjs.io/docs/jest-object#jestretrytimesnumretries-options">Documentation</a></p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="jestunstable_unmockmodule"><code>jest.unstable_unmockModule()</code><a href="https://jestjs.io/blog/2025/06/04/jest-30#jestunstable_unmockmodule" class="hash-link" aria-label="Direct link to jestunstable_unmockmodule" title="Direct link to jestunstable_unmockmodule" translate="no">​</a></h3>
<p>Jest 30 adds new experimental <code>jest.unstable_unmockModule()</code> API for finer control when unmocking modules (especially when using native ESM).</p>
<p><a class="" href="https://jestjs.io/docs/ecmascript-modules#module-unmocking-in-esm">Documentation</a></p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="jestongeneratemockcallback"><code>jest.onGenerateMock(callback)</code><a href="https://jestjs.io/blog/2025/06/04/jest-30#jestongeneratemockcallback" class="hash-link" aria-label="Direct link to jestongeneratemockcallback" title="Direct link to jestongeneratemockcallback" translate="no">​</a></h3>
<p>A new <code>onGenerateMock</code> method was added. It registers a callback function that is invoked whenever Jest generates a mock for a module. This callback allows you to modify a mock before it is returned to your test environment:</p>
<div class="language-javascript codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-javascript codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token plain">jest</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">onGenerateMock</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">(</span><span class="token parameter">modulePath</span><span class="token parameter punctuation" style="color:#393A34">,</span><span class="token parameter"> moduleMock</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#888">=&gt;</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword control-flow" style="color:#297a29">if</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">modulePath</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">includes</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'Database'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    moduleMock</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">connect</span><span class="token plain"> </span><span class="token operator" style="color:#888">=</span><span class="token plain"> jest</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">fn</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">mockImplementation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#888">=&gt;</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token console class-name">console</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">log</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'Connected to mock DB'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword control-flow" style="color:#297a29">return</span><span class="token plain"> moduleMock</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p><a class="" href="https://jestjs.io/docs/jest-object#jestongeneratemockcb">Documentation</a></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="other-improvements">Other Improvements<a href="https://jestjs.io/blog/2025/06/04/jest-30#other-improvements" class="hash-link" aria-label="Direct link to Other Improvements" title="Direct link to Other Improvements" translate="no">​</a></h2>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="custom-object-serialization">Custom object serialization<a href="https://jestjs.io/blog/2025/06/04/jest-30#custom-object-serialization" class="hash-link" aria-label="Direct link to Custom object serialization" title="Direct link to Custom object serialization" translate="no">​</a></h3>
<p>Jest’s matcher utilities now support defining a static <code>SERIALIZABLE_PROPERTIES</code> on custom objects. This allows you to control which properties of a custom object are included in snapshots and error messages, making the output more focused and relevant.</p>
<p><a href="https://jestjs.io/docs/next/expect#serializable_properties" target="_blank" rel="noopener noreferrer" class="">Documentation</a></p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="asynchronous-setup-support">Asynchronous setup support<a href="https://jestjs.io/blog/2025/06/04/jest-30#asynchronous-setup-support" class="hash-link" aria-label="Direct link to Asynchronous setup support" title="Direct link to Asynchronous setup support" translate="no">​</a></h3>
<p>Test files listed in <code>setupFilesAfterEnv</code> can now export an async function or use top-level <code>await</code> similar to <code>setupFiles</code>.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="and-so-much-more">And so much more…<a href="https://jestjs.io/blog/2025/06/04/jest-30#and-so-much-more" class="hash-link" aria-label="Direct link to And so much more…" title="Direct link to And so much more…" translate="no">​</a></h3>
<p>Check out the full <a href="https://github.com/jestjs/jest/blame/main/CHANGELOG.md" target="_blank" rel="noopener noreferrer" class="">CHANGELOG</a> for all changes, improvements and new features.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="known-issues">Known Issues<a href="https://jestjs.io/blog/2025/06/04/jest-30#known-issues" class="hash-link" aria-label="Direct link to Known Issues" title="Direct link to Known Issues" translate="no">​</a></h3>
<p><a href="https://github.com/jsdom/jsdom/issues/3492" target="_blank" rel="noopener noreferrer" class="">jsdom has made changes to become more spec compliant</a>. This might break some use cases, most notably mocking <code>window.location</code> in tests. Jest now ships with <code>@jest/environment-jsdom-abstract</code> to make it easier for you to compose your own custom test environment based on jsdom. If you are just looking to patch <code>jsdom</code>, you can apply <a href="https://gist.github.com/cpojer/e66f9a082021a82230f2595a6027f161" target="_blank" rel="noopener noreferrer" class="">this <code>jsdom</code> patch to your project</a>. In the future, we may look into providing an alternative to <code>jsdom</code> that is better suited for testing.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="whats-next">What's Next<a href="https://jestjs.io/blog/2025/06/04/jest-30#whats-next" class="hash-link" aria-label="Direct link to What's Next" title="Direct link to What's Next" translate="no">​</a></h2>
<p>Jest has been the most popular JavaScript testing framework for a decade. It is used by millions of developers, supporting a wide range of projects from small libraries to the largest codebases in the world. Jest has constantly been improved over time, and as with all long-lasting software projects used in the real world, we accumulated technical debt. We support some features that only few people or companies use, and we have kept breaking changes to a minimum to avoid disrupting users. Some features should be made possible by Jest, but not as part of the core framework. Other features promote testing the wrong things, and should maybe not be part of Jest at all. In terms of Jest's team, a few of us moved on over time which led to slower progress and fewer releases. Here is how we are going to address these issues going forward:</p>
<ul>
<li class=""><strong>Performance / Technical Debt:</strong> Slim Jest down into a leaner, more performant core. Remove features that are not used by the majority of users, and focus on what makes Jest great.</li>
<li class=""><strong>Consistent Release Cycles:</strong> We will aim to be more consistent with our release cycles and deprecation policies.</li>
<li class=""><strong>Be Open:</strong> Build everything in the open, and be transparent about our plans. Provide more opportunities to get involved and increase the number of contributors.</li>
<li class=""><strong>Be Bold:</strong> As the Jest team, we should be more bold. There are a bunch of things that holds Jest back from what it could be. It's time to make moves.</li>
</ul>
<p>The great news is that Jest has always been well set up to deliver on these principles, ever since we built the framework as a modular system with clear separation of concerns. Now it's time to execute. <em>More on all that soon!</em></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="thanks">Thanks<a href="https://jestjs.io/blog/2025/06/04/jest-30#thanks" class="hash-link" aria-label="Direct link to Thanks" title="Direct link to Thanks" translate="no">​</a></h2>
<p>This release wouldn’t have been possible without the hard work of our community. Thank you.</p>
<p><a href="https://github.com/SimenB" target="_blank" rel="noopener noreferrer" class="">@SimenB</a>, <a href="https://github.com/mrazauskas" target="_blank" rel="noopener noreferrer" class="">@mrazauskas</a>, <a href="https://github.com/Connormiha" target="_blank" rel="noopener noreferrer" class="">@Connormiha</a>, <a href="https://github.com/liuxingbaoyu" target="_blank" rel="noopener noreferrer" class="">@liuxingbaoyu</a>, <a href="https://github.com/k-rajat19" target="_blank" rel="noopener noreferrer" class="">@k-rajat19</a>, <a href="https://github.com/G-Rath" target="_blank" rel="noopener noreferrer" class="">@G-Rath</a>, <a href="https://github.com/charpeni" target="_blank" rel="noopener noreferrer" class="">@charpeni</a>, <a href="https://github.com/dubzzz" target="_blank" rel="noopener noreferrer" class="">@dubzzz</a>, <a href="https://github.com/stekycz" target="_blank" rel="noopener noreferrer" class="">@stekycz</a>, <a href="https://github.com/yinm" target="_blank" rel="noopener noreferrer" class="">@yinm</a>, <a href="https://github.com/lencioni" target="_blank" rel="noopener noreferrer" class="">@lencioni</a>, <a href="https://github.com/phawxby" target="_blank" rel="noopener noreferrer" class="">@phawxby</a>, <a href="https://github.com/lukeapage" target="_blank" rel="noopener noreferrer" class="">@lukeapage</a>, <a href="https://github.com/robhogan" target="_blank" rel="noopener noreferrer" class="">@robhogan</a>, <a href="https://github.com/fisker" target="_blank" rel="noopener noreferrer" class="">@fisker</a>, <a href="https://github.com/k-rajat19" target="_blank" rel="noopener noreferrer" class="">@k-rajat19</a>, <a href="https://github.com/connectdotz" target="_blank" rel="noopener noreferrer" class="">@connectdotz</a>, <a href="https://github.com/alesmenzel" target="_blank" rel="noopener noreferrer" class="">@alesmenzel</a>, <a href="https://github.com/rickhanlonii" target="_blank" rel="noopener noreferrer" class="">@rickhanlonii</a>, <a href="https://github.com/mbelsky" target="_blank" rel="noopener noreferrer" class="">@mbelsky</a>, <a href="https://github.com/brunocabral88" target="_blank" rel="noopener noreferrer" class="">@brunocabral88</a>, <a href="https://github.com/brandon-leapyear" target="_blank" rel="noopener noreferrer" class="">@brandon-leapyear</a>, <a href="https://github.com/nicolo-ribaudo" target="_blank" rel="noopener noreferrer" class="">@nicolo-ribaudo</a>, <a href="https://github.com/dj-stormtrooper" target="_blank" rel="noopener noreferrer" class="">@dj-stormtrooper</a>, <a href="https://github.com/eryue0220" target="_blank" rel="noopener noreferrer" class="">@eryue0220</a></p>
<p>A special thanks to everyone who made their first contribution to Jest in this release. Thank you for making Jest better for everyone!</p>
<p><a href="https://github.com/eyalroth" target="_blank" rel="noopener noreferrer" class="">@eyalroth</a>, <a href="https://github.com/KhaledElmorsy" target="_blank" rel="noopener noreferrer" class="">@KhaledElmorsy</a>, <a href="https://github.com/mohammednumaan" target="_blank" rel="noopener noreferrer" class="">@mohammednumaan</a>, <a href="https://github.com/bensternthal" target="_blank" rel="noopener noreferrer" class="">@bensternthal</a>, <a href="https://github.com/BondarenkoAlex" target="_blank" rel="noopener noreferrer" class="">@BondarenkoAlex</a>, <a href="https://github.com/phryneas" target="_blank" rel="noopener noreferrer" class="">@phryneas</a>, <a href="https://github.com/jayvdb" target="_blank" rel="noopener noreferrer" class="">@jayvdb</a>, <a href="https://github.com/brandonchinn178" target="_blank" rel="noopener noreferrer" class="">@brandonchinn178</a>, <a href="https://github.com/latin-1" target="_blank" rel="noopener noreferrer" class="">@latin-1</a>, <a href="https://github.com/rmartine-ias" target="_blank" rel="noopener noreferrer" class="">@rmartine-ias</a>, <a href="https://github.com/fa93hws" target="_blank" rel="noopener noreferrer" class="">@fa93hws</a>, <a href="https://github.com/Dunqing" target="_blank" rel="noopener noreferrer" class="">@Dunqing</a>, <a href="https://github.com/gustav0d" target="_blank" rel="noopener noreferrer" class="">@gustav0d</a>, <a href="https://github.com/noritaka1166" target="_blank" rel="noopener noreferrer" class="">@noritaka1166</a>, <a href="https://github.com/andreibereczki" target="_blank" rel="noopener noreferrer" class="">@andreibereczki</a>, <a href="https://github.com/Dreamsorcerer" target="_blank" rel="noopener noreferrer" class="">@Dreamsorcerer</a>, <a href="https://github.com/satanTime" target="_blank" rel="noopener noreferrer" class="">@satanTime</a>, <a href="https://github.com/icholy" target="_blank" rel="noopener noreferrer" class="">@icholy</a>, <a href="https://github.com/ecraig12345" target="_blank" rel="noopener noreferrer" class="">@ecraig12345</a>, <a href="https://github.com/cgm-16" target="_blank" rel="noopener noreferrer" class="">@cgm-16</a>, <a href="https://github.com/sebastiancarlos" target="_blank" rel="noopener noreferrer" class="">@sebastiancarlos</a>, <a href="https://github.com/dancer1325" target="_blank" rel="noopener noreferrer" class="">@dancer1325</a>, <a href="https://github.com/loganrosen" target="_blank" rel="noopener noreferrer" class="">@loganrosen</a>, <a href="https://github.com/zakingslayerv22" target="_blank" rel="noopener noreferrer" class="">@zakingslayerv22</a>, <a href="https://github.com/dev-intj" target="_blank" rel="noopener noreferrer" class="">@dev-intj</a>, <a href="https://github.com/tez3998" target="_blank" rel="noopener noreferrer" class="">@tez3998</a>, <a href="https://github.com/anbnyc" target="_blank" rel="noopener noreferrer" class="">@anbnyc</a>, <a href="https://github.com/pengqiseven" target="_blank" rel="noopener noreferrer" class="">@pengqiseven</a>, <a href="https://github.com/thypon" target="_blank" rel="noopener noreferrer" class="">@thypon</a>, <a href="https://github.com/co63oc" target="_blank" rel="noopener noreferrer" class="">@co63oc</a>, <a href="https://github.com/danielrentz" target="_blank" rel="noopener noreferrer" class="">@danielrentz</a>, <a href="https://github.com/jonasongg" target="_blank" rel="noopener noreferrer" class="">@jonasongg</a>, <a href="https://github.com/andrew-the-drawer" target="_blank" rel="noopener noreferrer" class="">@andrew-the-drawer</a>, <a href="https://github.com/phryneas" target="_blank" rel="noopener noreferrer" class="">@phryneas</a>, <a href="https://github.com/hyperupcall" target="_blank" rel="noopener noreferrer" class="">@hyperupcall</a>, <a href="https://github.com/tonyd33" target="_blank" rel="noopener noreferrer" class="">@tonyd33</a>, <a href="https://github.com/madcapnmckay" target="_blank" rel="noopener noreferrer" class="">@madcapnmckay</a>, <a href="https://github.com/dongwa" target="_blank" rel="noopener noreferrer" class="">@dongwa</a>, <a href="https://github.com/gagan-bhullar-tech" target="_blank" rel="noopener noreferrer" class="">@gagan-bhullar-tech</a>, <a href="https://github.com/ikonst" target="_blank" rel="noopener noreferrer" class="">@ikonst</a>, <a href="https://github.com/ZuBB" target="_blank" rel="noopener noreferrer" class="">@ZuBB</a>, <a href="https://github.com/jzaefferer" target="_blank" rel="noopener noreferrer" class="">@jzaefferer</a>, <a href="https://github.com/brandonnorsworthy" target="_blank" rel="noopener noreferrer" class="">@brandonnorsworthy</a>, <a href="https://github.com/henny1105" target="_blank" rel="noopener noreferrer" class="">@henny1105</a>, <a href="https://github.com/DmitryMakhnev" target="_blank" rel="noopener noreferrer" class="">@DmitryMakhnev</a>, <a href="https://github.com/askoufis" target="_blank" rel="noopener noreferrer" class="">@askoufis</a>, <a href="https://github.com/RahulARanger" target="_blank" rel="noopener noreferrer" class="">@RahulARanger</a>, <a href="https://github.com/Jon-Biz" target="_blank" rel="noopener noreferrer" class="">@Jon-Biz</a>, <a href="https://github.com/fynsta" target="_blank" rel="noopener noreferrer" class="">@fynsta</a>, <a href="https://github.com/KonnorRogers" target="_blank" rel="noopener noreferrer" class="">@KonnorRogers</a>, <a href="https://github.com/BondarenkoAlex" target="_blank" rel="noopener noreferrer" class="">@BondarenkoAlex</a>, <a href="https://github.com/mouadhbb" target="_blank" rel="noopener noreferrer" class="">@mouadhbb</a>, <a href="https://github.com/kemuridama" target="_blank" rel="noopener noreferrer" class="">@kemuridama</a>, <a href="https://github.com/Avi-E-Koenig" target="_blank" rel="noopener noreferrer" class="">@Avi-E-Koenig</a>, <a href="https://github.com/davidroeca" target="_blank" rel="noopener noreferrer" class="">@davidroeca</a>, <a href="https://github.com/akwodkiewicz" target="_blank" rel="noopener noreferrer" class="">@akwodkiewicz</a>, <a href="https://github.com/mukul-turing" target="_blank" rel="noopener noreferrer" class="">@mukul-turing</a>, <a href="https://github.com/dnicolson" target="_blank" rel="noopener noreferrer" class="">@dnicolson</a>, <a href="https://github.com/colinacassidy" target="_blank" rel="noopener noreferrer" class="">@colinacassidy</a>, <a href="https://github.com/ofekm97" target="_blank" rel="noopener noreferrer" class="">@ofekm97</a>, <a href="https://github.com/haze" target="_blank" rel="noopener noreferrer" class="">@haze</a>, <a href="https://github.com/Vadimchesh" target="_blank" rel="noopener noreferrer" class="">@Vadimchesh</a>, <a href="https://github.com/peterdenham" target="_blank" rel="noopener noreferrer" class="">@peterdenham</a>, <a href="https://github.com/ShuZhong" target="_blank" rel="noopener noreferrer" class="">@ShuZhong</a>, <a href="https://github.com/manoraj" target="_blank" rel="noopener noreferrer" class="">@manoraj</a>, <a href="https://github.com/nicolo-ribaudo" target="_blank" rel="noopener noreferrer" class="">@nicolo-ribaudo</a>, <a href="https://github.com/georgekaran" target="_blank" rel="noopener noreferrer" class="">@georgekaran</a>, <a href="https://github.com/MathieuFedrigo" target="_blank" rel="noopener noreferrer" class="">@MathieuFedrigo</a>, <a href="https://github.com/hkdobrev" target="_blank" rel="noopener noreferrer" class="">@hkdobrev</a>, <a href="https://github.com/Germandrummer92" target="_blank" rel="noopener noreferrer" class="">@Germandrummer92</a>, <a href="https://github.com/CheadleCheadle" target="_blank" rel="noopener noreferrer" class="">@CheadleCheadle</a>, <a href="https://github.com/notaphplover" target="_blank" rel="noopener noreferrer" class="">@notaphplover</a>, <a href="https://github.com/danbeam" target="_blank" rel="noopener noreferrer" class="">@danbeam</a>, <a href="https://github.com/arescrimson" target="_blank" rel="noopener noreferrer" class="">@arescrimson</a>, <a href="https://github.com/yepitschunked" target="_blank" rel="noopener noreferrer" class="">@yepitschunked</a>, <a href="https://github.com/JimminiKin" target="_blank" rel="noopener noreferrer" class="">@JimminiKin</a>, <a href="https://github.com/DerTimonius" target="_blank" rel="noopener noreferrer" class="">@DerTimonius</a>, <a href="https://github.com/vkml" target="_blank" rel="noopener noreferrer" class="">@vkml</a>, <a href="https://github.com/ginabethrussell" target="_blank" rel="noopener noreferrer" class="">@ginabethrussell</a>, <a href="https://github.com/jeremiah-snee-openx" target="_blank" rel="noopener noreferrer" class="">@jeremiah-snee-openx</a>, <a href="https://github.com/WillianAgostini" target="_blank" rel="noopener noreferrer" class="">@WillianAgostini</a>, <a href="https://github.com/casey-lentz" target="_blank" rel="noopener noreferrer" class="">@casey-lentz</a>, <a href="https://github.com/faizanu94" target="_blank" rel="noopener noreferrer" class="">@faizanu94</a>, <a href="https://github.com/someone635" target="_blank" rel="noopener noreferrer" class="">@someone635</a>, <a href="https://github.com/rafaelrabelos" target="_blank" rel="noopener noreferrer" class="">@rafaelrabelos</a>, <a href="https://github.com/RayBrokeSomething" target="_blank" rel="noopener noreferrer" class="">@RayBrokeSomething</a>, <a href="https://github.com/DaniAcu" target="_blank" rel="noopener noreferrer" class="">@DaniAcu</a>, <a href="https://github.com/mattkubej" target="_blank" rel="noopener noreferrer" class="">@mattkubej</a>, <a href="https://github.com/tr1ckydev" target="_blank" rel="noopener noreferrer" class="">@tr1ckydev</a>, <a href="https://github.com/shresthasurav" target="_blank" rel="noopener noreferrer" class="">@shresthasurav</a>, <a href="https://github.com/the-ress" target="_blank" rel="noopener noreferrer" class="">@the-ress</a>, <a href="https://github.com/Mutesa-Cedric" target="_blank" rel="noopener noreferrer" class="">@Mutesa-Cedric</a>, <a href="https://github.com/nolddor" target="_blank" rel="noopener noreferrer" class="">@nolddor</a>, <a href="https://github.com/alexreardon" target="_blank" rel="noopener noreferrer" class="">@alexreardon</a>, <a href="https://github.com/Peeja" target="_blank" rel="noopener noreferrer" class="">@Peeja</a>, <a href="https://github.com/verycosy" target="_blank" rel="noopener noreferrer" class="">@verycosy</a>, <a href="https://github.com/mknight-atl" target="_blank" rel="noopener noreferrer" class="">@mknight-atl</a>, <a href="https://github.com/maro1993" target="_blank" rel="noopener noreferrer" class="">@maro1993</a>, <a href="https://github.com/Eric-Tyrrell22" target="_blank" rel="noopener noreferrer" class="">@Eric-Tyrrell22</a></p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 29: Snapshot format changes]]></title>
            <link>https://jestjs.io/blog/2022/08/25/jest-29</link>
            <guid>https://jestjs.io/blog/2022/08/25/jest-29</guid>
            <pubDate>Thu, 25 Aug 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Jest 29 is here, just a few short months after Jest 28. As mentioned in the Jest 28 blog post, this version contains just a couple of breaking changes, in order to make the upgrade as smooth as possible.]]></description>
            <content:encoded><![CDATA[<p>Jest 29 is here, just a few short months after Jest 28. As mentioned in the <a class="" href="https://jestjs.io/blog/2022/04/25/jest-28#future">Jest 28 blog post</a>, this version contains just a couple of breaking changes, in order to make the upgrade as smooth as possible.</p>
<p>The only breaking changes that should be noticeable are:</p>
<ul>
<li class="">
<p>Node versions 12 and 17 are dropped, both of which are EOL</p>
</li>
<li class="">
<p>The <code>snapshotFormat</code> property is changed to:</p>
<div class="language-diff codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-diff codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token inserted-sign inserted prefix inserted" style="color:#397300;background:#baeeba">+</span><span class="token inserted-sign inserted line" style="color:#397300;background:#baeeba"> snapshotFormat: {</span><br></span><span class="token-line" style="color:#393A34"><span class="token inserted-sign inserted line" style="color:#397300;background:#baeeba"></span><span class="token inserted-sign inserted prefix inserted" style="color:#397300;background:#baeeba">+</span><span class="token inserted-sign inserted line" style="color:#397300;background:#baeeba">   escapeString: false,</span><br></span><span class="token-line" style="color:#393A34"><span class="token inserted-sign inserted line" style="color:#397300;background:#baeeba"></span><span class="token inserted-sign inserted prefix inserted" style="color:#397300;background:#baeeba">+</span><span class="token inserted-sign inserted line" style="color:#397300;background:#baeeba">   printBasicPrototype: false</span><br></span><span class="token-line" style="color:#393A34"><span class="token inserted-sign inserted line" style="color:#397300;background:#baeeba"></span><span class="token inserted-sign inserted prefix inserted" style="color:#397300;background:#baeeba">+</span><span class="token inserted-sign inserted line" style="color:#397300;background:#baeeba"> }</span><br></span></code></pre></div></div>
</li>
<li class="">
<p><code>jest-environment-jsdom</code> has upgraded <code>jsdom</code> from v19 to v20</p>
</li>
</ul>
<p>There are certain changes to the types exposed by Jest, but probably (hopefully!) nothing that should impede the upgrade. Please see the <a href="https://jest-archive-august-2023.netlify.app/docs/upgrading-to-jest29" target="_blank" rel="noopener noreferrer" class="">upgrade guide</a> for more details.</p>
<p>That's it for breaking changes! Hopefully this means the upgrade path from Jest 28 is smooth. Please see the <a href="https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2900" target="_blank" rel="noopener noreferrer" class="">changelog</a> for other changes.</p>
<p>Thanks for reading, and happy Jesting! 🃏</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest joins OpenJS Foundation]]></title>
            <link>https://jestjs.io/blog/2022/05/11/jest-joins-openjs</link>
            <guid>https://jestjs.io/blog/2022/05/11/jest-joins-openjs</guid>
            <pubDate>Wed, 11 May 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Banner image for Meta Open Source and OpenJS Foundation]]></description>
            <content:encoded><![CDATA[<p><img decoding="async" loading="lazy" alt="Banner image for Meta Open Source and OpenJS Foundation" src="https://jestjs.io/assets/images/openjs-ba98de96267fe09d68d434f11271825b.png" width="8002" height="1278" class="img_SS3x"></p>
<p>Today we're excited to announce that Jest is joining the OpenJS Foundation!</p>
<p>This change transfers ownership of the project from Meta to the Jest Core team via the OpenJS Foundation as an Impact Project. We’re grateful to Meta for creating Jest and all of their support over the years, and we look forward to the future of Jest as a project owned by the Jest community!</p>
<p>Check out the <a href="https://developers.facebook.com/blog/post/2022/05/11/meta-open-source-transfers-jest-to-openjs-foundation/" target="_blank" rel="noopener noreferrer" class="">Meta Engineering blog</a> and <a href="https://openjsf.org/blog/2022/05/11/openjs-foundation-welcomes-jest/" target="_blank" rel="noopener noreferrer" class="">OpenJS Foundation blog</a> announcements for more info.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 28: Shedding weight and improving compatibility 🫶]]></title>
            <link>https://jestjs.io/blog/2022/04/25/jest-28</link>
            <guid>https://jestjs.io/blog/2022/04/25/jest-28</guid>
            <pubDate>Mon, 25 Apr 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Jest 28 is finally here, and it comes with some long requested features such as support for sharding a test run across multiple machines, package exports and the ability to customize the behavior of fake timers. These are just some personal highlights, and we'll be highlighting more in this blog post.]]></description>
            <content:encoded><![CDATA[<p>Jest 28 is finally here, and it comes with some long requested features such as support for <a class="" href="https://jestjs.io/docs/cli#--shard">sharding</a> a test run across multiple machines, <a href="https://nodejs.org/api/packages.html#exports" target="_blank" rel="noopener noreferrer" class="">package <code>exports</code></a> and the ability to customize the behavior of <a class="" href="https://jestjs.io/docs/jest-object#fake-timers">fake timers</a>. These are just some personal highlights, and we'll be highlighting more in this blog post.</p>
<p>Additionally, as announced in the <a class="" href="https://jestjs.io/blog/2021/05/25/jest-27">Jest 27 blog post</a> last year, we have removed some packages that no longer are used by default from the default installation. As a result the installation size has dropped by about 1/3.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="breaking-changes">Breaking changes<a href="https://jestjs.io/blog/2022/04/25/jest-28#breaking-changes" class="hash-link" aria-label="Direct link to Breaking changes" title="Direct link to Breaking changes" translate="no">​</a></h2>
<p>The list of breaking changes is long (and can be seen fully in the <a href="https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2800" target="_blank" rel="noopener noreferrer" class="">changelog</a>), but for migration purposes, we've also written <a href="https://jest-archive-august-2023.netlify.app/docs/28.x/upgrading-to-jest28/" target="_blank" rel="noopener noreferrer" class="">a guide</a> you can follow. Hopefully this makes the upgrade experience as frictionless as possible!</p>
<p>Main breaking changes likely to impact your migration are dropped support for Node 10 and 15 (but <em>not</em> Node 12, which will be EOL in a few days) and some renamed configuration options.</p>
<p>Please note that both of the removed modules (<code>jest-environment-jsdom</code> and <code>jest-jasmine2</code>) are still actively maintained and tested in the same way, so the only breaking change here is that you'll need to explicitly install them.</p>
<p>The guide should hopefully make migration trivial, but note that if you use any of the packages Jest consists of directly (such as <code>jest-worker</code> or <code>pretty-format</code>), instead of just running <code>jest</code>, then you need to go through the changelog to view any breaking changes.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="features">Features<a href="https://jestjs.io/blog/2022/04/25/jest-28#features" class="hash-link" aria-label="Direct link to Features" title="Direct link to Features" translate="no">​</a></h2>
<p>Now let's talk about the new features in Jest 28, which is way more exciting! And there's quite a few of them, so buckle up.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="sharding-of-test-run">Sharding of test run<a href="https://jestjs.io/blog/2022/04/25/jest-28#sharding-of-test-run" class="hash-link" aria-label="Direct link to Sharding of test run" title="Direct link to Sharding of test run" translate="no">​</a></h3>
<p>Jest now includes a new <a class="" href="https://jestjs.io/docs/cli#--shard"><code>--shard</code></a> CLI option, contributed by <a href="https://github.com/marionebl" target="_blank" rel="noopener noreferrer" class="">Mario Nebl</a>. It allows you to run parts of your test across different machine, and has been one of Jest's oldest feature requests.</p>
<p>Jest's own test suite on CI went from about 10 minutes to 3 on Ubuntu, and on Windows from 20 minutes to 7.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="packagejson-exports"><code>package.json</code> <code>exports</code><a href="https://jestjs.io/blog/2022/04/25/jest-28#packagejson-exports" class="hash-link" aria-label="Direct link to packagejson-exports" title="Direct link to packagejson-exports" translate="no">​</a></h3>
<p>Jest shipped minimal support of <a href="https://nodejs.org/api/packages.html#exports" target="_blank" rel="noopener noreferrer" class=""><code>exports</code></a> in 27.3. However, it only supported the "main" entry point (<code>.</code>), and only if no <code>main</code> field was present in <code>package.json</code>. With Jest 28 we're excited to finally be shipping full support!</p>
<p>Related, in Jest 27, we provided either <code>require</code> or <code>import</code> condition. In Jest 28, <code>jest-environment-node</code> will now automatically provide <code>node</code> and <code>node-addons</code> conditions, while <code>jest-environment-jsdom</code> will provide the <code>browser</code> condition.</p>
<p>This has been one of the biggest compatibility issues of Jest, and hopefully this is now resolved once and for all.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="fake-timers">Fake timers<a href="https://jestjs.io/blog/2022/04/25/jest-28#fake-timers" class="hash-link" aria-label="Direct link to Fake timers" title="Direct link to Fake timers" translate="no">​</a></h3>
<p>Jest 26 introduced the concept of "modern" fake timers, which uses <a href="https://www.npmjs.com/package/@sinonjs/fake-timers" target="_blank" rel="noopener noreferrer" class=""><code>@sinonjs/fake-timers</code></a> under the hood, and Jest 27 made it the default. In Jest 28, we are now exposing more of the underlying implementation through both configuration and runtime APIs. Huge thanks to <a href="https://github.com/mrazauskas" target="_blank" rel="noopener noreferrer" class="">Tom Mrazauskas</a> who contributed this feature!</p>
<p>This allows you to not mock out <code>process.nextTick</code> which improves compatibility with fake <code>Promise</code>s, or to enable <code>advanceTimers</code> which automatically advance timers.</p>
<p>Please see <a class="" href="https://jestjs.io/docs/configuration#faketimers-object">the <code>fakeTimers</code> configuration</a> for details.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="github-actions-reporter">GitHub Actions Reporter<a href="https://jestjs.io/blog/2022/04/25/jest-28#github-actions-reporter" class="hash-link" aria-label="Direct link to GitHub Actions Reporter" title="Direct link to GitHub Actions Reporter" translate="no">​</a></h3>
<p>Jest now ships with a reporter to be used on GitHub Actions, which will use annotations to print test errors inline.</p>
<p><img decoding="async" loading="lazy" alt="GitHub Actions test error screenshot" src="https://jestjs.io/assets/images/28-gh-actions-reporter-1ee03f15b770cc9e04bb15ad1a532e1d.png" width="2286" height="554" class="img_SS3x"></p>
<p>You can activate this reporter by passing <code>github-actions</code> in the <a class="" href="https://jestjs.io/docs/configuration#reporters-arraymodulename--modulename-options"><code>reporters</code> configuration option</a>.</p>
<p>Huge thanks to <a href="https://github.com/ockham" target="_blank" rel="noopener noreferrer" class="">Bernie Reiter</a> and other contributors for sticking by us and finally landing this feature.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="inline-testenvironmentoptions">Inline <code>testEnvironmentOptions</code><a href="https://jestjs.io/blog/2022/04/25/jest-28#inline-testenvironmentoptions" class="hash-link" aria-label="Direct link to inline-testenvironmentoptions" title="Direct link to inline-testenvironmentoptions" translate="no">​</a></h3>
<p>You can now pass <a class="" href="https://jestjs.io/docs/configuration#testenvironmentoptions-object"><code>testEnvironmentOptions</code></a> inline in a file, similar to how you can set test environment. This is useful if you want to e.g. change the URL in a single file.</p>
<div class="language-js codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-js codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token doc-comment comment" style="color:#999988;font-style:italic">/**</span><br></span><span class="token-line" style="color:#393A34"><span class="token doc-comment comment" style="color:#999988;font-style:italic"> * </span><span class="token doc-comment comment keyword" style="color:#297a29;font-style:italic">@jest-environment</span><span class="token doc-comment comment" style="color:#999988;font-style:italic"> jsdom</span><br></span><span class="token-line" style="color:#393A34"><span class="token doc-comment comment" style="color:#999988;font-style:italic"> * </span><span class="token doc-comment comment keyword" style="color:#297a29;font-style:italic">@jest-environment-options</span><span class="token doc-comment comment" style="color:#999988;font-style:italic"> </span><span class="token doc-comment comment punctuation" style="color:#393A34;font-style:italic">{</span><span class="token doc-comment comment" style="color:#999988;font-style:italic">"url": "https://jestjs.io/"</span><span class="token doc-comment comment punctuation" style="color:#393A34;font-style:italic">}</span><span class="token doc-comment comment" style="color:#999988;font-style:italic"></span><br></span><span class="token-line" style="color:#393A34"><span class="token doc-comment comment" style="color:#999988;font-style:italic"> */</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#6b2e85">test</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'use jsdom and set the URL in this test file'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#888">=&gt;</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token function" style="color:#6b2e85">expect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token dom variable" style="color:#1373c2">window</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">location</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">href</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">toBe</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'https://jestjs.io/'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="all-nodejs-globals">All Node.js globals<a href="https://jestjs.io/blog/2022/04/25/jest-28#all-nodejs-globals" class="hash-link" aria-label="Direct link to All Node.js globals" title="Direct link to All Node.js globals" translate="no">​</a></h3>
<p>If you are using the new <a href="https://nodejs.org/en/blog/announcements/v18-release-announce/#fetch-experimental" target="_blank" rel="noopener noreferrer" class=""><code>fetch</code></a> implementation in Node v18, you might have noticed that this function is not available in Jest. It has been a long-standing issue that we have to manually copy over any globals into the test globals. With Jest 28, this is no longer an issue as we now inspect the global environment Jest itself is running in, and copy over any globals that are missing in the test environment.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="ecmascript-modules">ECMAScript Modules<a href="https://jestjs.io/blog/2022/04/25/jest-28#ecmascript-modules" class="hash-link" aria-label="Direct link to ECMAScript Modules" title="Direct link to ECMAScript Modules" translate="no">​</a></h3>
<p>Not much has changed in Jest's support for native ESM since Jest 27 came out. We continue to be blocked by <a href="https://github.com/nodejs/node/issues/37648" target="_blank" rel="noopener noreferrer" class="">stabilization in Node</a>, and are hopeful this situation will improve sooner rather than later!</p>
<p>However, we have been able to add a couple of new features in Jest 28.</p>
<h4 class="anchor anchorTargetStickyNavbar_tleR" id="data-urls"><code>data:</code> URLs<a href="https://jestjs.io/blog/2022/04/25/jest-28#data-urls" class="hash-link" aria-label="Direct link to data-urls" title="Direct link to data-urls" translate="no">​</a></h4>
<p><a href="https://github.com/tbossi" target="_blank" rel="noopener noreferrer" class="">Tommaso Bossi</a> has contributed support for <a href="https://nodejs.org/api/esm.html#data-imports" target="_blank" rel="noopener noreferrer" class=""><code>data</code> URLs</a>, meaning you can now inline define some JavaScript to run without using <code>eval</code>.</p>
<h4 class="anchor anchorTargetStickyNavbar_tleR" id="importmetajest"><code>import.meta.jest</code><a href="https://jestjs.io/blog/2022/04/25/jest-28#importmetajest" class="hash-link" aria-label="Direct link to importmetajest" title="Direct link to importmetajest" translate="no">​</a></h4>
<p>While you have been able to access <code>jest</code> via <code>import {jest} from '@jest/globals'</code> in Jest, we've received feedback that this is less ergonomical than the (seemingly, but not really) global <code>jest</code> variable available in CJS. So Jest 28 ships with <code>import.meta.jest</code> to allow easier access.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="miscellaneous">Miscellaneous<a href="https://jestjs.io/blog/2022/04/25/jest-28#miscellaneous" class="hash-link" aria-label="Direct link to Miscellaneous" title="Direct link to Miscellaneous" translate="no">​</a></h3>
<p>That's quite a lot of features, and are my personal highlights. However, we still have many more which I'll quickly go through:</p>
<h4 class="anchor anchorTargetStickyNavbar_tleR" id="asynchronous-resolvers">Asynchronous resolvers<a href="https://jestjs.io/blog/2022/04/25/jest-28#asynchronous-resolvers" class="hash-link" aria-label="Direct link to Asynchronous resolvers" title="Direct link to Asynchronous resolvers" translate="no">​</a></h4>
<p><a href="https://github.com/IanVS" target="_blank" rel="noopener noreferrer" class="">Ian VanSchooten</a> has contributed support for <a class="" href="https://jestjs.io/docs/configuration#resolver-string">asynchronous resolvers</a>, which enables tools like <a href="https://vitejs.dev/" target="_blank" rel="noopener noreferrer" class="">Vite</a> to have better integrations with Jest.</p>
<h4 class="anchor anchorTargetStickyNavbar_tleR" id="asynchronous-setup-files">Asynchronous setup files<a href="https://jestjs.io/blog/2022/04/25/jest-28#asynchronous-setup-files" class="hash-link" aria-label="Direct link to Asynchronous setup files" title="Direct link to Asynchronous setup files" translate="no">​</a></h4>
<p>If you have some async work you want to do when using <code>setupFiles</code>, you can now export an <code>async function</code>, which Jest will call and await before loading any tests.</p>
<p>Note that this feature is only available for CJS. For ESM, we recommend using top-level <code>await</code> instead.</p>
<h4 class="anchor anchorTargetStickyNavbar_tleR" id="using-globalthis">Using <code>globalThis</code><a href="https://jestjs.io/blog/2022/04/25/jest-28#using-globalthis" class="hash-link" aria-label="Direct link to using-globalthis" title="Direct link to using-globalthis" translate="no">​</a></h4>
<p>Internally, Jest has been using <code>global</code> to refer to the <a href="https://developer.mozilla.org/en-US/docs/Glossary/Global_object" target="_blank" rel="noopener noreferrer" class="">global environment</a>. However, since this only exists in Node, and not browsers (<code>window</code>), this led to incompatibility when attempting to use Jest's modules in another environment.</p>
<p>Jest 28 uses <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis" target="_blank" rel="noopener noreferrer" class=""><code>globalThis</code></a> instead, which works in all environments.</p>
<h4 class="anchor anchorTargetStickyNavbar_tleR" id="jsdom-19">JSDOM 19<a href="https://jestjs.io/blog/2022/04/25/jest-28#jsdom-19" class="hash-link" aria-label="Direct link to JSDOM 19" title="Direct link to JSDOM 19" translate="no">​</a></h4>
<p>While, as mentioned, Jest no longer ships <code>jest-environment-jsdom</code> in the default installation, it is still actively maintained. As part of that, Jest 28 has upgraded from <code>jsdom@16</code> to <code>jsdom@19</code>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="typescript">TypeScript<a href="https://jestjs.io/blog/2022/04/25/jest-28#typescript" class="hash-link" aria-label="Direct link to TypeScript" title="Direct link to TypeScript" translate="no">​</a></h2>
<p>If you use Jest with TypeScript, either in your tests or when writing plugins such as custom runners, Jest 28 comes with extensive improvements to our types. Here's a non-exhaustive list of the changes in Jest 28.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="expect"><code>expect</code><a href="https://jestjs.io/blog/2022/04/25/jest-28#expect" class="hash-link" aria-label="Direct link to expect" title="Direct link to expect" translate="no">​</a></h3>
<p>When using <code>expect</code>'s own types (either directly, or via <code>import {expect} from '@jest/globals'</code>), it's now finally possible to add custom matchers. See our <a href="https://github.com/jestjs/jest/tree/main/examples/expect-extend" target="_blank" rel="noopener noreferrer" class="">example</a> for how to do this.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="custom-plugins">Custom plugins<a href="https://jestjs.io/blog/2022/04/25/jest-28#custom-plugins" class="hash-link" aria-label="Direct link to Custom plugins" title="Direct link to Custom plugins" translate="no">​</a></h3>
<p>If you write a custom runner, test reporter, resolver or something else, we now export more types that should help you type these more correctly. This is a moving target, so if you are the author of something pluggable in Jest and the types aren't as useful as they could be, please file an issue!</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="jest-runner-tsd"><code>jest-runner-tsd</code><a href="https://jestjs.io/blog/2022/04/25/jest-28#jest-runner-tsd" class="hash-link" aria-label="Direct link to jest-runner-tsd" title="Direct link to jest-runner-tsd" translate="no">​</a></h3>
<p><a href="https://github.com/jest-community/jest-runner-tsd" target="_blank" rel="noopener noreferrer" class=""><code>jest-runner-tsd</code></a> is a custom runner for running type tests. This is what Jest uses itself to test our types, and we hope it can also be used by others! As its name implies, it is based on <a href="https://npmjs.com/package/tsd" target="_blank" rel="noopener noreferrer" class=""><code>tsd</code></a>, although it under the hood uses the fork <a href="https://npmjs.com/package/tsd-lite" target="_blank" rel="noopener noreferrer" class=""><code>tsd-lite</code></a>.</p>
<hr>
<p>All of these improvements and fixes has been contributed by <a href="https://github.com/mrazauskas" target="_blank" rel="noopener noreferrer" class="">Tom Mrazauskas</a>. Thank you so much, Tom! 👏</p>
<p>Lastly, the minimum support version of TypeScript is now 4.3.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="jest-light-runner"><code>jest-light-runner</code><a href="https://jestjs.io/blog/2022/04/25/jest-28#jest-light-runner" class="hash-link" aria-label="Direct link to jest-light-runner" title="Direct link to jest-light-runner" translate="no">​</a></h2>
<p>The last thing we want to highlight in this blog post, is a very cool new Jest runner, created by <a href="https://github.com/nicolo-ribaudo" target="_blank" rel="noopener noreferrer" class="">Nicolò Ribaudo</a>, called <a href="https://www.npmjs.com/package/jest-light-runner" target="_blank" rel="noopener noreferrer" class=""><code>jest-light-runner</code></a>. This takes almost all of the DX Jest is known for, and speeds it way up by being a smaller abstraction on top of Node. Babel's tests became almost twice as fast after migrating. While there are caveats, the existence of this runner should make it even easier for people who have smaller Node modules to test to choose Jest. Thanks, Nicolò!</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="future">Future<a href="https://jestjs.io/blog/2022/04/25/jest-28#future" class="hash-link" aria-label="Direct link to Future" title="Direct link to Future" translate="no">​</a></h2>
<p>While Jest 28 came almost a year after Jest 27, Jest 29 will be coming sooner, probably in just a few months. The current plan then is to just have one breaking change (except dropping Node versions), and that is to default <a class="" href="https://jestjs.io/docs/configuration#snapshotformat-object"><code>snapshotFormat</code></a> to <code>{escapeString: false, printBasicPrototype: false}</code>. This makes snapshots both more readable and more copy-pasteable.</p>
<p>This will of course be possible to override if you don't want to change, but you can also use those options today if you don't want to wait!</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="acknowledgements">Acknowledgements<a href="https://jestjs.io/blog/2022/04/25/jest-28#acknowledgements" class="hash-link" aria-label="Direct link to Acknowledgements" title="Direct link to Acknowledgements" translate="no">​</a></h2>
<p>Jest 28 contains contributions from more than 60 people, of which more than two thirds are first time contributors. Thank you so much to all contributors, old and new. Without you the project wouldn't be nearly as good as it is! I'd particularly like to thank <a href="https://github.com/mrazauskas" target="_blank" rel="noopener noreferrer" class="">Tom Mrazauskas</a> and <a href="https://github.com/F3n67u" target="_blank" rel="noopener noreferrer" class="">Feng Yu</a> for all their contributions, from code, to issue triaging to debugging, that made Jest 28 what it is. Thank you! 🙏</p>
<p>Thanks for reading, and happy Jesting! 🃏</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 27: New Defaults for Jest, 2021 edition ⏩]]></title>
            <link>https://jestjs.io/blog/2021/05/25/jest-27</link>
            <guid>https://jestjs.io/blog/2021/05/25/jest-27</guid>
            <pubDate>Tue, 25 May 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[In the Jest 26 blog post about a year ago, we announced that after two major releases with few breaking changes, Jest 27 will flip some switches to set better defaults for projects that are new or can migrate smoothly. This gives us the opportunity to remove some packages from the default distribution of Jest 28 and publish them as separately installable and pluggable modules instead. Everyone on the new defaults can benefit from a smaller install size, while people needing these packages can still install them separately.]]></description>
            <content:encoded><![CDATA[<p>In the <a class="" href="https://jestjs.io/blog/2020/05/05/jest-26">Jest 26 blog post</a> about a year ago, we announced that after two major releases with few breaking changes, Jest 27 will flip some switches to set better defaults for projects that are new or can migrate smoothly. This gives us the opportunity to remove some packages from the default distribution of Jest 28 and publish them as separately installable and pluggable modules instead. Everyone on the new defaults can benefit from a smaller install size, while people needing these packages can still install them separately.</p>
<p>With the first major change of defaults since the <a class="" href="https://jestjs.io/blog/2016/09/01/jest-15">New Defaults for Jest</a> that came with the seminal version 15, Jest 27 is now here, to keep Jest fast, lean, and relevant in the future. We will explain those changes of defaults and other notable breaking changes in this post, but first, let's get into some exciting new features!</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="feature-updates">Feature updates<a href="https://jestjs.io/blog/2021/05/25/jest-27#feature-updates" class="hash-link" aria-label="Direct link to Feature updates" title="Direct link to Feature updates" translate="no">​</a></h2>
<p>Firstly, the interactive mode you may know from reviewing and updating failed snapshots can now also be used to <strong>step through failed tests</strong> one at a time. Credit goes to first-time contributor <a href="https://github.com/NullDivision" target="_blank" rel="noopener noreferrer" class="">@NullDivision</a> for <a href="https://github.com/jestjs/jest/pull/10858" target="_blank" rel="noopener noreferrer" class="">implementing</a> this feature!</p>
<p><img decoding="async" loading="lazy" alt="Interactive failed test run" src="https://jestjs.io/assets/images/27-interactive-failures-e22e3b31b285188ed65f6432cb21df30.png" width="2416" height="1289" class="img_SS3x"></p>
<p>Speaking of snapshots, one of the more exciting features we've shipped in recent years are Inline Snapshots, which <a href="https://github.com/jestjs/jest/pull/6380" target="_blank" rel="noopener noreferrer" class="">landed</a> in a minor release of Jest 23 almost three years ago. However, they came with the restriction that projects wanting to utilize them must be using <a href="https://prettier.io/" target="_blank" rel="noopener noreferrer" class="">Prettier</a> to format their code, because that's what Jest would use to make sure the file it writes the snapshots into remains properly formatted.<br>
<!-- -->And so for most of these years, we've had a <a href="https://github.com/jestjs/jest/pull/7792" target="_blank" rel="noopener noreferrer" class="">pull request</a> in the pipeline to eliminate this restriction and allow using <strong>Inline Snapshots without Prettier</strong>. It has amassed well above a hundred comments, not even taking into account PRs split out from it and landed first, and even changed owner once after the initial submission by another first-time contributor, <a href="https://github.com/mmkal" target="_blank" rel="noopener noreferrer" class="">@mmkal</a> under the hilarious working title 'Uglier Inline Snapshots'. With the stellar rise of Prettier in recent times, this improvement is now maybe less needed than back in 2018, but still, we know that feeling of getting into a project that does not use Prettier, and suddenly not being able to use inline snapshots anymore. Nevermore!</p>
<p>The main reason why it took us so long to land this was, somewhat surprisingly, an out of memory error on our build pipeline. It turns out that the dependencies we load for each test file to perform the parsing, snapshot insertion, and printing do incur a significant time and memory overhead.<br>
<!-- -->So with some <a href="https://github.com/jestjs/jest/issues/9898" target="_blank" rel="noopener noreferrer" class="">tricks</a>, we've <strong>speed up the initialization per test file</strong> by roughly 70% compared to Jest 26. Note that you will almost certainly not see this big of a performance improvement on your project—you would need a lot of test files that each run very quickly to best notice this, and the overhead when using a <a class="" href="https://jestjs.io/docs/configuration#testenvironment-string">JSDOM environment</a> dwarfs any such improvement.</p>
<p>In other news, the <a href="https://github.com/jestjs/jest/issues/9430" target="_blank" rel="noopener noreferrer" class="">native ESM support</a> is progressing, but some major complexities, for instance around mocking, are still ahead of us, and we continue to observe the migration to ESM as a huge ecosystem effort, where Node and a lot of crucial tools and packages all have to rely on each other to deliver an overall compelling experience.<br>
<!-- -->ESM support <a href="https://github.com/jestjs/jest/issues/11167" target="_blank" rel="noopener noreferrer" class="">for plugging modules into Jest</a> is more advanced—custom runners, reporters, watch plugins, and many other modules can already be loaded as ES modules.</p>
<p>We've also merged <a href="https://github.com/jestjs/jest/pull/9351" target="_blank" rel="noopener noreferrer" class="">a PR</a> to be able to deal with test files symlinked into the test directory, a feature much wanted by users of <a href="https://bazel.build/" target="_blank" rel="noopener noreferrer" class="">Bazel</a>.</p>
<p><a href="https://github.com/jestjs/jest/issues/9504" target="_blank" rel="noopener noreferrer" class="">Another PR</a> enabled <a class="" href="https://jestjs.io/docs/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object"><code>transform</code>s</a> to be asynchronous, a requirement to support transpilation through tools such as <a href="https://esbuild.github.io/" target="_blank" rel="noopener noreferrer" class="">esbuild</a>, <a href="https://www.snowpack.dev/" target="_blank" rel="noopener noreferrer" class="">Snowpack</a>, and <a href="https://vitejs.dev/" target="_blank" rel="noopener noreferrer" class="">Vite</a> effectively.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="flipping-defaults">Flipping defaults<a href="https://jestjs.io/blog/2021/05/25/jest-27#flipping-defaults" class="hash-link" aria-label="Direct link to Flipping defaults" title="Direct link to Flipping defaults" translate="no">​</a></h2>
<p>Up until now, if you were using Jest in its default configuration, you were—perhaps unknowingly—running some code forked many years ago from the test runner <a href="https://jasmine.github.io/2.0/introduction" target="_blank" rel="noopener noreferrer" class="">Jasmine 2.0</a> that provides test framework functions such as <code>describe</code>, <code>it</code>, and <code>beforeEach</code>. In 2017, <a href="https://github.com/aaronabramov" target="_blank" rel="noopener noreferrer" class="">Aaron Abramov</a> <a href="https://github.com/jestjs/jest/pull/3668" target="_blank" rel="noopener noreferrer" class="">initially wrote</a> a <strong>replacement for the Jasmine code</strong> called <code>jest-circus</code>, meant to improve error messages, maintainability, and extensibility.<br>
<!-- -->After years of large-scale use at Facebook and of course in Jest itself, as well as recent adoption in <code>create-react-app</code>, we are now confident that <code>jest-circus</code> is highly compatible with <code>jest-jasmine2</code> and should work in most environments with little to no migration work. There may be minor differences in execution order and strictness, but we expect no major upgrade difficulties other than for code relying on Jasmine-specific APIs such as <code>jasmine.getEnv()</code>. If you rely extensively on such APIs, you can opt back in to the Jasmine-based test runner by <a class="" href="https://jestjs.io/docs/configuration#testrunner-string">configuring</a> <code>"testRunner": "jest-jasmine2"</code>.</p>
<p>Running tests in a <a class="" href="https://jestjs.io/docs/configuration#testenvironment-string">JSDOM environment</a> incurs a significant performance overhead. Because this was the default behavior of Jest unless otherwise configured up until now, users who are writing Node apps, for example, may not even know they are given an expensive DOM environment that they do not even need.<br>
<!-- -->For this reason, we are <strong>changing the default test environment</strong> from <code>"jsdom"</code> to <code>"node"</code>. If you are affected by this change because you use DOM APIs and do not have the test environment explicitly configured, you should be receiving an error when e.g. <code>document</code> is accessed, and you can configure <code>"testEnvironment": "jsdom"</code> or use <a class="" href="https://jestjs.io/docs/configuration#testenvironment-string">per-file environment configuration</a> to resolve this.<br>
<!-- -->For mixed projects where some tests require a DOM environment but others don't, we recommend using the fast <code>"node"</code> environment by default and declaring exactly those tests that need the DOM using <a class="" href="https://jestjs.io/docs/configuration#testenvironment-string">docblocks</a>.<br>
<!-- -->In the next major, we plan to also eliminate <code>jest-jasmine2</code> and <code>jest-environment-jsdom</code> from the Jest dependency tree and require them to be installed explicitly, so that many users can profit from a smaller install size with less clutter that they don't need.</p>
<p>Another default that we are changing affects Fake Timers aka <a class="" href="https://jestjs.io/docs/timer-mocks">Timer Mocks</a>. We introduced an opt-in "modern" implementation of Fake Timers in Jest 26 accessed transparently through the same API, but with much more comprehensive mocking, such as for <code>Date</code> and <code>queueMicrotask</code>.<br>
<!-- -->This <strong>modern fake timers implementation will now be the default</strong>. If you are among the unlucky few who are affected by the subtle implementation differences too heavily to migrate, you can get back the old implementation using <code>jest.useFakeTimers("legacy")</code> or, if you are enabling fake timers globally via <a class="" href="https://jestjs.io/docs/configuration#timers-string">configuration</a>, <code>"timers": "legacy"</code>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="features-coming-with-breaking-changes">Features coming with breaking changes<a href="https://jestjs.io/blog/2021/05/25/jest-27#features-coming-with-breaking-changes" class="hash-link" aria-label="Direct link to Features coming with breaking changes" title="Direct link to Features coming with breaking changes" translate="no">​</a></h2>
<p>We introduced a few more small breaking changes to help you avoid mistakes by disallowing some things that can easily happen unintentionally:</p>
<ul>
<li class="">The same <code>done</code> test callback may not be called more than once,</li>
<li class="">calling <code>done</code> and returning a Promise may not be combined,</li>
<li class="">a <code>describe</code> block must not return anything,</li>
</ul>
<p>and we <a href="https://github.com/jestjs/jest/pull/10512" target="_blank" rel="noopener noreferrer" class="">made some TypeScript types stricter</a>.</p>
<p>Modules used in the following configuration options are now transformed like the rest of your code, which may be breaking if you relied on them being loaded as-is:</p>
<ul>
<li class=""><code>testEnvironment</code></li>
<li class=""><code>runner</code></li>
<li class=""><code>testRunner</code></li>
<li class=""><code>snapshotResolver</code></li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="miscellaneous-breaking-changes">Miscellaneous breaking changes<a href="https://jestjs.io/blog/2021/05/25/jest-27#miscellaneous-breaking-changes" class="hash-link" aria-label="Direct link to Miscellaneous breaking changes" title="Direct link to Miscellaneous breaking changes" translate="no">​</a></h2>
<p>We removed some long-deprecated functions:</p>
<ul>
<li class=""><code>jest.addMatchers</code> (use <code>expect.extend</code> instead)</li>
<li class=""><code>jest.resetModuleRegistry</code> (use <code>jest.resetModules</code> instead)</li>
<li class=""><code>jest.runTimersToTime</code> (use <code>jest.advanceTimersByTime</code> instead)</li>
</ul>
<p>A lot of Jest's packages have been migrated to use ESM-style exports (although they are still shipped as CommonJS), so if you consume e.g. <code>pretty-format</code> directly, you may need to adjust your import to a <code>default</code> import.</p>
<p>We dropped support for Node 13—but Jest always supports the <em>Current</em> and all <em>LTS</em> <a href="https://nodejs.org/en/about/releases/" target="_blank" rel="noopener noreferrer" class="">Node versions</a>, and Jest 27 continues to support Node 10, which only recently became unmaintained.</p>
<p>As always, the full changelog and list of breaking changes can be <a href="https://github.com/jestjs/jest/blob/main/CHANGELOG.md#2700" target="_blank" rel="noopener noreferrer" class="">viewed here</a>.</p>
<p>Finally, we'd like to thank the community for once again awarding Jest a sky-high satisfaction rating of 96% in the <a href="https://2020.stateofjs.com/en-US/technologies/testing/" target="_blank" rel="noopener noreferrer" class="">State of JS 2020</a> survey! Stay safe everyone, and we hope you continue to enjoy using Jest in the years and versions to come! 🃏</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest Website Upgrade]]></title>
            <link>https://jestjs.io/blog/2021/03/09/jest-website-upgrade</link>
            <guid>https://jestjs.io/blog/2021/03/09/jest-website-upgrade</guid>
            <pubDate>Tue, 09 Mar 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[We are excited to present the new Jest website!]]></description>
            <content:encoded><![CDATA[<p>We are excited to present the <strong>new Jest website</strong>!</p>
<p>The Jest site was upgraded from <strong><a href="https://v1.docusaurus.io/" target="_blank" rel="noopener noreferrer" class="">Docusaurus 1</a></strong> to <strong><a href="https://v2.docusaurus.io/" target="_blank" rel="noopener noreferrer" class="">Docusaurus 2</a></strong>, and is an early adopter of the <a href="https://v2.docusaurus.io/blog/2021/03/09/releasing-docusaurus-i18n" target="_blank" rel="noopener noreferrer" class="">newly released Docusaurus 2 i18n support</a>.</p>
<p>So, what's new exactly?</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="whats-new">What's new?<a href="https://jestjs.io/blog/2021/03/09/jest-website-upgrade#whats-new" class="hash-link" aria-label="Direct link to What's new?" title="Direct link to What's new?" translate="no">​</a></h2>
<p>Here's a good overview of the most visible improvements:</p>
<ul>
<li class="">
<p><strong>Dark Mode</strong>: change the color scheme through the navbar switch.</p>
</li>
<li class="">
<p><strong>Modern navigation</strong>: we improved the navigation experience with <strong>client-side routing</strong> and <strong>prefetching</strong>.</p>
</li>
<li class="">
<p><strong>Versions dropdown</strong>: it is now simpler to switch from one Jest version to another.</p>
</li>
<li class="">
<p><strong>Progressive-Web-App</strong>: you can install the Jest website and browse it offline.</p>
</li>
<li class="">
<p><strong>Search</strong>: try the new Algolia <strong>DocSearch v3</strong> user-experience. It is now possible to <strong>search in blog posts</strong>.</p>
</li>
<li class="">
<p><strong>I18n</strong>: Jest is the first website using the <strong><a href="https://v2.docusaurus.io/docs/i18n/introduction" target="_blank" rel="noopener noreferrer" class="">new i18n feature of Docusaurus 2</a></strong>. It is now possible to <strong>translate blog posts</strong>.</p>
</li>
<li class="">
<p><strong>MDX</strong>: embedding React components in Markdown will allow maintainers to make the <strong>documentation more interactive</strong>.</p>
</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="for-site-translators">For site translators<a href="https://jestjs.io/blog/2021/03/09/jest-website-upgrade#for-site-translators" class="hash-link" aria-label="Direct link to For site translators" title="Direct link to For site translators" translate="no">​</a></h2>
<p>If you want to help to translate the new Jest website, please use the new Crowdin project <a href="https://crowdin.com/project/jest-v2" target="_blank" rel="noopener noreferrer" class="">jest-v2</a> instead of the previous one.</p>
<div class="theme-admonition theme-admonition-note admonition_WCGJ alert alert--secondary"><div class="admonitionHeading_GCBg"><span class="admonitionIcon_L39b"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_pbrs"><p>In localized pages, the edit button now links directly to Crowdin.</p></div></div>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="thanks">Thanks<a href="https://jestjs.io/blog/2021/03/09/jest-website-upgrade#thanks" class="hash-link" aria-label="Direct link to Thanks" title="Direct link to Thanks" translate="no">​</a></h2>
<p>Thanks to all the contributors that supported or reviewed this migration: <a href="https://github.com/SimenB" target="_blank" rel="noopener noreferrer" class="">Simen</a>, <a href="https://github.com/orta" target="_blank" rel="noopener noreferrer" class="">Orta</a>, <a href="https://github.com/JoelMarcey" target="_blank" rel="noopener noreferrer" class="">Joel</a>, <a href="https://github.com/merceyz" target="_blank" rel="noopener noreferrer" class="">Kristoffer</a>...</p>
<p>Please report any problem on the <a href="https://github.com/jestjs/jest/pull/11021" target="_blank" rel="noopener noreferrer" class="">migration issue</a>.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 26: Tick Tock]]></title>
            <link>https://jestjs.io/blog/2020/05/05/jest-26</link>
            <guid>https://jestjs.io/blog/2020/05/05/jest-26</guid>
            <pubDate>Tue, 05 May 2020 00:00:00 GMT</pubDate>
            <description><![CDATA[When we started rebuilding Jest five years ago our goal was to provide a batteries-included zero-configuration test runner that is approachable for beginners, extensible for almost all testing use cases and scalable to large projects. One of the instrumental releases was Jest 15 which tied everything together and provided good defaults that allowed people to run Jest often without any setup. However, this approach has a big downside as Jest installs a lot of dependencies into your projects that you may not need.]]></description>
            <content:encoded><![CDATA[<p>When we started rebuilding Jest five years ago our goal was to provide a batteries-included zero-configuration test runner that is approachable for beginners, extensible for almost all testing use cases and scalable to large projects. One of the instrumental releases was <a class="" href="https://jestjs.io/blog/2016/09/01/jest-15">Jest 15</a> which tied everything together and provided good defaults that allowed people to run Jest often without any setup. However, this approach has a big downside as Jest installs a lot of dependencies into your projects that you may not need.</p>
<p>We are now beginning to address this shortcoming and are working on reducing Jest’s install size while keeping it approachable and extensible. We have made the following <strong>breaking changes</strong> in Jest 26:</p>
<ul>
<li class="">
<p><code>[expect, jest-mock, pretty-format]</code> Remove <code>ES5</code> build files with a new minimum of support of ES2015 (Node 8) which were only used for browser builds (<a href="https://github.com/jestjs/jest/pull/9945" target="_blank" rel="noopener noreferrer" class="">#9945</a>)</p>
<blockquote>
<p><strong>Migration</strong>: With this change, we are pushing the responsibility to bundle the affected packages to the users, rather than Jest providing them out of the box, since they know their target environments best. If you want it back, we're open to shipping these as separate packages. PRs welcome!</p>
</blockquote>
</li>
<li class="">
<p><code>[jest-config, jest-resolve]</code> Remove support for <code>browser</code> field (<a href="https://github.com/jestjs/jest/pull/9943" target="_blank" rel="noopener noreferrer" class="">#9943</a>)</p>
<blockquote>
<p><strong>Migration</strong>: Install <code>browser-resolve</code> module and use the following configuration:</p>
</blockquote>
<div class="language-json codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-json codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token property" style="color:#82772c">"jest"</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#82772c">"resolver"</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token string" style="color:#c21325">"&lt;rootDir&gt;/resolver.js"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></span></code></pre></div></div>
<div class="language-js codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-js codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token comment" style="color:#999988;font-style:italic">// resolver.js</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#297a29">const</span><span class="token plain"> browserResolve </span><span class="token operator" style="color:#888">=</span><span class="token plain"> </span><span class="token function" style="color:#6b2e85">require</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'browser-resolve'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">module</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">exports</span><span class="token plain"> </span><span class="token operator" style="color:#888">=</span><span class="token plain"> browserResolve</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">sync</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
</li>
<li class="">
<p>TypeScript definitions requires a minimum of TypeScript v3.8 (<a href="https://github.com/jestjs/jest/pull/9823" target="_blank" rel="noopener noreferrer" class="">#9823</a>)</p>
</li>
</ul>
<p>With the above changes Jest 26 is now 4 MiB smaller than Jest 25.5.4 (53 → 49 MiB). Please keep in mind that many dependencies like Babel are likely already part of your project. Jest's own size was reduced by 1.2 MiB (4.3 -&gt; 3.1 MiB).</p>
<p>While this is a good start, it isn’t enough to make Jest meaningfully leaner. We are planning on gradually reducing Jest's and its dependency tree size by up to 70%. Most of the changes to reduce Jest’s default setup will be small breaking changes and we want to bring the community with us as much as possible. Therefore we will make the following changes in Jest 27 and Jest 28 using a <a href="https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model" target="_blank" rel="noopener noreferrer" class="">“Tick-Tock" release process</a>:</p>
<ul>
<li class="">Jest 27 will ship with a new test runner "<code>jest-circus</code>" and the Node.js environment by default. <code>jest-jasmine2</code> and <code>jest-environment-jsdom</code> will still be bundled so users can keep using them by changing one-line each in the configuration.</li>
<li class="">Jest 28 will remove <code>jest-jasmine2</code> and <code>jest-environment-jsdom</code> from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them.</li>
</ul>
<p>Upon upgrading to these major releases, Jest will guide you through the necessary changes. If you’d like to get ahead and migrate to the new defaults now, and your project does not require a DOM environment, you can upgrade to Jest 26 and add the following configuration options:</p>
<div class="language-json codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-json codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token property" style="color:#82772c">"jest"</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#82772c">"testEnvironment"</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token string" style="color:#c21325">"node"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token property" style="color:#82772c">"testRunner"</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token string" style="color:#c21325">"jest-circus/runner"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></span></code></pre></div></div>
<p>Jest will continue to ship with <code>babel-jest</code> enabled by default. It currently powers a few Jest features beyond compiling modern JavaScript syntax to something understood by current versions of Node.js and browsers: It also powers Jest's code coverage and mocking of ES modules. Jest currently ships with experimental support for <a class="" href="https://jestjs.io/blog/2020/01/21/jest-25#v8-code-coverage">V8 coverage</a> and native support for ES Modules (more on that below!). It is not possible to mock static ES Modules per the specification without transforming the code first, so we will be encouraging patterns that work without the transformation we use Babel for today. Once V8 coverage and native ESM support stabilizes in Jest, we will also be able remove <code>babel-jest</code> as a default but we will keep maintaining it.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="new-fake-timers">New fake timers<a href="https://jestjs.io/blog/2020/05/05/jest-26#new-fake-timers" class="hash-link" aria-label="Direct link to New fake timers" title="Direct link to New fake timers" translate="no">​</a></h2>
<p>With Jest 26 we are shipping a new implementation of fake timers based on <code>@sinonjs/fake-timers</code>. We've wanted to do this for years and are happy this has finally progressed far enough to support all of Jest's existing fake timer use cases.</p>
<p>The new implementation comes with extra features such as mocking <code>Date</code>, <code>queueMicrotask</code> and more, see <a href="https://github.com/sinonjs/fake-timers/blob/master/README.md" target="_blank" rel="noopener noreferrer" class="">this README</a>. It works transparently using the existing timer APIs like <code>jest.runAllTimers()</code> – check out the documentation <a class="" href="https://jestjs.io/docs/timer-mocks">on our website</a>.</p>
<p>We are confident this implementation is ready for prime time, however we don't want to force people to rewrite their tests if they depend on subtle differences between the old and new implementation. In Jest 26, this new implementation will remain <em>opt-in</em> and can be activated by calling <code>jest.useFakeTimers('modern')</code> or by passing <code>modern</code> to the <code>timers</code> option in your config if you opted all tests into fake timers previously.</p>
<p>In Jest 27 we will swap the default to the new "modern" implementation but we will keep supporting and maintaining the legacy implementation which can be used by calling <code>jest.useFakeTimers('legacy')</code>. If you are unsure whether you'll be able to upgrade all your tests by the time Jest 27 rolls out, you can add this to your tests now to keep the old behavior.</p>
<p>We'd like to thank <a href="https://github.com/fatso83" target="_blank" rel="noopener noreferrer" class="">Carl-Erik Kopseng</a>, <a href="https://github.com/benjamingr" target="_blank" rel="noopener noreferrer" class="">Benjamin Gruenbaum</a> and other maintainers of <code>@sinonjs/fake-timers</code> for their help and patience when working with us to make this happen! <em>Exciting</em>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="a-new-way-to-consume-jest---jestglobals">A new way to consume Jest - <code>@jest/globals</code><a href="https://jestjs.io/blog/2020/05/05/jest-26#a-new-way-to-consume-jest---jestglobals" class="hash-link" aria-label="Direct link to a-new-way-to-consume-jest---jestglobals" title="Direct link to a-new-way-to-consume-jest---jestglobals" translate="no">​</a></h2>
<p>Jest has relied on globals popularized by the Jasmine testing framework and others such as <code>describe</code>, <code>it</code>, <code>test</code> and <code>expect</code>. While this is a widely used pattern, many people have expressed their preference for importing testing related functions instead. To support this use case, we added a new package <code>@jest/globals</code> that can be used to import testing functions: <code>import {expect, jest, test} from '@jest/globals';</code>.</p>
<p>Caveats:</p>
<ul>
<li class="">Currently the globals still exist in the environment but we will introduce a mode to disable globals in the future. Similarly, you cannot use <code>const jest = require('@jest/globals')</code> as you'll get declaration errors because the <code>jest</code> variable is still a global for now.</li>
<li class="">There is currently no way to add custom matchers to the TypeScript definitions when using globals like this.</li>
<li class="">While this allows running tests without globals, it does not allow running tests without Jest's test runner at this time.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="native-esm-support">Native ESM support<a href="https://jestjs.io/blog/2020/05/05/jest-26#native-esm-support" class="hash-link" aria-label="Direct link to Native ESM support" title="Direct link to Native ESM support" translate="no">​</a></h2>
<p>As mentioned in the <a class="" href="https://jestjs.io/blog/2020/01/21/jest-25#ecmascript-modules-support">Jest 25 blog post</a> we have been working on native support for ECMAScript Modules. It is not stable yet but it is ready to be tested. We'd love to hear your feedback and bug reports! For an overview of the current state you can check out <a href="https://github.com/jestjs/jest/issues/9430" target="_blank" rel="noopener noreferrer" class="">this issue</a>, or browse all issues with that label <a href="https://github.com/jestjs/jest/labels/ES%20Modules" target="_blank" rel="noopener noreferrer" class="">ES Modules</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="other-breaking-changes-in-jest-26">Other Breaking Changes in Jest 26<a href="https://jestjs.io/blog/2020/05/05/jest-26#other-breaking-changes-in-jest-26" class="hash-link" aria-label="Direct link to Other Breaking Changes in Jest 26" title="Direct link to Other Breaking Changes in Jest 26" translate="no">​</a></h2>
<ul>
<li class="">Dropped support for Node 8 (<a href="https://github.com/jestjs/jest/pull/9423" target="_blank" rel="noopener noreferrer" class="">#9423</a>)</li>
<li class=""><code>[jest-environment-jsdom]</code> Upgrade <code>jsdom</code> to v16 (<a href="https://github.com/jestjs/jest/pull/9606" target="_blank" rel="noopener noreferrer" class="">#9606</a>)</li>
<li class=""><code>[jest-runtime]</code> Remove long-deprecated <code>require.requireActual</code> and <code>require.requireMock</code> methods (<a href="https://github.com/jestjs/jest/pull/9854" target="_blank" rel="noopener noreferrer" class="">#9854</a>)</li>
<li class=""><code>[jest-haste-map]</code> Removed <code>providesModuleNodeModules</code> (<a href="https://github.com/jestjs/jest/pull/8535" target="_blank" rel="noopener noreferrer" class="">#8535</a>)</li>
<li class=""><code>[jest-circus]</code> Fail tests if a test takes a done callback and have return values (<a href="https://github.com/jestjs/jest/pull/9129" target="_blank" rel="noopener noreferrer" class="">#9129</a>)</li>
<li class=""><code>[jest-circus]</code> Throw a proper error if a test / hooks is defined asynchronously (<a href="https://github.com/jestjs/jest/pull/8096" target="_blank" rel="noopener noreferrer" class="">#8096</a>)</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="stay-safe">Stay Safe<a href="https://jestjs.io/blog/2020/05/05/jest-26#stay-safe" class="hash-link" aria-label="Direct link to Stay Safe" title="Direct link to Stay Safe" translate="no">​</a></h2>
<p>We are all currently experiencing an unprecedented time of uncertainty. If you are struggling financially, we would like to use <a href="https://opencollective.com/jest" target="_blank" rel="noopener noreferrer" class="">Jest’s Open Collective fund</a> to help new and existing contributors. We place <a href="https://github.com/jestjs/jest/issues?q=is%3Aissue+is%3Aopen+bounty+label%3A%22Has+Bounty%22" target="_blank" rel="noopener noreferrer" class="">bounties on some issues</a> and are open to offering a bounty on any of our current open issues - you can mention that an issue should have a bounty in the issue or contact <a href="https://twitter.com/cpojer" target="_blank" rel="noopener noreferrer" class="">@cpojer via private message on Twitter</a>.</p>
<p>Please stay safe.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 25: 🚀 Laying foundations for the future]]></title>
            <link>https://jestjs.io/blog/2020/01/21/jest-25</link>
            <guid>https://jestjs.io/blog/2020/01/21/jest-25</guid>
            <pubDate>Tue, 21 Jan 2020 00:00:00 GMT</pubDate>
            <description><![CDATA[Jest 25 is laying the groundwork for many major changes in the future. As such, we kept breaking changes to a minimum, but internal architecture changes may require attention during the upgrade. The main changes are an upgrade of JSDOM from v11 to v15, 10-15% faster test runs, a new diff view for outdated snapshots and dropped Node 6 support.]]></description>
            <content:encoded><![CDATA[<p>Jest 25 is laying the groundwork for many major changes in the future. As such, we kept breaking changes to a minimum, but internal architecture changes may require attention during the upgrade. The main changes are an upgrade of JSDOM from v11 to v15, 10-15% faster test runs, a new diff view for outdated snapshots and dropped Node 6 support.</p>
<p>There has been more than 200 commits since Jest 24.9 by more than 80 different contributors, so as always, take a look at the <a href="https://github.com/jestjs/jest/blob/main/CHANGELOG.md" target="_blank" rel="noopener noreferrer" class="">changelog</a> for a full list of changes.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="bye-node-6">Bye Node 6<a href="https://jestjs.io/blog/2020/01/21/jest-25#bye-node-6" class="hash-link" aria-label="Direct link to Bye Node 6" title="Direct link to Bye Node 6" translate="no">​</a></h2>
<p>Node 6 has been EOL since April 30th 2019, and Jest 25 leaves it behind. Dropping Node 6 means we can upgrade our dependencies, the main one being JSDOM, which has been upgraded to version 15. Upgrading also means we no longer have to transpile <code>async-await</code> syntax, which results in both faster code execution and less memory consumption. As a bonus, Jest’s transpiled code should be easier to debug if anyone finds themselves tumbling down that particular rabbit hole.</p>
<p>Even though Node 8 has also entered EOL, Jest 25 will keep support for it to make the upgrade as easy as possible for those of us who still support Node 8. It does come with some tradeoffs though, such as JSDOM v16 having been released without Node 8 support, so you'll need to use <a href="https://www.npmjs.com/package/jest-environment-jsdom-sixteen" target="_blank" rel="noopener noreferrer" class=""><code>jest-environment-jsdom-sixteen</code></a> if you want to use the latest version.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="performance-improvements">Performance improvements<a href="https://jestjs.io/blog/2020/01/21/jest-25#performance-improvements" class="hash-link" aria-label="Direct link to Performance improvements" title="Direct link to Performance improvements" translate="no">​</a></h2>
<p>We’ve gotten reports that Jest has slowed down over the last couple of releases. Jest 25 includes upgraded Micromatch, which brings huge gains in startup time, and some bug fixes and performance tweaks which brings Jest back to the speed it was at for Jest 23. For Jest itself, like mentioned at the beginning of this post, that means a 10-15% reduction of test runtime. We're always looking to improve here of course, so please check how it stacks up against earlier versions and create issues if we should be better!</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="v8-code-coverage">V8 Code Coverage<a href="https://jestjs.io/blog/2020/01/21/jest-25#v8-code-coverage" class="hash-link" aria-label="Direct link to V8 Code Coverage" title="Direct link to V8 Code Coverage" translate="no">​</a></h2>
<p>Jest’s current code coverage instrumentation is powered by <code>babel-plugin-istanbul</code> inserting code coverage collection code before creating reports. However, this is quite slow and memory-intensive, especially for large files and code bases. Luckily, V8 has built-in code coverage, which is becoming more and more usable in Node thanks to the hard work of <a href="https://github.com/bcoe" target="_blank" rel="noopener noreferrer" class="">Benjamin Coe</a> and others on the V8 and Node.js teams. Jest 25 comes with experimental support for this via a new <code>--coverage-provider</code> flag. Please see its <a class="" href="https://jestjs.io/docs/configuration#coverageprovider-string">documentation</a> for caveats and how to use it.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="thinking-fast-and-slow-when-tests-fail">Thinking fast and slow when tests fail<a href="https://jestjs.io/blog/2020/01/21/jest-25#thinking-fast-and-slow-when-tests-fail" class="hash-link" aria-label="Direct link to Thinking fast and slow when tests fail" title="Direct link to Thinking fast and slow when tests fail" translate="no">​</a></h2>
<p>Unnecessary effort to interpret the reports when tests fail hinders:</p>
<ul>
<li class="">“thinking fast” to recognize patterns from your past experience</li>
<li class="">“thinking slow” to analyze changes and decide whether they are expected progress or unexpected regressions</li>
</ul>
<p>Jest 25 completes the second half of an effort begun in Jest 24 to improve all matchers:</p>
<ul>
<li class="">correct description line, including <code>.rejects</code>, <code>.resolves</code>, and <code>.not</code> modifiers</li>
<li class="">concise labels and consistent alignment for expected and received values</li>
<li class="">inverse highlight of substring differences when expected and received are strings</li>
<li class="">counts of change lines in differences to know if they are only delete or insert</li>
</ul>
<p>Special thanks to Jest maintainer <a href="https://github.com/pedrottimark" target="_blank" rel="noopener noreferrer" class="">Mark Pedrotti</a> for driving this effort and his continued work towards making expectation errors as good as they can be.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="colors-of-differences-when-snapshot-tests-fail">Colors of differences when snapshot tests fail<a href="https://jestjs.io/blog/2020/01/21/jest-25#colors-of-differences-when-snapshot-tests-fail" class="hash-link" aria-label="Direct link to Colors of differences when snapshot tests fail" title="Direct link to Colors of differences when snapshot tests fail" translate="no">​</a></h2>
<p>The most obvious change to replace confusion with confidence is the colors of change lines in differences when snapshot tests fail:</p>
<ul>
<li class=""><code>- Snapshot</code> changes from green to <strong>magenta</strong></li>
<li class=""><code>+ Received</code> changes from red to <strong>teal</strong> foreground on cyan/aqua background</li>
</ul>
<p>Examples of snapshot test reports (before at left and after at right)</p>
<ol>
<li class="">Counts of changed lines confirm your first impression which way did the snapshot change (that is, deleted or inserted lines)</li>
</ol>
<p><img decoding="async" loading="lazy" alt="snapshot-insert-lines" src="https://jestjs.io/assets/images/25-snapshot-insert-lines-8168b88f07172d72e4d2cd0e05d200f1.png" width="1800" height="532" class="img_SS3x"></p>
<ol start="2">
<li class="">Background colors attract your eyes to compare adjacent changed lines</li>
</ol>
<p><img decoding="async" loading="lazy" alt="snapshot-change-lines" src="https://jestjs.io/assets/images/25-snapshot-change-lines-d42906add66e08bb7c0ffffbca9a44bc.png" width="1800" height="504" class="img_SS3x"></p>
<ol start="3">
<li class="">Background colors also help you see which <code>toThrow</code> tests require a decision whether or not to update the snapshot</li>
</ol>
<p><img decoding="async" loading="lazy" alt="snapshot-change-substrings" src="https://jestjs.io/assets/images/25-snapshot-change-substrings-0798d37f2f603ec43b57145cddc1247b.png" width="1800" height="168" class="img_SS3x"></p>
<p>Here are some reasons why we chose unique colors:</p>
<ul>
<li class="">The 95% of people who have full color vision can quickly recognize which reports are from snapshot tests versus all other matchers.</li>
<li class="">It solves the direct conflict between meaning of green/red in Jest tests versus red/green in code review.</li>
<li class="">Unlike a reversal to red/green which suggests that update is the default decision, it suggests that differences require more careful review for possible regression in local snapshot test failures than in code review (when problems have already been fixed).</li>
</ul>
<p>The difference in hue from magenta at 300° to teal/cyan/aqua at 180° gives better color vision accessibility and the light background tint for changed lines gives consistent contrast on light and dark themes.</p>
<p>If you maintain a command line tool, you might find inspiration to improve its accessibility in <a href="https://github.com/jestjs/jest/pull/9132" target="_blank" rel="noopener noreferrer" class="">#9132</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="ecmascript-modules-support">ECMAScript Modules support<a href="https://jestjs.io/blog/2020/01/21/jest-25#ecmascript-modules-support" class="hash-link" aria-label="Direct link to ECMAScript Modules support" title="Direct link to ECMAScript Modules support" translate="no">​</a></h2>
<p>Node 13 has unflagged ESM support, and we have started a tiny bit working towards native support in Jest. Jest 25 includes support for <code>jest.config.cjs</code> and <code>jest.config.mjs</code> configuration files, but tests themselves cannot yet be written using ESM without something like Babel or TypeScript transforming it into CJS.</p>
<p>The APIs Jest will use are still flagged and experimental, so don't expect support right away. These APIs are something the <a href="https://github.com/nodejs/modules" target="_blank" rel="noopener noreferrer" class="">Node.js Modules team</a> is actively working on, and we'll be keeping an eye on it moving forward and experiment with them so we can provide feedback. You can subscribe to <a href="https://github.com/jestjs/jest/issues/9430" target="_blank" rel="noopener noreferrer" class="">this issue</a> to get any updates about the implementation status in Jest.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="other-improvements-and-updates">Other improvements and updates<a href="https://jestjs.io/blog/2020/01/21/jest-25#other-improvements-and-updates" class="hash-link" aria-label="Direct link to Other improvements and updates" title="Direct link to Other improvements and updates" translate="no">​</a></h2>
<ul>
<li class="">Jest has passed <a href="https://github.com/jestjs/jest/graphs/contributors" target="_blank" rel="noopener noreferrer" class="">1000 unique contributors</a>. This is an incredible milestone! Thank you to everybody who helps us make testing as delightful as possible.</li>
<li class="">Thanks to community member <a href="https://github.com/JoshRosenstein" target="_blank" rel="noopener noreferrer" class="">Josh Rosenstein</a>, Jest now comes with support for <code>BigInt</code> in most matchers, such as <code>toBeGreaterThan</code>. Jest will also understand bigint literals out of the box.</li>
<li class="">Jest’s feature <code>--detect-leaks</code> has been broken for Node 12 and newer - this has been fixed in Jest 25.</li>
<li class="">As announced in the blog post for Jest 24, Jest’s code base has been rewritten in TypeScript - this work was completed in Jest 24.3. So if you use any of Jest’s individual parts, you should get great IDE integration. Looking forward, we really want to make Jest mocks play nicer with type systems, and we’d love the community’s help with this. Please chime in <a href="https://github.com/jestjs/jest/issues/7832" target="_blank" rel="noopener noreferrer" class="">here</a> with ideas and send PRs! We’ll also be investigating moving the typings for using Jest as a test runner from DefinitelyTyped into Jest itself.</li>
<li class="">The <code>jest-diff</code> package now exports functions like <code>diffLinesUnified</code> and <code>diffStringsUnified</code> which have configuration options, so other applications can format differences in a custom way. For more information and code examples, see its new <code>README.md</code> file in the Jest repository or on package repositories.</li>
<li class="">Thanks to community member <a href="https://github.com/WeiAnAn" target="_blank" rel="noopener noreferrer" class="">Wei An Yen</a>, Jest will no longer highlight passing asymmetric matchers in expectation errors. This has been a long-standing pain point with asymmetric matchers and we're very happy it's finally solved.</li>
<li class="">For the second year running, Jest won the Highest Satisfaction award from <a href="https://2019.stateofjs.com/awards/" target="_blank" rel="noopener noreferrer" class="">State of JS</a>. We are incredibly grateful for the support from the community, and hope we can build on this momentum to make 2020 even better!</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="plans-for-the-future">Plans for the future<a href="https://jestjs.io/blog/2020/01/21/jest-25#plans-for-the-future" class="hash-link" aria-label="Direct link to Plans for the future" title="Direct link to Plans for the future" translate="no">​</a></h2>
<ul>
<li class="">Jest’s configuration is vast and somewhat clunky - there is often <em>at least</em> two ways of doing the same thing, oftentimes even more. For Jest 26 we hope to condense the config down, and make it more predictable. See this <a href="https://github.com/jestjs/jest/issues/7185" target="_blank" rel="noopener noreferrer" class="">issue</a> for details.</li>
<li class="">We also hope to be able to provide a proper programmatic API for running Jest, to make integration into IDEs and other tooling easier. Please see <a href="https://github.com/jestjs/jest/issues/5048" target="_blank" rel="noopener noreferrer" class="">this</a> tracking issue.</li>
<li class="">There’s been an open PR for adding Lolex as an implementation of Jest’s fake timers since December 2017. While we’re not adding it to any public APIs in Jest 25, support for it is technically included and you we're looking into how to expose this so people can test and experiment with it. Using it means you can mock out <code>Date</code> and other timer function Jest currently doesn’t touch. Note that this should be considered experimental, and a proper API support will come in a later release. Follow <a href="https://github.com/jestjs/jest/pull/7776" target="_blank" rel="noopener noreferrer" class="">this PR</a> for the latest updates on the status.</li>
</ul>
<p>Happy Jesting! 🃏</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 24: 💅 Refreshing, Polished, TypeScript-friendly]]></title>
            <link>https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly</link>
            <guid>https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly</guid>
            <pubDate>Fri, 25 Jan 2019 00:00:00 GMT</pubDate>
            <description><![CDATA[Today we are happy to announce the next major release of Jest - version 24! It's been 4 months since the last minor release, and 8 months since Jest 23, so this upgrade is a big one, with something for everyone! Highlights include built-in support for TypeScript by upgrading the Jest internals to Babel 7, fixing some long-standing issues with missing console output and performance issues when computing large diffs, and a brand new sparkling website. ✨]]></description>
            <content:encoded><![CDATA[<p>Today we are happy to announce the next major release of Jest - version 24! It's been 4 months since the last minor release, and 8 months since Jest 23, so this upgrade is a big one, with something for everyone! Highlights include built-in support for TypeScript by upgrading the Jest internals to Babel 7, fixing some long-standing issues with missing console output and performance issues when computing large diffs, and a brand new sparkling website. ✨</p>
<p>For a full list of all changes see the <a href="https://github.com/jestjs/jest/blob/main/CHANGELOG.md" target="_blank" rel="noopener noreferrer" class="">changelog</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="new-website">New Website<a href="https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly#new-website" class="hash-link" aria-label="Direct link to New Website" title="Direct link to New Website" translate="no">​</a></h2>
<p><a href="https://twitter.com/orta" target="_blank" rel="noopener noreferrer" class="">@orta</a> has provided a beautiful redesign of Jest's website, which has been implemented by community members <a href="https://twitter.com/montogeek" target="_blank" rel="noopener noreferrer" class="">@montogeek</a> and <a href="https://github.com/brainkim" target="_blank" rel="noopener noreferrer" class="">@brainkim</a>.</p>
<p>The aim of the redesign was to highlight more of what makes Jest awesome, and to decouple the idea that Jest is primarily a tool for testing React apps - you can use Jest with all sorts of projects and we want to make that obvious. You can read more about the ideas behind the redesign in <a href="https://github.com/jestjs/jest/issues/7265" target="_blank" rel="noopener noreferrer" class="">this issue</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="typescript-support">TypeScript support<a href="https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly#typescript-support" class="hash-link" aria-label="Direct link to TypeScript support" title="Direct link to TypeScript support" translate="no">​</a></h2>
<p>We've upgraded to Babel 7 internally for Jest 24, which comes with support for TypeScript projects. That means Jest can support transpiling TypeScript out of the box, as long as you configure Babel to use it with <code>@babel/preset-typescript</code>. One caveat to the default TypeScript support, similar to Flow, is that Babel will only strip out the type annotations to make your code valid JavaScript. It will <em>not</em> typecheck your code.</p>
<p>While Jest has supported Babel 7 since version 22 released in December 2017, it required usage of a bridge module in order to fit in with Jest's support of Babel 6. In Jest 24 we have migrated entirely over to Babel 7, with great help from community member <a href="https://github.com/milesj" target="_blank" rel="noopener noreferrer" class="">@milesj</a>. This means that setup is now easier and we can take advantage of other Babel 7 features, such as config loading and automatic <code>modules</code> transpilation. Make sure to remove the <code>babel-core@^7.0.0-bridge.0</code> as it's not needed now.</p>
<p>If you want to run typechecks while you test, you should use <a href="https://github.com/kulshekhar/ts-jest" target="_blank" rel="noopener noreferrer" class=""><code>ts-jest</code></a>. You will need to configure the transformer, as Jest by default applies Babel to <code>.ts</code> (and <code>.tsx</code>) files. Alternatively, you can run <code>tsc</code> or even use a Jest runner to simultaneously transpile your TypeScript whilst running your tests! See <a href="https://github.com/azz/jest-runner-tsc" target="_blank" rel="noopener noreferrer" class=""><code>jest-runner-tsc</code></a> for more information.</p>
<p>See <a class="" href="https://jestjs.io/docs/getting-started#using-typescript">the docs</a> for more details.</p>
<div class="theme-admonition theme-admonition-tip admonition_WCGJ alert alert--success"><div class="admonitionHeading_GCBg"><span class="admonitionIcon_L39b"><svg viewBox="0 0 12 16"><path fill-rule="evenodd" d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"></path></svg></span>tip</div><div class="admonitionContent_pbrs"><p>If you for whatever reason cannot upgrade to Babel 7, you can still use Jest 24 with <code>babel@6</code> as long as you keep <code>babel-jest</code> at version 23.</p></div></div>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="testtodo"><code>test.todo</code><a href="https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly#testtodo" class="hash-link" aria-label="Direct link to testtodo" title="Direct link to testtodo" translate="no">​</a></h2>
<p>Jest 23 had a change that made tests missing an implementation throw instead of being skipped. This change was made due to feedback that accidentally skipped tests were hard to discover and hard to track down. However, this change broke the workflow for quite a few developers who used the feature to sketch out which tests to write.</p>
<p>In Jest 24, we are addressing this issue by adding an explicit <code>test.todo</code> (inspired by the excellent AVA), which will be printed separately in the test summary. It allows you to quickly sketch out which tests you want to write and in the future, an <a href="https://eslint.org/" target="_blank" rel="noopener noreferrer" class="">ESLint</a> rule might even be able to warn you that you have forgotten to write out some tests.</p>
<div class="language-js codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-js codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token plain">test</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">todo</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'invalid input should throw'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">test</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">todo</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'missing options should be normalized'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p><img decoding="async" loading="lazy" alt="test.todo" src="https://jestjs.io/assets/images/24-todo-c06adf4108c116aa230143cb8a147ae3.png" width="2324" height="1422" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="improved-assertion-messages">Improved Assertion Messages<a href="https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly#improved-assertion-messages" class="hash-link" aria-label="Direct link to Improved Assertion Messages" title="Direct link to Improved Assertion Messages" translate="no">​</a></h2>
<p>When tests fail, you need to make confident and correct decisions which changes are expected progress and which changes are unexpected regressions. It is especially important not to miss a few regressions hidden among much progress. Jest 24 makes reports when assertions fail more clear and concise for several matchers. Because the effort will continue in Jest 25, you might notice some temporary inconsistencies. If your tests never fail, then you won't get to see them - for the rest of us, it'll be easier to debug why something isn't working as expected. Thanks for the hard work by <a href="https://twitter.com/ittordepam" target="_blank" rel="noopener noreferrer" class="">@ittordepam</a> and other contributors from the community.</p>
<p>You can see these changes across all these PRs: <a href="https://github.com/jestjs/jest/pull/7621" target="_blank" rel="noopener noreferrer" class="">7621</a>, <a href="https://github.com/jestjs/jest/pull/7557" target="_blank" rel="noopener noreferrer" class="">7557</a>, <a href="https://github.com/jestjs/jest/pull/7448" target="_blank" rel="noopener noreferrer" class="">7448</a>, <a href="https://github.com/jestjs/jest/pull/7325" target="_blank" rel="noopener noreferrer" class="">7325</a>, <a href="https://github.com/jestjs/jest/pull/7241" target="_blank" rel="noopener noreferrer" class="">7241</a>, <a href="https://github.com/jestjs/jest/pull/7152" target="_blank" rel="noopener noreferrer" class="">7152</a>, <a href="https://github.com/jestjs/jest/pull/7125" target="_blank" rel="noopener noreferrer" class="">7125</a>, <a href="https://github.com/jestjs/jest/pull/7107" target="_blank" rel="noopener noreferrer" class="">7107</a>, <a href="https://github.com/jestjs/jest/pull/6961" target="_blank" rel="noopener noreferrer" class="">6961</a>.</p>
<p>Examples:</p>
<p>Failing assertion</p>
<p><img decoding="async" loading="lazy" alt="failing assertion" src="https://jestjs.io/assets/images/24-assertion-error-424a6b04bd7012af7d80419981d553d4.png" width="1844" height="1246" class="img_SS3x"></p>
<p>Type mismatch</p>
<p><img decoding="async" loading="lazy" alt="different types" src="https://jestjs.io/assets/images/24-different-types-6cdc48fef8c458eeb7b804ba60f4661e.png" width="1844" height="1246" class="img_SS3x"></p>
<p>Mock function not called</p>
<p><img decoding="async" loading="lazy" alt="mock functions" src="https://jestjs.io/assets/images/24-mock-function-c93fb0afe32cea366976c870d89d9309.png" width="1844" height="1246" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="fixing-old-pain">Fixing old pain<a href="https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly#fixing-old-pain" class="hash-link" aria-label="Direct link to Fixing old pain" title="Direct link to Fixing old pain" translate="no">​</a></h2>
<p>We've fixed a couple of really old issues in this release.</p>
<p>The first one we'd like to highlight is <code>console.log</code> statements going missing. Jest intercepts and collects all logs in order to give you a stack trace to them, as well as provide them to reporters so you can handle them however you want. However, this has led to an issue where they have simply been missing in certain edge cases. Luckily for Jest 24, <a href="https://twitter.com/spion" target="_blank" rel="noopener noreferrer" class="">@spion</a> has <a href="https://github.com/jestjs/jest/pull/6871" target="_blank" rel="noopener noreferrer" class="">stepped up</a> and fixed this issue. Thank you very much!</p>
<p>The second one is an issue where Jest runs out of memory if the difference in serialization of expected and received value has a huge number of insertion changes (either unexpected because of mistake in test or defect in serializer or expected because of temporary failures during test-driven development). <a href="https://twitter.com/ittordepam" target="_blank" rel="noopener noreferrer" class="">@ittordepam</a> has <a href="https://github.com/jestjs/jest/pull/6961" target="_blank" rel="noopener noreferrer" class="">replaced</a> the previous diffing algorithm with <code>diff-sequences</code> package, which should fix this issue because it uses the theoretical minimum amount of memory. It opens up possibility for word-diffs in the future, similar to what <a href="https://git-scm.com/docs/git-diff#git-diff---word-diffltmodegt" target="_blank" rel="noopener noreferrer" class="">git provides</a>. Please see <a href="https://github.com/jestjs/jest/pull/4619" target="_blank" rel="noopener noreferrer" class="">this PR</a> and don't hesitate to reach out if you want to help make that happen!</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="other-highlights">Other highlights<a href="https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly#other-highlights" class="hash-link" aria-label="Direct link to Other highlights" title="Direct link to Other highlights" translate="no">​</a></h2>
<ul>
<li class="">We have some improvements for <code>globalSetup</code> and <code>globalTeardown</code> as well - code transformation will be applied to them similar to <code>setupFiles</code> and they are now supported as part of <code>projects</code>.</li>
<li class="">You can <a href="https://github.com/jestjs/jest/pull/6143" target="_blank" rel="noopener noreferrer" class="">configure</a> Jest's snapshot location, this is mainly useful if you are building tools which use Jest in a larger build process.</li>
<li class="">A quirk of Jest's CLI has been that while some flags and options have been camel cased (such as <code>runInBand</code>), others have not been (such as <code>no-cache</code>). In Jest 24, both are recognized, meaning you can write your CLI arguments however you want.</li>
<li class="">We've renamed <code>setupTestFrameworkScriptFile</code> to <code>setupFilesAfterEnv</code>, and made it into an array. We hope this will make it more obvious what the options is for. We have plans to further overhaul the configuration in the next major, see the paragraph in the section below.</li>
<li class="">To reduce the amount of magic Jest performs to “just work™”, in this release we decided to drop automatic injection of <code>regenerator-runtime</code>, which is sometimes used in compiled async code. Including <code>regenerator-runtime</code> is not always necessary and we believe it's the user's responsibility to include it if it's needed. If you use <code>@babel/preset-env</code> with <code>targets</code> set to a modern Node version (e.g. Node 6+) you will not need to include it. Please see our <a class="" href="https://jestjs.io/docs/getting-started#using-babel">Using Babel docs</a> for more information.</li>
<li class="">Node.js 10 came with an experimental module <a href="https://nodejs.org/api/worker_threads.html" target="_blank" rel="noopener noreferrer" class="">called <code>worker_threads</code></a>, which is similar to Worker threads in the browser. <code>jest-worker</code>, part of the <a class="" href="https://jestjs.io/docs/jest-platform">Jest platform</a>, will be able to use <code>worker_threads</code> if available instead of <code>child_process</code>, which makes it even faster! <a href="https://github.com/jestjs/jest/pull/6676" target="_blank" rel="noopener noreferrer" class="">Benchmarks</a> show a 50% improvement. Due to its experimental nature, it's not enabled when using Jest as a test runner, but you can use it in your own projects today! We plan to enable it by default when it's promoted from experimental status in Node.js.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="breaking-changes">Breaking Changes<a href="https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly#breaking-changes" class="hash-link" aria-label="Direct link to Breaking Changes" title="Direct link to Breaking Changes" translate="no">​</a></h2>
<p>While all breaking changes are listed in the <a href="https://github.com/jestjs/jest/blob/main/CHANGELOG.md" target="_blank" rel="noopener noreferrer" class="">changelog</a>, there's a few of them that are worth highlighting:</p>
<ul>
<li class="">We've upgraded to Micromatch 3. While this might not affect every user, it is stricter in its parsing of globs than version 2, which is used in Jest 23. Please read through <a href="https://github.com/micromatch/micromatch/issues/133#issuecomment-404211484" target="_blank" rel="noopener noreferrer" class="">this</a> and linked issues for examples of invalid globs in case you have problems.</li>
<li class="">We've removed code remnants that was needed for Node 4. It was previously technically possible to run Jest 23 on Node 4 - that is no longer possible without polyfilling and transpiling.</li>
<li class="">Some changes to serialization of mock functions in snapshots - make sure to double check your updated snapshots after upgrading. Related <a href="https://github.com/jestjs/jest/pull/6381" target="_blank" rel="noopener noreferrer" class="">PR</a>.</li>
<li class="">Jest no longer automatically injects <code>regenerator-runtime</code> - if you get errors concerning it, make sure to configure Babel to properly transpile <code>async</code> functions, using e.g. <code>@babel/preset-env</code>. Related <a href="https://github.com/jestjs/jest/pull/7595" target="_blank" rel="noopener noreferrer" class="">PR</a>.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="the-future">The future<a href="https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly#the-future" class="hash-link" aria-label="Direct link to The future" title="Direct link to The future" translate="no">​</a></h2>
<p>We are incredibly humbled by the results in <a href="https://2018.stateofjs.com/awards/" target="_blank" rel="noopener noreferrer" class="">State Of JS 2018</a>, where Jest won the “Highest Satisfaction” award. Another huge thing to happen in 2018 was in October, when Jest passed 2 million weekly downloads for the first time. Thank you.</p>
<p>We are very thankful for the trust in us shown by the community, and hope to build on it in the future. We will ensure Jest 24 and future releases will continue to build upon this incredible foundation, and continue to be an integral part of JavaScript developers' toolkits.</p>
<p>This has been the first release where we have explored the idea of using our Open Collective funding to create bug bounties. This worked well in getting non-core developers involved in the implementation of the new landing page, and we're optimistic for a long running bug where Jest globals <a href="https://github.com/jestjs/jest/issues/2549" target="_blank" rel="noopener noreferrer" class="">are mismatched</a> from Node globals. We'd like to do more, if you have a pet bug that's a good candidate for our bounty program, please let us know. In the meantime, you can find all the tickets with a bounty via <a href="https://github.com/jestjs/jest/labels/Has%20Bounty" target="_blank" rel="noopener noreferrer" class="">the issue label</a>.</p>
<p>We have already started to make plans for the next release of Jest 25, with the biggest planned feature being an overhaul of our configuration, which is pretty hard to grok, mainly because of overlapping option and mixing globs and regular expressions. Feedback on how you want Jest's configuration to look is very much welcome, and can be submitted in <a href="https://github.com/jestjs/jest/issues/7185" target="_blank" rel="noopener noreferrer" class="">this issue</a>.</p>
<p>You might also have heard that we are planning to migrate the code base from Flow to TypeScript. We are hopeful that this migration will enable even more contributors to jump in and help make 2019 even better for JavaScript testing. 🚀 The plan is to land this in a minor release in the not too distant future. Feedback on this choice can be added to <a href="https://github.com/jestjs/jest/pull/7554" target="_blank" rel="noopener noreferrer" class="">the RFC</a>.</p>
<p>Lastly, if you've ever wondered about how Jest is built, <a href="https://twitter.com/cpojer" target="_blank" rel="noopener noreferrer" class="">@cpojer</a> has recorded a video with an architectural overview of how Jest is put together under the hood. Feel free to reach out if you have any further questions about it. The video is available on our <a class="" href="https://jestjs.io/docs/architecture">website</a>.</p>
<p>Happy Jesting! 🃏</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supporting Jest Open Source]]></title>
            <link>https://jestjs.io/blog/2018/06/27/supporting-jest-open-source</link>
            <guid>https://jestjs.io/blog/2018/06/27/supporting-jest-open-source</guid>
            <pubDate>Wed, 27 Jun 2018 00:00:00 GMT</pubDate>
            <description><![CDATA[Jest is maintained by a community of open source contributors and Facebook employees.]]></description>
            <content:encoded><![CDATA[<p>Jest is maintained by a community of open source contributors and Facebook employees.</p>
<p>Our open source contributors work on behalf of the community to create new features, fix bugs, and maintain the issue backlog. Facebook employees do the same, focused on the problems specific to Facebook's scale, and run all proposed releases on Facebook's enormous test suite before publishing.</p>
<p>All of us do our part to make testing delightful.</p>
<p>At the Jest Summit we announced the Jest Open Collective. This is our way to help support the efforts of the open source Jest community. <strong>To be absolutely clear: Facebook employees cannot benefit from the Jest Open Collective.</strong> The collective's sole purpose is to support the open source side of the Jest community.</p>
<p>In this post we'll outline what the Jest Open Collective is, the structure, and the goals we have.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="the-jest-open-collective">The Jest Open Collective<a href="https://jestjs.io/blog/2018/06/27/supporting-jest-open-source#the-jest-open-collective" class="hash-link" aria-label="Direct link to The Jest Open Collective" title="Direct link to The Jest Open Collective" translate="no">​</a></h2>
<p><img decoding="async" loading="lazy" alt="Banner image for Jest Open Collective" src="https://jestjs.io/assets/images/collective-fcec198ec20af7c295dbdab660e972b5.png" width="1869" height="800" class="img_SS3x"></p>
<p>Open Collective is a platform to manage groups of people transparently. Jest joins projects like <a href="https://opencollective.com/webpack" target="_blank" rel="noopener noreferrer" class="">webpack</a>, <a href="https://opencollective.com/babel" target="_blank" rel="noopener noreferrer" class="">Babel</a>, <a href="https://opencollective.com/mochajs" target="_blank" rel="noopener noreferrer" class="">Mocha</a>, <a href="https://opencollective.com/preact" target="_blank" rel="noopener noreferrer" class="">Preact</a>, <a href="https://opencollective.com/vuejs" target="_blank" rel="noopener noreferrer" class="">Vue</a>, and many more in supporting the open source community through the Open Collective platform.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="what-is-the-jest-open-collective">What is the Jest Open Collective<a href="https://jestjs.io/blog/2018/06/27/supporting-jest-open-source#what-is-the-jest-open-collective" class="hash-link" aria-label="Direct link to What is the Jest Open Collective" title="Direct link to What is the Jest Open Collective" translate="no">​</a></h3>
<p>The Jest Open Collective is a group of open source contributors who operate in full transparency to:</p>
<ul>
<li class="">Receive funds from backers and sponsors</li>
<li class="">Approve expenses submitted by the community</li>
<li class="">Give everyone visibility on the budget</li>
</ul>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="what-is-the-structure-of-the-collective">What is the structure of the collective<a href="https://jestjs.io/blog/2018/06/27/supporting-jest-open-source#what-is-the-structure-of-the-collective" class="hash-link" aria-label="Direct link to What is the structure of the collective" title="Direct link to What is the structure of the collective" translate="no">​</a></h3>
<p>The Jest Open Collective is currently managed by three non-Facebook core contributors from the open source community:</p>
<ul>
<li class=""><a href="https://twitter.com/thymikee" target="_blank" rel="noopener noreferrer" class="">Michal Pierzchala</a></li>
<li class=""><a href="https://github.com/simenb" target="_blank" rel="noopener noreferrer" class="">Simen Bekkhus</a></li>
<li class=""><a href="https://twitter.com/rickhanlonii" target="_blank" rel="noopener noreferrer" class="">Rick Hanlon</a></li>
</ul>
<p>Michal has been an active Jest contributor since September 2016, Simen joined the core team in June 2017, and Rick joined in January. They're responsible for setting the budget, approving expenses, and managing admins of the collective. We have elected to keep <a href="https://twitter.com/cpojer" target="_blank" rel="noopener noreferrer" class="">Christoph Nakazawa</a> as an adviser.</p>
<p>There are two levels of support for the collective: Backer and Sponsor.</p>
<h4 class="anchor anchorTargetStickyNavbar_tleR" id="backers">Backers<a href="https://jestjs.io/blog/2018/06/27/supporting-jest-open-source#backers" class="hash-link" aria-label="Direct link to Backers" title="Direct link to Backers" translate="no">​</a></h4>
<p>Backers of the collective are individuals contributing at least $2/month. We'll include a list of backers on the Jest homepage, README on github/yarn/npm, and Contributors page.</p>
<h4 class="anchor anchorTargetStickyNavbar_tleR" id="sponsors">Sponsors<a href="https://jestjs.io/blog/2018/06/27/supporting-jest-open-source#sponsors" class="hash-link" aria-label="Direct link to Sponsors" title="Direct link to Sponsors" translate="no">​</a></h4>
<p>Sponsors of the collective are individuals and organizations contributing at least $100/month. We'll place sponsor logos with a link to their site on the Jest homepage, README on github/yarn/npm, and Contributors page.</p>
<h3 class="anchor anchorTargetStickyNavbar_tleR" id="what-is-the-goal-of-the-collective">What is the goal of the collective<a href="https://jestjs.io/blog/2018/06/27/supporting-jest-open-source#what-is-the-goal-of-the-collective" class="hash-link" aria-label="Direct link to What is the goal of the collective" title="Direct link to What is the goal of the collective" translate="no">​</a></h3>
<p>The goal of the collective is to support the work of open source contributors to Jest in order to make testing delightful.</p>
<p>To achieve that goal, we will use the funds to:</p>
<ul>
<li class="">Cover speaker travel expenses</li>
<li class="">Host events and meetups</li>
<li class="">Print and distribute swag</li>
<li class="">Develop and fund a bug bounty program (TBD)</li>
</ul>
<p>This is just the beginning and we're committed to getting this right. If you have ideas on how else we can support the community, or feedback on the structure of the collective, please reach out to us on <a href="https://twitter.com/jestjs_" target="_blank" rel="noopener noreferrer" class="">twitter</a>!</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="thank-you">Thank You<a href="https://jestjs.io/blog/2018/06/27/supporting-jest-open-source#thank-you" class="hash-link" aria-label="Direct link to Thank You" title="Direct link to Thank You" translate="no">​</a></h2>
<p>Finally, thank you to everyone who contributes to the Jest community and open source in general. We are incredibly grateful that we get the opportunity to work on improving JavaScript testing together.</p>
<p>The Jest core team would also like to make a special thank you to Facebook Open Source for driving the creation of this collective.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 23: 🔥 Blazing Fast Delightful Testing]]></title>
            <link>https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing</link>
            <guid>https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing</guid>
            <pubDate>Tue, 29 May 2018 00:00:00 GMT</pubDate>
            <description><![CDATA[Today we are excited to announce Jest 23, our largest major release to date! Together with over 100 contributors, we've shipped a ton of features and bug fixes. Thank you to everyone in the community for helping make JavaScript Testing Delightful.]]></description>
            <content:encoded><![CDATA[<p>Today we are excited to announce Jest 23, our largest major release to date! Together with over 100 contributors, we've shipped a ton of features and bug fixes. Thank you to everyone in the community for helping make JavaScript Testing Delightful.</p>
<p>We would also like to welcome both <a href="https://babeljs.io/" target="_blank" rel="noopener noreferrer" class="">Babel</a> and <a href="https://webpack.js.org/" target="_blank" rel="noopener noreferrer" class="">webpack</a> to the Jest community! After converting from Mocha to Jest 23 Beta, webpack saw their total test suite time reduced 6x from over 13 minutes to 2 minutes 20 seconds. <a href="https://twitter.com/search?q=%23blazingmeansgood" target="_blank" rel="noopener noreferrer" class="">#blazingmeansgood</a></p>
<p>Here's are some of the Jest 23 highlights and breaking changes.</p>
<p>For a full list see the <a href="https://github.com/jestjs/jest/blob/main/CHANGELOG.md" target="_blank" rel="noopener noreferrer" class="">changelog</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="interactive-snapshot-mode">Interactive Snapshot Mode<a href="https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing#interactive-snapshot-mode" class="hash-link" aria-label="Direct link to Interactive Snapshot Mode" title="Direct link to Interactive Snapshot Mode" translate="no">​</a></h2>
<p>We've added a new default watch menu option we're calling Interactive Snapshot Mode. This new mode allows you to step through each failing snapshot in each failing suite to review your failed snapshots and choose to update or skip each individually.</p>
<p><img decoding="async" loading="lazy" alt="Interactive snapshot mode in action" src="https://jestjs.io/assets/images/23-interactive-3b2c2f9ec0fecc4effbc03fbc3ad1963.gif" width="1004" height="732" class="img_SS3x"></p>
<p>See the Interactive Snapshot Mode docs <a class="" href="https://jestjs.io/docs/snapshot-testing#interactive-snapshot-mode">here</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="snapshot-property-matchers">Snapshot Property Matchers<a href="https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing#snapshot-property-matchers" class="hash-link" aria-label="Direct link to Snapshot Property Matchers" title="Direct link to Snapshot Property Matchers" translate="no">​</a></h2>
<p>Often, objects you're snapshotting contain generated values like Dates and IDs. Jest now allows you to pass properties to the snapshot matcher which specify the structure of the data instead of the specific values. These property matchers are then verified before serializing the matcher type (instead of the value), giving you consistent snapshot results across test runs.</p>
<p><img decoding="async" loading="lazy" alt="Snapshot Property Matchers" src="https://jestjs.io/assets/images/23-snapshot-matchers-aa63fd590f453650a67eaa0d99f678e3.png" width="2236" height="1177" class="img_SS3x"></p>
<p>See the updated <code>toMatchSnapshot</code> <a class="" href="https://jestjs.io/docs/expect#tomatchsnapshotpropertymatchers-snapshotname">docs</a> or the Property Matcher <a class="" href="https://jestjs.io/docs/snapshot-testing#property-matchers">guide</a> for more information.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="custom-asynchronous-matchers">Custom Asynchronous matchers<a href="https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing#custom-asynchronous-matchers" class="hash-link" aria-label="Direct link to Custom Asynchronous matchers" title="Direct link to Custom Asynchronous matchers" translate="no">​</a></h2>
<p>We now support asynchronous matchers with <code>expect.extends</code>! Async matchers return a Promise so that you can <code>await</code> for the matcher to resolve. As an example:</p>
<p><img decoding="async" loading="lazy" alt="Custom asynchronous matchers in action" src="https://jestjs.io/assets/images/23-async-matchers-91183e14fbce836540d2079f145dbe97.png" width="2230" height="876" class="img_SS3x"></p>
<p>Docs available <a class="" href="https://jestjs.io/docs/expect#expectextendmatchers">here</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="custom-asymmetric-matchers">Custom Asymmetric Matchers<a href="https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing#custom-asymmetric-matchers" class="hash-link" aria-label="Direct link to Custom Asymmetric Matchers" title="Direct link to Custom Asymmetric Matchers" translate="no">​</a></h2>
<p>Asymmetric matchers are a great tool to use when you only care about asymmetric equality. For example, when the left side is expected to be an object with some subset of properties on the right, instead of an exact match. Jest provides a number of asymmetric matchers out of the box, and in this release we're introducing Custom Asymmetric Matchers.</p>
<p><img decoding="async" loading="lazy" alt="Custom asymmetric matchers in action" src="https://jestjs.io/assets/images/23-asymmetric-matchers-12a593708f9e4cec91225d63c49e959e.png" width="2230" height="1012" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="jest-each">Jest Each<a href="https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing#jest-each" class="hash-link" aria-label="Direct link to Jest Each" title="Direct link to Jest Each" translate="no">​</a></h2>
<p><a href="https://twitter.com/mattphillipsio" target="_blank" rel="noopener noreferrer" class="">@mattphillipsio</a> has donated the <code>jest-each</code> package to Jest Core (thanks Matt!). <code>jest-each</code> is a library inspired by <a href="https://yarnpkg.com/en/package/mocha-each" target="_blank" rel="noopener noreferrer" class=""><code>mocha-each</code></a> and <a href="http://spockframework.org/spock/docs/1.1/data_driven_testing.html#data-tables" target="_blank" rel="noopener noreferrer" class="">Spock Data Tables</a> which allows you to define a table of test cases, and then run a test for each row with the specified column values. We support both array types and template literals for all flavors of <code>describe</code> and <code>test</code>. Docs are available <a class="" href="https://jestjs.io/docs/api#testeachtable-name-fn">here</a>, and for those not on Jest 23 yet, we're still publishing <a href="https://yarnpkg.com/en/package/jest-each" target="_blank" rel="noopener noreferrer" class=""><code>jest-each</code></a> separately!</p>
<p><img decoding="async" loading="lazy" alt="jest-each in action" src="https://jestjs.io/assets/images/23-jest-each-3d938745102750ad491139ea700842ab.png" width="2230" height="1304" class="img_SS3x"></p>
<p>Huge shout out to Prettier for <a href="https://github.com/prettier/prettier/pull/4423" target="_blank" rel="noopener noreferrer" class="">fixing</a> the table formatting so quickly (<a href="https://prettier.io/blog/2018/05/23/1.13.0.html#format-new-describeeach-table-in-jest-23-4423-by-ikatyang" target="_blank" rel="noopener noreferrer" class="">see Prettier 1.13</a>)!</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="new-matchers">New Matchers<a href="https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing#new-matchers" class="hash-link" aria-label="Direct link to New Matchers" title="Direct link to New Matchers" translate="no">​</a></h2>
<p>We only add matchers to core if we believe they will be useful to a large amount of people in the Jest community, and leave the majority of matchers to the community (see <a href="https://yarnpkg.com/en/package/jest-extended" target="_blank" rel="noopener noreferrer" class="">jest-extended</a>). Some matchers make the cut into core, and Jest 23 adds:</p>
<ul>
<li class="">nthCalledWith</li>
<li class="">toReturn</li>
<li class="">toReturnTimes</li>
<li class="">toReturnWith</li>
<li class="">lastReturnedWith</li>
<li class="">nthReturnedWith</li>
<li class="">toStrictEqual</li>
</ul>
<p><img decoding="async" loading="lazy" alt="New matchers in action" src="https://jestjs.io/assets/images/23-new-matchers-8aaaad14f7dc524a46b99503b6ede43b.png" width="2230" height="1276" class="img_SS3x"></p>
<p>See the updated expect docs <a class="" href="https://jestjs.io/docs/expect">here</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="debug-hanging-tests">Debug Hanging Tests<a href="https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing#debug-hanging-tests" class="hash-link" aria-label="Direct link to Debug Hanging Tests" title="Direct link to Debug Hanging Tests" translate="no">​</a></h2>
<p>A common issue we see on the issue tracker relates to “Jest” hanging after a test run. This is usually due to app code leaving handles open, preventing Jest from exiting. In the past, users have resorted to <code>--forceExit</code> to fix (not recommended).</p>
<p>To help debug these issues, we're now detecting when Jest does not exit:</p>
<p><img decoding="async" loading="lazy" alt="Detecting hanging tests" src="https://jestjs.io/assets/images/23-hanging-before-867f8f3cfd6d67bb5ce37bf11f053749.png" width="2236" height="780" class="img_SS3x"></p>
<p>And we offer a new flag <code>--detectOpenHandles</code> to help find the open handles:</p>
<p><img decoding="async" loading="lazy" alt="Running detectOpenHandles" src="https://jestjs.io/assets/images/23-hanging-after-4f446e62ff117f6ae7f669d56057d206.png" width="2236" height="1106" class="img_SS3x"></p>
<p>See the updated CLI docs <a class="" href="https://jestjs.io/docs/cli#detectopenhandles">here</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="watch-mode-plugins">Watch Mode Plugins<a href="https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing#watch-mode-plugins" class="hash-link" aria-label="Direct link to Watch Mode Plugins" title="Direct link to Watch Mode Plugins" translate="no">​</a></h2>
<p>We have completely rewritten the watch mode system to allow adding custom plugins to watch mode. Watch Mode Plugins now make it possible to hook into Jest events and provide custom menu options in the Watch Mode Menu. All of the default Watch Mode prompts are implemented as plugins in this system, and the docs to create your own are available <a class="" href="https://jestjs.io/docs/watch-plugins">here</a>.</p>
<p>With this change, we're also now able to bring back typeahead support as a Watch Mode Plugin via <a href="https://yarnpkg.com/en/package/jest-watch-typeahead" target="_blank" rel="noopener noreferrer" class="">jest-watch-typeahead</a>!</p>
<p><img decoding="async" loading="lazy" alt="Typeahead plugin in action" src="https://jestjs.io/assets/images/23-typeahead-b16e5a1f51f3b3852df9fcc508c920d1.gif" width="1001" height="731" class="img_SS3x"></p>
<p>See <a href="https://github.com/jest-community/jest-watch-typeahead" target="_blank" rel="noopener noreferrer" class="">jest-watch-typeahead</a> for documentation and install instructions. Huge thank you to <a href="https://twitter.com/rogeliog" target="_blank" rel="noopener noreferrer" class="">@rogeliog</a> for the new watch mode plugin system and the jest-watch-typeahead plugin!</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="breaking-changes">Breaking Changes<a href="https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing#breaking-changes" class="hash-link" aria-label="Direct link to Breaking Changes" title="Direct link to Breaking Changes" translate="no">​</a></h2>
<p>As with every major release, we are making a few breaking changes to make larger changes in the future possible and to push the testing experience to a new level. Here's a list of the biggest changes you may see:</p>
<ul>
<li class=""><strong>Require test descriptions and functions</strong>: We're now failing tests that do not include both a function and a description.</li>
<li class=""><strong>Remove undefined props from React snapshots</strong>: Smaller snapshots and proper React behavior.</li>
<li class=""><strong>Remove deprecations</strong>: We removed mapCoverage since it's no longer needed. Additionally, we removed <code>jest.genMockFunction</code> and <code>jest.genMockFn</code> since these are the same as <code>jest.fn</code>.</li>
<li class=""><strong>Add snapshot names to failures</strong>: We added the snapshot name (if provided) to the snapshot failure message so it's easier to find the snapshot that's failing.</li>
<li class=""><strong>Replace mock timestamps</strong>: We replaced mock timestamps with invocationCallOrder since two or mocks may often have the same timestamp, making it impossible to test the call order.</li>
<li class=""><strong>Add results to mock snapshots</strong>: We added mock function call results to snapshots so that both the calls and the results of the invocation are tracked.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="other-improvements">Other Improvements<a href="https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing#other-improvements" class="hash-link" aria-label="Direct link to Other Improvements" title="Direct link to Other Improvements" translate="no">​</a></h2>
<ul>
<li class=""><strong>Watch mode coverage</strong>: Coverage is now limited to only the files tested in watch mode or when using <code>--onlyChanged</code> and <code>--findRelatedTests</code>.</li>
<li class=""><strong>Version documentation</strong>: We added docs for each minor release back to Jest 22, and have removed all of the “Requires Jest X.X+” from the docs.</li>
<li class=""><strong>Better snapshot summaries</strong>: We overhauled the Snapshot Summary output to make obsolete snapshots more informative.</li>
<li class=""><strong>Better stack traces</strong>: We added stack traces to asynchronous errors, timeout errors, expect.assertions, and thrown non-errors. We're also indicating the column in the code frame!</li>
<li class=""><strong>Better React 16 support</strong>: Adds snapshot support for <code>React.Fragment</code>, <code>React.forwardRef</code>, and <code>React.createContext</code>.</li>
<li class=""><strong>Track mock return and throw values</strong>: Adds <code>mock.results</code> that contains the return value or thrown value for each mock call.</li>
<li class=""><strong>Blazing 🔥</strong>: We've added a blazing badge to the README to indicate that Jest is blazing good.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="jest-summit">Jest Summit<a href="https://jestjs.io/blog/2018/05/29/jest-23-blazing-fast-delightful-testing#jest-summit" class="hash-link" aria-label="Direct link to Jest Summit" title="Direct link to Jest Summit" translate="no">​</a></h2>
<p>Last week, the Jest Core Team met for the Jest Summit at Facebook London where worked on and released Jest 23, announced the Jest Open Collective, and gave a number of talks:</p>
<ul>
<li class=""><strong>Christoph Nakazawa</strong> – <a href="https://www.youtube.com/watch?v=cAKYQpTC7MA" target="_blank" rel="noopener noreferrer" class="">Intro</a></li>
<li class=""><strong>Aaron Abramov</strong> – <a href="https://youtu.be/cAKYQpTC7MA?t=440" target="_blank" rel="noopener noreferrer" class="">Writing Meaningful Tests</a></li>
<li class=""><strong>Rick Hanlon II</strong> – <a href="https://youtu.be/cAKYQpTC7MA?t=1881" target="_blank" rel="noopener noreferrer" class="">Blazing Fast Snapshot Testing in Jest 23</a></li>
<li class=""><strong>Simen Bekkhus</strong> – <a href="https://youtu.be/cAKYQpTC7MA?t=2990" target="_blank" rel="noopener noreferrer" class="">Jest's Delightful Error Messages</a></li>
<li class=""><strong>Matt Phillips</strong> – <a href="https://youtu.be/cAKYQpTC7MA?t=3852" target="_blank" rel="noopener noreferrer" class="">Level up your Jest experience with community packages</a></li>
<li class=""><strong>Michele Bertoli</strong> – <a href="https://youtu.be/cAKYQpTC7MA?t=4582" target="_blank" rel="noopener noreferrer" class="">Snapshot all the things</a></li>
<li class=""><strong>Jordan Eldredge</strong> – <a href="https://youtu.be/cAKYQpTC7MA?t=5185" target="_blank" rel="noopener noreferrer" class="">Webamp: Learn by imitating</a></li>
</ul>
<p>Full talk is available <a href="https://www.youtube.com/watch?v=cAKYQpTC7MA" target="_blank" rel="noopener noreferrer" class="">here</a>.</p>
<p>The turnout was amazing, and we were able to meet a lot of the London-based community in person. Thank you to everyone who joined us and for your continued support! Stay tuned for our next post which will outline the Jest Open Collective and the plans we have for the future.</p>
<p><em>As always, this release couldn't have been possible without you, the JavaScript community. We are incredibly grateful that we get the opportunity to work on improving JavaScript testing together. If you'd like to contribute to Jest, please don't hesitate to reach out to us on</em> <em><a href="https://github.com/jestjs/jest" target="_blank" rel="noopener noreferrer" class="">GitHub</a> or on</em> <em><a href="https://discord.gg/j6FKKQQrW9" target="_blank" rel="noopener noreferrer" class="">Discord</a>.</em></p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 22: Refinements & Custom Runners]]></title>
            <link>https://jestjs.io/blog/2017/12/18/jest-22</link>
            <guid>https://jestjs.io/blog/2017/12/18/jest-22</guid>
            <pubDate>Mon, 18 Dec 2017 00:00:00 GMT</pubDate>
            <description><![CDATA[Today we are announcing a new major version of Jest which refines almost all parts of Jest to provide a more solid testing foundation. Together with the Jest community we made a number of changes across the board that will help you get more out of Jest. We are also graduating the custom runners feature out of the experimental stage and added a new package, jest-worker, for parallelizing work across multiple processes. We have compiled a list of highlights below but make sure to check out the (as always) massive changelog.]]></description>
            <content:encoded><![CDATA[<p>Today we are announcing a new major version of Jest which refines almost all parts of Jest to provide a more solid testing foundation. Together with the Jest community we made a number of changes across the board that will help you get more out of Jest. We are also graduating the custom runners feature out of the experimental stage and added a new package, <code>jest-worker</code>, for parallelizing work across multiple processes. We have compiled a list of highlights below but make sure to check out the (as always) <a href="https://github.com/jestjs/jest/blob/main/CHANGELOG.md" target="_blank" rel="noopener noreferrer" class="">massive changelog</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="good-bye-node-4--welcome-jsdom-11">Good bye Node 4 &amp; welcome JSDOM 11<a href="https://jestjs.io/blog/2017/12/18/jest-22#good-bye-node-4--welcome-jsdom-11" class="hash-link" aria-label="Direct link to Good bye Node 4 &amp; welcome JSDOM 11" title="Direct link to Good bye Node 4 &amp; welcome JSDOM 11" translate="no">​</a></h2>
<p>With this release we are dropping support for Node 4, mainly because one of our main dependencies, JSDOM, ended their support. Jest now comes out of the box with JSDOM 11 which features better support for SVGs, <code>requestAnimationFrame</code>, <code>URL</code> and <code>URLSearchParams</code> built in, and <a href="https://github.com/jsdom/jsdom/blob/master/Changelog.md" target="_blank" rel="noopener noreferrer" class="">much more</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="custom-runners--easy-parallelization-with-jest-worker">Custom Runners + Easy parallelization with <code>jest-worker</code><a href="https://jestjs.io/blog/2017/12/18/jest-22#custom-runners--easy-parallelization-with-jest-worker" class="hash-link" aria-label="Direct link to custom-runners--easy-parallelization-with-jest-worker" title="Direct link to custom-runners--easy-parallelization-with-jest-worker" translate="no">​</a></h2>
<p>In Jest 21 we introduced the concept of custom Jest runners. Since then, Rogelio, one of Jest's core contributors, built a number of useful runners: If you have many existing tests written using another framework but you'd like to immediately benefit from Jest's features, check out <a href="https://yarnpkg.com/en/package/jest-runner-mocha" target="_blank" rel="noopener noreferrer" class="">jest-runner-mocha</a>. If you have a large codebase that needs linting, <a href="https://twitter.com/lencioni/status/907398856756695040" target="_blank" rel="noopener noreferrer" class="">you may get a significant speedup</a> if you run eslint within Jest using <a href="https://yarnpkg.com/en/package/jest-runner-eslint" target="_blank" rel="noopener noreferrer" class="">jest-runner-eslint</a>.</p>
<p>To gain more of fine-grained control over heavy tasks parallelization (e.g. transforming files or crawling the file system), we designed a new library perfectly suited for the job. We developed a modern, Promise-based module with an approachable API, called <code>jest-worker</code>, that allows you to delegate to child processes those intensive functions. As <code>jest-worker</code>, like any other Jest package, is a part of the Jest platform, you can use it however you like even without ever using Jest itself. You'll find more in the documentation <a href="https://yarnpkg.com/en/package/jest-worker" target="_blank" rel="noopener noreferrer" class="">here</a>.</p>
<p>To get a better understanding of custom runners and Jest as a platform, make sure to check out Rogelio's talk from Reactive Conf 2017: <a href="https://www.youtube.com/watch?v=NtjyeojAOBs" target="_blank" rel="noopener noreferrer" class="">Jest as a Platform</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="codeframe-in-test-failures">Codeframe in test failures<a href="https://jestjs.io/blog/2017/12/18/jest-22#codeframe-in-test-failures" class="hash-link" aria-label="Direct link to Codeframe in test failures" title="Direct link to Codeframe in test failures" translate="no">​</a></h2>
<p>In order to more easily identify which assertion is failing your test, we've added a code frame showing the context where the assertion is in order to focus on your own code. See the following example test:</p>
<div class="language-js codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-js codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#6b2e85">test</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'some test'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#888">=&gt;</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword" style="color:#297a29">function</span><span class="token plain"> </span><span class="token function" style="color:#6b2e85">someFunctionWhichShouldThrow</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token keyword control-flow" style="color:#297a29">if</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token boolean" style="color:#36acaa">false</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token keyword control-flow" style="color:#297a29">throw</span><span class="token plain"> </span><span class="token keyword" style="color:#297a29">new</span><span class="token plain"> </span><span class="token class-name">Error</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token keyword control-flow" style="color:#297a29">return</span><span class="token plain"> </span><span class="token string" style="color:#c21325">'success!'</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token function" style="color:#6b2e85">expect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">someFunctionWhichShouldThrow</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">toThrow</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p>In Jest 21, we would display the following error:</p>
<p><img decoding="async" loading="lazy" alt="failure in Jest 21" src="https://jestjs.io/assets/images/22-failure-21-a7eb296a994d13405234955abd946adc.png" width="972" height="650" class="img_SS3x"></p>
<p>In Jest 22, we have added a codeframe, giving more context to the failing assertions. We have also cleaned up the stack trace to remove more clutter than ever.</p>
<p><img decoding="async" loading="lazy" alt="failure in Jest 22" src="https://jestjs.io/assets/images/22-failure-22-2dfad8dd25ea9b4b87a9359658f5eab4.png" width="938" height="744" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="easier-testing-of-errors-thrown-in-async-code">Easier testing of errors thrown in async code<a href="https://jestjs.io/blog/2017/12/18/jest-22#easier-testing-of-errors-thrown-in-async-code" class="hash-link" aria-label="Direct link to Easier testing of errors thrown in async code" title="Direct link to Easier testing of errors thrown in async code" translate="no">​</a></h2>
<p>You can now use <code>toThrow</code> and <code>toThrowErrorMatchingSnapshot</code> on promise rejections in the same way you can on synchronous errors.</p>
<div class="language-js codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-js codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token keyword" style="color:#297a29">async</span><span class="token plain"> </span><span class="token keyword" style="color:#297a29">function</span><span class="token plain"> </span><span class="token function" style="color:#6b2e85">throwingFunction</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword control-flow" style="color:#297a29">throw</span><span class="token plain"> </span><span class="token keyword" style="color:#297a29">new</span><span class="token plain"> </span><span class="token class-name">Error</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'This failed'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#6b2e85">test</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'asynchronous rejection'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token keyword" style="color:#297a29">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#888">=&gt;</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword control-flow" style="color:#297a29">await</span><span class="token plain"> </span><span class="token function" style="color:#6b2e85">expect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#6b2e85">throwingFunction</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">rejects</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">toThrowErrorMatchingSnapshot</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="asynchronous-test-environments">Asynchronous test environments<a href="https://jestjs.io/blog/2017/12/18/jest-22#asynchronous-test-environments" class="hash-link" aria-label="Direct link to Asynchronous test environments" title="Direct link to Asynchronous test environments" translate="no">​</a></h2>
<p>When <a href="https://github.com/GoogleChrome/puppeteer/" target="_blank" rel="noopener noreferrer" class="">Puppeteer</a>, a way of programmatically interacting with a real Chromium Browser, was announced by the Google Chrome team in August, many wanted to be able to use Jest to write their tests running them in Chrome. The community have helped us out making this possible by allowing asynchronous test environments. We are still working on making this experience as good as possible, but please see <a class="" href="https://jestjs.io/docs/puppeteer">this guide</a> for how to use Puppeteer with Jest, starting today.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="experimental-leak-detection">Experimental Leak Detection<a href="https://jestjs.io/blog/2017/12/18/jest-22#experimental-leak-detection" class="hash-link" aria-label="Direct link to Experimental Leak Detection" title="Direct link to Experimental Leak Detection" translate="no">​</a></h2>
<p>We added an experimental <code>--detectLeaks</code> setting to Jest that will let you know if your internal environment instance is leaked after a test execution. It will also warn you when your test suite tries to require a file after the test has finished, meaning you forgot to wait for all async operations or left something not properly cleaned. This will however not discover leaks in user land code, only in test land code; although the technology used behind it can help you (see <code>jest-leak-detector</code>). If you are reporting a bug about Jest's memory usage, please provide a repro where <code>--detectLeaks</code> will make the test suite fail. We <a href="https://github.com/jestjs/jest/pull/4970" target="_blank" rel="noopener noreferrer" class="">started building a better sandboxing mechanism</a> for Jest but it's not ready yet to be enabled by default. If you'd like to help, please reach out to us on discord!</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="watch-mode-refinements">Watch Mode Refinements<a href="https://jestjs.io/blog/2017/12/18/jest-22#watch-mode-refinements" class="hash-link" aria-label="Direct link to Watch Mode Refinements" title="Direct link to Watch Mode Refinements" translate="no">​</a></h2>
<p>When using watch mode, there is now a way to <a href="https://github.com/jestjs/jest/pull/4886" target="_blank" rel="noopener noreferrer" class="">focus only on tests that previously failed</a>. In this mode, Jest will not re-run previously passing tests which should help you iron out all test failures. Additionally, <a href="https://github.com/jestjs/jest/pull/4841" target="_blank" rel="noopener noreferrer" class="">we added a plugin system to watch mode</a>. By adding modules to <code>watchPlugins</code> in your configuration you can extend the features of the watch mode.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="babel-7-support">Babel 7 support<a href="https://jestjs.io/blog/2017/12/18/jest-22#babel-7-support" class="hash-link" aria-label="Direct link to Babel 7 support" title="Direct link to Babel 7 support" translate="no">​</a></h2>
<p>Jest uses Babel under the hood to power code coverage and advanced mocking features. With Jest 22, it also supports the upcoming Babel 7. You'll find more in the documentation <a class="" href="https://jestjs.io/docs/getting-started#using-babel">here</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="mock-function-improvements">Mock function improvements<a href="https://jestjs.io/blog/2017/12/18/jest-22#mock-function-improvements" class="hash-link" aria-label="Direct link to Mock function improvements" title="Direct link to Mock function improvements" translate="no">​</a></h2>
<p>There has been a couple of changes to mock functions in Jest 22, making them even easier to use. Firstly, we added a <a class="" href="https://jestjs.io/docs/mock-function-api#mockfnmocknamevalue"><code>mockName</code></a> property allowing you to name your mocks, which is useful in assertion failures. We have also made the Jest mock function serializable in <code>pretty-format</code>, meaning that you can snapshot test mocks. In Jest 21, <code>expect(jest.fn()).toMatchSnapshot()</code> would serialize to <code>[Function]</code>, in Jest 22, you might get something like this:</p>
<div class="language-js codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-js codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#6b2e85">test</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'my mocking test'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#888">=&gt;</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword" style="color:#297a29">const</span><span class="token plain"> mock </span><span class="token operator" style="color:#888">=</span><span class="token plain"> jest</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">fn</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">mockName</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'myMock'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token function" style="color:#6b2e85">mock</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'hello'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token literal-property property" style="color:#82772c">foo</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token string" style="color:#c21325">'bar'</span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token function" style="color:#6b2e85">expect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">mock</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">toMatchSnapshot</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic">// Serializes to:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">exports</span><span class="token punctuation" style="color:#393A34">[</span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token template-string string" style="color:#c21325">my mocking test 1</span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token operator" style="color:#888">=</span><span class="token plain"> </span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token template-string string" style="color:#c21325"></span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">[MockFunction myMock] {</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  "calls": Array [</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">    Array [</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">      "hello",</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">      Object {</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">        "foo": "bar",</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">      },</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">    ],</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  ],</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">}</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325"></span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="highlights-from-jest-21">Highlights from Jest 21<a href="https://jestjs.io/blog/2017/12/18/jest-22#highlights-from-jest-21" class="hash-link" aria-label="Direct link to Highlights from Jest 21" title="Direct link to Highlights from Jest 21" translate="no">​</a></h2>
<p>Jest 21 was released back in September, and we unfortunately never got around to write a blog post. So here is a quick summary of the main changes in version 21:</p>
<ol>
<li class=""><strong>Use expect and jest-mock in the browser:</strong> <a href="https://github.com/mjackson" target="_blank" rel="noopener noreferrer" class="">Michael Jackson</a> donated his excellent <a href="https://github.com/mjackson/expect" target="_blank" rel="noopener noreferrer" class=""><code>expect</code></a> package to the Jest project. As part of that transition, the Jest core team, with much help from <a href="https://github.com/skovhus/" target="_blank" rel="noopener noreferrer" class="">Kenneth Skovhus</a>, made both <code>jest-matchers</code> (renamed to <code>expect</code>) and <code>jest-mock</code> work in browsers. This means that while you cannot use Jest itself in browsers (<a href="https://github.com/jestjs/jest/issues/848" target="_blank" rel="noopener noreferrer" class="">yet</a>), you can use its awesome assertions and mocks for instance as replacements for Chai and Sinon running in Mocha tests. If you are migrating from earlier <code>expect</code> to the new Jest-powered <code>expect</code>, you can use <a href="https://github.com/skovhus/jest-codemods/" target="_blank" rel="noopener noreferrer" class=""><code>jest-codemods</code></a> to automate the migration.</li>
<li class=""><strong>MIT License:</strong> We changed Jest's license to MIT. <em>Yay!</em></li>
<li class=""><strong>Fail test suites on async errors:</strong> Jest used to have a bug that made it crash when errors were thrown in certain parts of async code. This was fixed by community contributors.</li>
<li class=""><strong>Faster startup:</strong> With Jest 21 we fine tuned Jest's startup to be more than 50% faster. The large overhead of Jest when running it on a small and fast test was always an issue for us and now this shouldn't be a reason to hold you back from using Jest any longer.</li>
</ol>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="jest-community">Jest Community<a href="https://jestjs.io/blog/2017/12/18/jest-22#jest-community" class="hash-link" aria-label="Direct link to Jest Community" title="Direct link to Jest Community" translate="no">​</a></h2>
<p>The community around Jest is working hard to make the testing experience even greater. These are separate projects from the main Jest project, but we want to highlight some of our personal favorites here.</p>
<ul>
<li class=""><a href="https://github.com/americanexpress/jest-image-snapshot" target="_blank" rel="noopener noreferrer" class="">jest-image-snapshot</a> – custom matcher to compare images with snapshots by American Express developers</li>
<li class=""><a href="https://github.com/kulshekhar/ts-jest" target="_blank" rel="noopener noreferrer" class="">ts-jest</a> – all you need to successfully run Jest within TypeScript project by <a href="https://github.com/kulshekhar/ts-jest" target="_blank" rel="noopener noreferrer" class="">@kulshekhar</a></li>
<li class=""><a href="https://github.com/skovhus/jest-codemods/" target="_blank" rel="noopener noreferrer" class="">jest-codemods</a> – migrate your tests from other frameworks to Jest with ease</li>
<li class=""><a href="https://github.com/negativetwelve/jest-plugins" target="_blank" rel="noopener noreferrer" class="">jest-plugins</a> – a new community project oriented around simplifying setting up test environment for specific tools, like React, or providing some handy utilities</li>
</ul>
<p>We'd also like to announce that recently we launched a new place for high quality Jest additions – <a href="https://github.com/jest-community" target="_blank" rel="noopener noreferrer" class="">jest-community</a>. It's a new GitHub organization already featuring our favorite projects, like <a href="https://github.com/jest-community/vscode-jest" target="_blank" rel="noopener noreferrer" class="">vscode-jest</a>, <a href="https://github.com/jest-community/jest-extended" target="_blank" rel="noopener noreferrer" class="">jest-extended</a>, to name a few, curated by Jest maintainers and collaborators. We've even migrated our <a href="https://github.com/jest-community/eslint-plugin-jest" target="_blank" rel="noopener noreferrer" class="">eslint-plugin-jest</a> there, and already see some great contributions, which are published independently at a faster pace.</p>
<p><img decoding="async" loading="lazy" alt="Jest Community" src="https://jestjs.io/assets/images/22-community-2b148613668cb789c0215015bfbc10c7.png" width="2004" height="1090" class="img_SS3x"></p>
<p>Community projects under one organisation are also a great way for us to experiment on things like automated releases, which we'd like to explore for Jest as well. They also enable us to share some common things between them, like the shape of the README for example (thanks to the webpack Community for the idea), making it easier to learn and use for all of us.</p>
<p>If you have something awesome to share, feel free to reach out to us! We'd love to share your project here.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 20: 💖 Delightful Testing & 🏃🏽 Multi-Project-Runner]]></title>
            <link>https://jestjs.io/blog/2017/05/06/jest-20-delightful-testing-multi-project-runner</link>
            <guid>https://jestjs.io/blog/2017/05/06/jest-20-delightful-testing-multi-project-runner</guid>
            <pubDate>Sat, 06 May 2017 00:00:00 GMT</pubDate>
            <description><![CDATA[A few months ago we announced Jest 19 which came with major new features and was the biggest Jest release until today. Jest 20 has twice the amount of changes compared to the previous version, features a complete rewrite of the test runner, adds new testing APIs. The new release enables a new level of customization and configuration for projects all while making it effortless to upgrade. Beyond Painless JavaScript Testing, we believe Jest is now delivering a Delightful JavaScript Testing experience. Let's take a look at the best new features and changes in depth:]]></description>
            <content:encoded><![CDATA[<p>A few months ago we announced <a class="" href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements">Jest 19</a> which came with major new features and was the biggest Jest release until today. Jest 20 has twice the amount of changes compared to the previous version, features a complete rewrite of the test runner, adds new testing APIs. The new release enables a new level of customization and configuration for projects all while making it effortless to upgrade. Beyond Painless JavaScript Testing, we believe Jest is now delivering a <strong>Delightful JavaScript Testing experience</strong>. Let's take a look at the best new features and changes in depth:</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="multi-project-runner--configuration-overhaul">Multi-Project-Runner &amp; Configuration Overhaul<a href="https://jestjs.io/blog/2017/05/06/jest-20-delightful-testing-multi-project-runner#multi-project-runner--configuration-overhaul" class="hash-link" aria-label="Direct link to Multi-Project-Runner &amp; Configuration Overhaul" title="Direct link to Multi-Project-Runner &amp; Configuration Overhaul" translate="no">​</a></h2>
<p>Until now, Jest could only operate in one project at a time. This is often cumbersome if you are working on many smaller projects that each have their own setup and configuration. With Jest 20, we rewrote the test runner completely to run many projects at the same time within a single instance of Jest, for example if you are working on a React frontend and a node.js backend. Here is a video of Jest running tests for <a href="https://github.com/facebook/react" target="_blank" rel="noopener noreferrer" class="">React</a>, <a href="https://github.com/facebook/relay" target="_blank" rel="noopener noreferrer" class="">Relay</a>, <a href="https://github.com/yarnpkg/yarn" target="_blank" rel="noopener noreferrer" class="">Yarn</a> and Jest all at the same time:</p>
<p><img decoding="async" loading="lazy" alt="multi-runner" src="https://jestjs.io/assets/images/20-multi-runner-bca686433b2cb63c147951eedce67538.gif" width="839" height="520" class="img_SS3x"></p>
<p>Jest is now collapsing the usage guide after the first test run to save vertical space in the terminal.</p>
<p>Further, we completely overhauled how the configuration system works inside of Jest. You can now pass any configuration option through the CLI to overwrite the ones specified in your configuration file. Along with that, we changed Jest to look for a <code>jest.config.js</code> file by default which means you are now able to define a Jest configuration using JavaScript as well as being able to configure it through <code>package.json</code> like before. Through the addition of all these new features, you are now able to combine Jest in more powerful ways than ever before. For example, if you would like to find out which tests Jest would run given a set of changed files from a commit across multiple projects in a monorepo, you can combine cli arguments like this now:</p>
<div class="language-bash codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-bash codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token plain">$ jest </span><span class="token parameter variable" style="color:#1373c2">--projects</span><span class="token plain"> projectA projectB </span><span class="token parameter variable" style="color:#1373c2">--listTests</span><span class="token plain"> </span><span class="token parameter variable" style="color:#1373c2">--findRelatedTests</span><span class="token plain"> projectA/banana.js projectB/kiwi.js</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token string" style="color:#c21325">"projectA/banana.test.js"</span><span class="token plain">,</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token string" style="color:#c21325">"projectB/kiwi.test.js"</span><span class="token plain">,</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token string" style="color:#c21325">"projectB/pineapple.test.js"</span><span class="token plain">,</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">]</span><br></span></code></pre></div></div>
<p>This is especially useful for continuous integration (CI) systems where you may want to only run a subset of tests for Pull Requests to prevent Jest from running thousands of test files on every small change.</p>
<p>Finally, we are now properly mapping code coverage when using TypeScript and we are running code coverage for untested files in worker processes which yields significant speed ups for this feature.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="new--improved-testing-apis">New &amp; Improved Testing APIs<a href="https://jestjs.io/blog/2017/05/06/jest-20-delightful-testing-multi-project-runner#new--improved-testing-apis" class="hash-link" aria-label="Direct link to New &amp; Improved Testing APIs" title="Direct link to New &amp; Improved Testing APIs" translate="no">​</a></h2>
<p>We made a number of additions and improvements to the testing APIs which will help write more effective tests. We'd like to point out that all of these improvements were made entirely by community members!</p>
<ul>
<li class=""><strong>Better async testing:</strong> Added new async/Promise support through resolves/rejects modifiers on expect: <code>expect(Promise(…)).resolves.toEqual(…)</code>. <a class="" href="https://jestjs.io/docs/expect#resolves">See documentation</a>.</li>
<li class=""><strong>Expect <code>n</code> assertions:</strong> Along with the existing <code>expect.assertions(n)</code>, the new <code>expect.hasAssertions()</code> can be used to ensure a test has at least one assertion.</li>
<li class=""><strong>Lint Plugin:</strong> A <code>valid-expect</code> rule was added to <code>eslint-plugin-jest</code> to ensure that an assertion is called after invoking <code>expect</code>. This will prevent mistakes like a stray <code>expect(banana);</code> with a missing assertion call.</li>
<li class=""><strong>Pretty-Format Plugins:</strong> A number of new pretty-format plugins were added to Jest. We now pretty-print <a href="https://github.com/facebook/immutable-js/" target="_blank" rel="noopener noreferrer" class="">Immutable.js</a> data structures and HtmlElements in assertion failures and snapshots.</li>
<li class=""><strong>Custom Environment:</strong> It is now possible to add a <code>@jest-environment node|jsdom</code> annotation to the doc-block comment of a test file to use a test environment different from the default for individual tests.</li>
</ul>
<p>Here is an example of all how all the new APIs together will make testing more delightful:</p>
<div class="language-js codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-js codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token doc-comment comment" style="color:#999988;font-style:italic">/**</span><br></span><span class="token-line" style="color:#393A34"><span class="token doc-comment comment" style="color:#999988;font-style:italic"> * </span><span class="token doc-comment comment keyword" style="color:#297a29;font-style:italic">@jest-environment</span><span class="token doc-comment comment" style="color:#999988;font-style:italic"> node</span><br></span><span class="token-line" style="color:#393A34"><span class="token doc-comment comment" style="color:#999988;font-style:italic"> */</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#6b2e85">test</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'compares apples and bananas'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token keyword" style="color:#297a29">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#888">=&gt;</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  expect</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">hasAssertions</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Ensure this test has at least one assertion.</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword control-flow" style="color:#297a29">await</span><span class="token plain"> </span><span class="token function" style="color:#6b2e85">expect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token known-class-name class-name">Promise</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">resolve</span><span class="token punctuation" style="color:#393A34">(</span><span class="token maybe-class-name">Immutable</span><span class="token punctuation" style="color:#393A34">.</span><span class="token known-class-name class-name">Map</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token literal-property property" style="color:#82772c">apples</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token number" style="color:#1373c2">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token literal-property property" style="color:#82772c">bananas</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token number" style="color:#1373c2">2</span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">resolves</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">toEqual</span><span class="token punctuation" style="color:#393A34">(</span><span class="token maybe-class-name">Immutable</span><span class="token punctuation" style="color:#393A34">.</span><span class="token known-class-name class-name">Map</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token literal-property property" style="color:#82772c">apples</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token number" style="color:#1373c2">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token literal-property property" style="color:#82772c">bananas</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token number" style="color:#1373c2">3</span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token function" style="color:#6b2e85">expect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'banana'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// valid-expect in eslint-plugin-jest will show an error.</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p>This example will print a test failure similar to this:</p>
<p><img decoding="async" loading="lazy" alt="testing-apis" src="https://jestjs.io/assets/images/20-testing-apis-d1ff5d93e72e0aedc768bd40bd179e96.png" width="2164" height="1638" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="breaking-changes">Breaking Changes<a href="https://jestjs.io/blog/2017/05/06/jest-20-delightful-testing-multi-project-runner#breaking-changes" class="hash-link" aria-label="Direct link to Breaking Changes" title="Direct link to Breaking Changes" translate="no">​</a></h2>
<p>As with every major release, we are making a number of breaking changes to make larger changes in the future possible and to push the testing experience to a new level. This time, we tried our best to only break APIs that we don't expect to affect the majority of Jest's users:</p>
<ul>
<li class=""><strong>Fork of Jasmine 2.5:</strong> We finally decided to fork Jasmine itself and take ownership over Jest's own test runner. This will allow us to improve all aspects of the unit testing experience in the future but for now we are focused on incremental rewrites and reducing the API surface. If you see a test breaking as a result of a Jasmine API that is now missing, there should be an equivalent feature on the <code>jest</code> or <code>expect</code> objects. As such, we have removed many Jasmine features that aren't generally used in most codebases.</li>
<li class=""><strong>New Snapshots on CI:</strong> Snapshots must always be committed along with the test and the modules they are testing. We changed Jest to not save new snapshots automatically in Continuous Integration (CI) environments or when the <code>--ci</code> flag is specified. To overwrite this behavior, which is generally not recommended, the <code>--updateSnapshot</code> flag can be used.</li>
<li class=""><strong>Babel-Polyfill:</strong> Jest used to load <code>babel-polyfill</code> automatically when using babel-jest which resulted in memory leaks inside of Jest. In most versions of node, it is not necessary to load <code>babel-polyfill</code> so we removed this auto-inclusion and instead changed Jest to only include <code>regenerator-runtime</code> by default, which is commonly used to support async/await in older versions of Node.js. If you need <code>babel-polyfill</code>, you can manually require it in your setup files.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="other-improvements">Other Improvements<a href="https://jestjs.io/blog/2017/05/06/jest-20-delightful-testing-multi-project-runner#other-improvements" class="hash-link" aria-label="Direct link to Other Improvements" title="Direct link to Other Improvements" translate="no">​</a></h2>
<ul>
<li class=""><strong>Documentation:</strong> Documentation is critical to share best practices and teach everyone how to write effective tests which will lead to better software. Over the last few weeks we have also expanded Jest's documentation to include a Snapshot Testing FAQ, a guide with information about how to use Jest with common JavaScript libraries as well as we documented the new features mentioned above.</li>
<li class=""><strong>Translations:</strong> We are now asking for your help to <a href="https://crowdin.com/project/jest-v2" target="_blank" rel="noopener noreferrer" class="">translate the Jest documentation</a> to make it easier for people to learn how to use Jest.</li>
<li class=""><strong>Custom Reporters:</strong> Jest now supports custom test reporters through the <code>reporters</code> configuration option. You can finally customize the output of Jest as well as integrate it with other tools by generating reports in formats such as XML. <a class="" href="https://jestjs.io/docs/configuration#reporters-array-modulename-modulename-options">See documentation</a>.</li>
<li class=""><strong>Codebase Health:</strong> It was only possible iterate so quickly in Jest because we spent a significant amount of time on the health of the codebase. We were one of the early adopters of <a href="https://github.com/prettier/prettier" target="_blank" rel="noopener noreferrer" class="">prettier</a>, we notably increased flow coverage, forked Jasmine to improve our test runner library and we rewrote and refactored significant portions of Jest itself to set up Jest for success in the future.</li>
<li class=""><strong>Bugfixes:</strong> As always, we made plenty of bugfixes in Jest. The full changelog can be found in the <a href="https://github.com/jestjs/jest/blob/main/CHANGELOG.md#jest-2000" target="_blank" rel="noopener noreferrer" class="">Jest repository</a>.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="talks-about-jest">Talks about Jest<a href="https://jestjs.io/blog/2017/05/06/jest-20-delightful-testing-multi-project-runner#talks-about-jest" class="hash-link" aria-label="Direct link to Talks about Jest" title="Direct link to Talks about Jest" translate="no">​</a></h2>
<p>Recently the Jest core team and other contributors started to talk more about Jest and the experience of working on Jest at conferences:</p>
<ul>
<li class="">Rogelio Guzman did a talk about <a href="https://www.youtube.com/watch?time_continue=416&amp;v=HAuXJVI_bUs" target="_blank" rel="noopener noreferrer" class="">Jest Snapshots and Beyond</a> at React Conf.</li>
<li class="">I spoke about <a href="https://developers.facebook.com/videos/f8-2017/building-high-quality-javascript-tools/" target="_blank" rel="noopener noreferrer" class="">Building High-Quality JavaScript Tools</a> at Facebook's F8 conference.</li>
</ul>
<p><em>As always, this release couldn't have been possible without you, the JavaScript community. We are incredibly grateful that we get the opportunity to work on improving JavaScript testing together. If you'd like to contribute to Jest, please don't hesitate to reach out to us on <a href="https://github.com/jestjs/jest" target="_blank" rel="noopener noreferrer" class="">GitHub</a> or on <a href="https://discord.gg/j6FKKQQrW9" target="_blank" rel="noopener noreferrer" class="">Discord</a>.</em></p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[🃏 Jest 19: Immersive Watch Mode & Test Platform Improvements]]></title>
            <link>https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements</link>
            <guid>https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements</guid>
            <pubDate>Tue, 21 Feb 2017 00:00:00 GMT</pubDate>
            <description><![CDATA[Today we are pleased to ship version 19 of the Jest testing platform. It's the biggest Jest release we have shipped so far and we are quite excited to show you what we've built over the last two months:]]></description>
            <content:encoded><![CDATA[<p>Today we are pleased to ship version 19 of the Jest testing platform. It's the biggest Jest release we have shipped so far and we are quite excited to show you what we've built over the last two months:</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="immersive-watch-mode">Immersive Watch Mode<a href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements#immersive-watch-mode" class="hash-link" aria-label="Direct link to Immersive Watch Mode" title="Direct link to Immersive Watch Mode" translate="no">​</a></h2>
<p>We <a href="https://github.com/jestjs/jest/pull/2362" target="_blank" rel="noopener noreferrer" class="">completely rewrote the watch mode</a> to make it instant and more extensible. As a result, the experience of using it really is immersive: tests re-run instantly after a file change and we made it easy to select the right tests.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="snapshot-updates">Snapshot Updates<a href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements#snapshot-updates" class="hash-link" aria-label="Direct link to Snapshot Updates" title="Direct link to Snapshot Updates" translate="no">​</a></h2>
<p>We made a couple of changes to the snapshot format. We don't make changes like this often and only consider them if they actually improve how snapshots work. As well as introducing a snapshot version number we accumulated a number of changes we wanted to make to the format for a while:</p>
<ul>
<li class="">We dropped the “test” prefix in snapshot names from top level <code>test</code> or <code>it</code> calls.</li>
<li class="">We improved the printing of React elements to cause less changes when the last prop in an element changes.</li>
<li class="">We improved the character escaping mechanism to be more bulletproof.</li>
</ul>
<p>Before:</p>
<div class="language-js codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-js codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token plain">exports</span><span class="token punctuation" style="color:#393A34">[</span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token template-string string" style="color:#c21325">test snap 1</span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token operator" style="color:#888">=</span><span class="token plain"> </span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token template-string string" style="color:#c21325"></span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">&lt;header&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  &lt;h1&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">    Jest \"19\"</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  &lt;/h1&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  &lt;Subtitle</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">    name="Painless JavaScript Testing" /&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">&lt;/header&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325"></span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p>After (no “test” prefix, better JSX rendering, version header):</p>
<div class="language-js codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-js codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token comment" style="color:#999988;font-style:italic">// Jest Snapshot v1, https://goo.gl/fbAQLP</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">exports</span><span class="token punctuation" style="color:#393A34">[</span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token template-string string" style="color:#c21325">snap 1</span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token operator" style="color:#888">=</span><span class="token plain"> </span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token template-string string" style="color:#c21325"></span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">&lt;header&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  &lt;h1&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">    Jest "19"</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  &lt;/h1&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  &lt;Subtitle</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">    name="Painless JavaScript Testing"</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  /&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">&lt;/header&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325"></span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p>We decided it's a good time to introduce versioned snapshots to ensure all developers are using a compatible version of Jest. Here's how we warn you about the need to update your snapshot:</p>
<p><img decoding="async" loading="lazy" alt="snapshot-version" src="https://jestjs.io/assets/images/19-snapshot-version-457ba31d60bb428bee970eb1ed529408.png" width="1396" height="311" class="img_SS3x"></p>
<p>Please make sure you revert any local changes before updating to make the transition smooth and to ensure you aren't including any unwanted changes from failing tests in your new snapshots.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="improved-printing-of-skipped-tests">Improved printing of skipped tests<a href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements#improved-printing-of-skipped-tests" class="hash-link" aria-label="Direct link to Improved printing of skipped tests" title="Direct link to Improved printing of skipped tests" translate="no">​</a></h2>
<p>Skipped tests are now printed as a single line instead of showing every individual one when testing in verbose mode or a single suite. Hopefully it will let you focus on currently important tests. It also occupies far less space!</p>
<p><img decoding="async" loading="lazy" alt="skipped-tests" src="https://jestjs.io/assets/images/19-skipped-tests-a51df1988c39d164bc52200a71459ec6.png" width="616" height="341" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="new-cli-arguments">New CLI arguments<a href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements#new-cli-arguments" class="hash-link" aria-label="Direct link to New CLI arguments" title="Direct link to New CLI arguments" translate="no">​</a></h2>
<p>Jest 19 ships with two new coverage-related arguments which you can run from CLI:</p>
<ul>
<li class=""><code>--collectCoverageFrom</code></li>
<li class=""><code>--coverageDirectory</code></li>
</ul>
<p>We now also error on invalid CLI arguments instead of ignoring them. But we've got your back with helpful error message like the one below, e.g. when you try running <code>jest --watc</code>:</p>
<p><img decoding="async" loading="lazy" alt="cli-error" src="https://jestjs.io/assets/images/19-cli-error-0a7455fcb6a1a01013633cc34575a1b8.png" width="738" height="214" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="expect-improvements"><code>expect</code> Improvements<a href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements#expect-improvements" class="hash-link" aria-label="Direct link to expect-improvements" title="Direct link to expect-improvements" translate="no">​</a></h2>
<ul>
<li class=""><a class="" href="https://jestjs.io/docs/expect#expectaddsnapshotserializerserializer"><code>expect.addSnapshotSerializer</code></a></li>
<li class=""><a class="" href="https://jestjs.io/docs/expect#expectstringcontainingstring"><code>expect.stringContaining</code></a></li>
<li class=""><a class="" href="https://jestjs.io/docs/jest-object#jestspyonobject-methodname"><code>jest.spyOn</code></a></li>
</ul>
<p>We're close to almost full feature parity with the <code>expect</code> npm package. <a href="https://twitter.com/mjackson" target="_blank" rel="noopener noreferrer" class="">Michael Jackson</a>, the author of the package, agreed to <a href="https://github.com/jestjs/jest/issues/1679" target="_blank" rel="noopener noreferrer" class="">donate</a> it to the Jest project, which means that <code>jest-matchers</code> will be renamed to <code>expect</code>. Since our version of <code>expect</code> is not intended to be fully compatible, <a href="https://twitter.com/Vjeux" target="_blank" rel="noopener noreferrer" class="">Christopher Chedeau</a> is working on a codemod to make the transition painless. Christopher also worked on a number of improvements to <code>jest-matchers</code> which enables it to be used outside of Jest and even <a href="https://github.com/jestjs/jest/pull/2795" target="_blank" rel="noopener noreferrer" class="">works inside browsers</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="eslint-plugin-jest--our-very-own-eslint-plugin"><a href="https://github.com/jest-community/eslint-plugin-jest" target="_blank" rel="noopener noreferrer" class="">eslint-plugin-jest</a> – our very own ESLint plugin<a href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements#eslint-plugin-jest--our-very-own-eslint-plugin" class="hash-link" aria-label="Direct link to eslint-plugin-jest--our-very-own-eslint-plugin" title="Direct link to eslint-plugin-jest--our-very-own-eslint-plugin" translate="no">​</a></h2>
<p>Thanks to <a href="https://twitter.com/jonnykim" target="_blank" rel="noopener noreferrer" class="">Jonathan Kim</a> Jest finally has its own official ESLint plugin. It exposes three rules:</p>
<ul>
<li class=""><a href="https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-disabled-tests.md" target="_blank" rel="noopener noreferrer" class="">no-disabled-tests</a> - this rule prevents you from accidentally committing disabled tests.</li>
<li class=""><a href="https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-focused-tests.md" target="_blank" rel="noopener noreferrer" class="">no-focused-tests</a> - this rule prevents you from committing focused tests which would disable all other tests in the same suite.</li>
<li class=""><a href="https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-identical-title.md" target="_blank" rel="noopener noreferrer" class="">no-identical-title</a> - disallows identical titles in test names.</li>
</ul>
<p>You can install it using <code>npm install --save-dev eslint-plugin-jest</code> or <code>yarn add --dev eslint eslint-plugin-jest</code> and it can be enabled by adding <code>{"plugins": ["jest"]}</code> to your eslint configuration.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="new-public-package-jest-validate">New public package: <a href="https://github.com/jestjs/jest/tree/main/packages/jest-validate" target="_blank" rel="noopener noreferrer" class="">jest-validate</a><a href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements#new-public-package-jest-validate" class="hash-link" aria-label="Direct link to new-public-package-jest-validate" title="Direct link to new-public-package-jest-validate" translate="no">​</a></h2>
<p>While we refactored the validation and normalization code for Jest's configuration, we were so happy with the new error messaging that we extracted it to its own module to share it with everyone. With Jest 19 we welcome <code>jest-validate</code> to our self-sustained packages family.</p>
<p><code>jest-validate</code> is a generic configuration validation tool that helps you with warnings, errors and deprecation messages in your JavaScript tool. It's also capable of showing users friendly examples of correct configuration and it comes with a simple but powerful API. We hope it'll make a good addition to your projects!</p>
<p><img decoding="async" loading="lazy" alt="validate" src="https://jestjs.io/assets/images/19-validate-68120eda9a55dbbb0325ea6deea0e973.png" width="1200" height="729" class="img_SS3x"></p>
<p>We're happy to announce that <code>jest-validate</code> is validating config options of <a href="https://github.com/jlongster/prettier" target="_blank" rel="noopener noreferrer" class="">prettier</a> since <a href="https://github.com/jlongster/prettier/blob/main/CHANGELOG.md#0120" target="_blank" rel="noopener noreferrer" class="">v0.12</a>. Feel free to add it to your project, try it, send us feedback and improve it by making pull requests on GitHub.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="improved-asymmetric-matchers">Improved asymmetric matchers<a href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements#improved-asymmetric-matchers" class="hash-link" aria-label="Direct link to Improved asymmetric matchers" title="Direct link to Improved asymmetric matchers" translate="no">​</a></h2>
<p>We moved the asymmetric matchers implementation from Jasmine into Jest, which enabled us to further improve the user experience around them. As a result, asymmetric matchers are now pretty-printed nicely, we added the new <a class="" href="https://jestjs.io/docs/expect#expectstringcontainingstring"><code>expect.stringContaining()</code></a> matcher and we also paired them with <a class="" href="https://jestjs.io/docs/expect#tomatchobjectobject"><code>expect.toMatchObject()</code></a> so you can use the best of both:</p>
<p><img decoding="async" loading="lazy" alt="asymmetric-matchers" src="https://jestjs.io/assets/images/19-asymmetric-matchers-a96ddf170a7a1cdf31a7ffe36374d172.png" width="586" height="222" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="better-manual-mocks">Better manual mocks<a href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements#better-manual-mocks" class="hash-link" aria-label="Direct link to Better manual mocks" title="Direct link to Better manual mocks" translate="no">​</a></h2>
<p>With the latest release, manual mocks now finally work with nested folders. For example <code>__mocks__/react-native/Libraries/Text/Text.js</code> will now work as expected and mock the correct module. We also fixed issues with virtual mocks and transitive dependencies and improved <code>moduleNameMapper</code> to not overwrite mocks when many patterns map to the same file.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="breaking-changes">Breaking Changes<a href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements#breaking-changes" class="hash-link" aria-label="Direct link to Breaking Changes" title="Direct link to Breaking Changes" translate="no">​</a></h2>
<p>As a part of our cleanups and fixes we removed the <code>mocksPattern</code> configuration option which was never officially supported. We also renamed the <code>testPathDirs</code> configuration option to <code>roots</code> which better explains what the option can be used for. The default configuration for <code>roots</code> is <code>["&lt;rootDir&gt;"]</code> and can be customized to include any number of directories. The rootDir configuration option has always been used mostly as a token for other configuration options and this rename should make configuring Jest clearer.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="revamped-documentation">Revamped documentation<a href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements#revamped-documentation" class="hash-link" aria-label="Direct link to Revamped documentation" title="Direct link to Revamped documentation" translate="no">​</a></h2>
<p>As you may have already seen, <a href="https://twitter.com/hectorramos" target="_blank" rel="noopener noreferrer" class="">Hector Ramos</a> and <a href="https://twitter.com/lacker" target="_blank" rel="noopener noreferrer" class="">Kevin Lacker</a> gave Jest's documentation a fresh new look. We changed the way we organize the website and it now features Docs and API as separate pages:</p>
<ul>
<li class="">Under <a class="" href="https://jestjs.io/docs/getting-started#content">Docs</a> you can find an introduction to Jest, including <a class="" href="https://jestjs.io/docs/getting-started#content">Getting Started</a> or <a class="" href="https://jestjs.io/docs/asynchronous#content">Testing Asynchronous Code</a> and handy guides like <a class="" href="https://jestjs.io/docs/snapshot-testing#content">Snapshot Testing</a>, <a class="" href="https://jestjs.io/docs/tutorial-react-native#content">Testing React Native App</a>, <a class="" href="https://jestjs.io/docs/webpack#content">Using with webpack</a> or <a class="" href="https://jestjs.io/docs/migration-guide#content">Migrating to Jest</a> and many more!</li>
<li class="">The <a class="" href="https://jestjs.io/docs/api">API</a> section on the other hand lists all available methods exposed by Jest: the <code>expect</code> and <code>jest</code> objects, mock functions, globals, along with configuration options from <em>package.json</em> and from the CLI.</li>
</ul>
<p>The homepage was completely redesigned to be more descriptive of what Jest is about: “<em>Zero configuration testing platform</em>”. We also made sure it reads better on mobile devices. And for those using RSS – we finally provide a <a href="https://jestjs.io/blog/feed.xml" target="_blank" rel="noopener noreferrer" class="">feed for our blog</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="community-updates">Community Updates<a href="https://jestjs.io/blog/2017/02/21/jest-19-immersive-watch-mode-test-platform-improvements#community-updates" class="hash-link" aria-label="Direct link to Community Updates" title="Direct link to Community Updates" translate="no">​</a></h2>
<ul>
<li class="">We really loved this talk: “<a href="https://www.youtube.com/watch?v=tvy0bSgwtTo" target="_blank" rel="noopener noreferrer" class="">Introduction to Jest</a>“ by Vas Boroviak.</li>
<li class="">Follow <a href="http://twitter.com/jestjs_" target="_blank" rel="noopener noreferrer" class="">@jestjs_ on Twitter</a>.</li>
<li class="">The Jest Core team syncs once a week to discuss current and future issues. If you'd like to work on Jest, let us know, submit a few pull requests and join our weekly team meetings.</li>
<li class="">The awesome engineers at Artsy wrote <a href="http://artsy.github.io/blog/2017/02/05/Front-end-JavaScript-at-Artsy-2017/" target="_blank" rel="noopener noreferrer" class="">about Jest as part of their 2017 frontend stack</a>.</li>
<li class="">Stephen Scott wrote a detailed article about <a href="https://medium.freecodecamp.com/the-right-way-to-test-react-components-548a4736ab22" target="_blank" rel="noopener noreferrer" class="">testing React components</a> in which he weighs the pros and cons of different approaches.</li>
<li class=""><a href="https://medium.com/@kentaromiura_the_js_guy/jest-for-all-episode-1-vue-js-d616bccbe186#.r8ryxlw98" target="_blank" rel="noopener noreferrer" class="">Using Jest with vue.js</a> got a lot easier after reading Cristian Carlesso's blog post.</li>
<li class=""><a href="https://twitter.com/cpojer/status/825004258219130880" target="_blank" rel="noopener noreferrer" class="">Michele Bertoli wrote a book about React Design Patterns and Best Practices</a> which features an entire section about Jest.</li>
<li class="">Improved <code>--notify</code> command that shows an operating system notification which <a href="https://github.com/jestjs/jest/pull/2727" target="_blank" rel="noopener noreferrer" class="">can now also re-run tests from the notification</a>. This is actually a Jest feature and we are just checking if you are still reading this blog post.</li>
<li class="">Jest is now part of <a href="https://twitter.com/mxstbr/status/820326656439177217" target="_blank" rel="noopener noreferrer" class="">react-boilerplate</a>.</li>
<li class="">Read about the <a href="https://medium.com/@boriscoder/the-hidden-power-of-jest-matchers-f3d86d8101b0#.pn10z1pzx" target="_blank" rel="noopener noreferrer" class="">hidden powers of Jest's matchers</a>.</li>
</ul>
<p>Finally, we are happy to announce that the <a href="https://github.com/avajs/ava" target="_blank" rel="noopener noreferrer" class="">ava</a> test runner has adopted parts of the Jest platform and is now shipping with basic <a href="https://github.com/avajs/ava#snapshot-testing" target="_blank" rel="noopener noreferrer" class="">snapshot support</a> and is using <a href="https://github.com/jestjs/jest/tree/main/packages/pretty-format" target="_blank" rel="noopener noreferrer" class="">pretty-format</a>. Consolidating test infrastructure makes it easier to learn how to test applications and enables us to share best practices. We are looking forward to see what we can learn from existing test libraries in the future.</p>
<p>The full <a href="https://github.com/jestjs/jest/blob/main/CHANGELOG.md#jest-1900" target="_blank" rel="noopener noreferrer" class="">changelog can be found on GitHub</a>. Jest 19 was a true JavaScript community effort with <a href="https://github.com/jestjs/jest/graphs/contributors?from=2016-12-23&amp;to=2017-02-21&amp;type=c" target="_blank" rel="noopener noreferrer" class="">17 people who contributed</a> to this release. We thank each and every one of you for your help to make this project great.</p>
<p><em>This blog post was written by <a href="https://twitter.com/rogeliog" target="_blank" rel="noopener noreferrer" class="">Rogelio Guzman</a> and <a href="https://twitter.com/thymikee" target="_blank" rel="noopener noreferrer" class="">Michał Pierzchała</a>.</em></p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Great Developer Experience]]></title>
            <link>https://jestjs.io/blog/2017/01/30/a-great-developer-experience</link>
            <guid>https://jestjs.io/blog/2017/01/30/a-great-developer-experience</guid>
            <pubDate>Mon, 30 Jan 2017 00:00:00 GMT</pubDate>
            <description><![CDATA[We strongly believe that great documentation is crucial to providing a great developer experience. The docs should be clear, concise, and useful to new users and veterans alike. With that in mind, we recently took some time to overhaul the Jest website.]]></description>
            <content:encoded><![CDATA[<p>We strongly believe that great documentation is crucial to providing a great developer experience. The docs should be clear, concise, and useful to new users and veterans alike. With that in mind, we recently took some time to overhaul the Jest website.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="improved-docs">Improved docs<a href="https://jestjs.io/blog/2017/01/30/a-great-developer-experience#improved-docs" class="hash-link" aria-label="Direct link to Improved docs" title="Direct link to Improved docs" translate="no">​</a></h2>
<p>One of the changes you'll notice upon visiting our docs is the updated sidebar. The documentation is now divided into three main areas: an introduction to Jest, detailed guides to Jest's features, and a comprehensive API reference.</p>
<p>The <strong>Introduction</strong> section will guide you from installing Jest and writing your first case, to using Jest's matchers and testing async code. If you're new to Jest or need a quick refresher, these docs should get you up to speed in no time. If you've used Jest before and only need a quick reference on how it's installed, you need to go no further than the <a class="" href="https://jestjs.io/docs/getting-started">Getting Started</a> guide.</p>
<p>Once you feel comfortable using Jest, proceed to the advanced <strong>Guides</strong> section. The new <a class="" href="https://jestjs.io/docs/snapshot-testing">Snapshot Testing guide</a> covers everything you need to know about creating and maintaining snapshot test cases.</p>
<p>Finally, we've completely overhauled our API reference docs. You can now find detailed information on all of Jest's <a class="" href="https://jestjs.io/docs/api">Globals</a>, <a class="" href="https://jestjs.io/docs/expect">matchers</a>, and <a class="" href="https://jestjs.io/docs/cli">every flag</a> supported by the <code>jest</code> CLI.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="new-colors--website">New colors &amp; website<a href="https://jestjs.io/blog/2017/01/30/a-great-developer-experience#new-colors--website" class="hash-link" aria-label="Direct link to New colors &amp; website" title="Direct link to New colors &amp; website" translate="no">​</a></h2>
<p>The colors in the Jest logo and on the website have felt outdated to us for a while. We changed the color scheme we are using for Jest and changed the landing page significantly to be more inviting. We hope you like the new colors and showcase of Jest's strengths.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="whos-using-jest">Who's using Jest?<a href="https://jestjs.io/blog/2017/01/30/a-great-developer-experience#whos-using-jest" class="hash-link" aria-label="Direct link to Who's using Jest?" title="Direct link to Who's using Jest?" translate="no">​</a></h2>
<p>We have created a <a class="" href="https://jestjs.io/">showcase of users</a> to highlight some of the companies that are using Jest. We're thankful to all of these companies for using Jest to test their websites, mobile apps, and APIs. If you're using Jest, check out the guidelines on GitHub and send us a pull request!</p>
<div class="productShowcaseSection"><div class="logos"><img src="https://jestjs.io/img/logos/twitter.png" title="Twitter"><img src="https://jestjs.io/img/logos/pinterest.png" title="Pinterest"><img src="https://jestjs.io/img/logos/paypal.png" title="PayPal"><img src="https://jestjs.io/img/logos/ibm.png" title="IBM"><img src="https://jestjs.io/img/logos/spotify.png" title="Spotify"></div></div>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="jest-in-the-browser">Jest in the browser<a href="https://jestjs.io/blog/2017/01/30/a-great-developer-experience#jest-in-the-browser" class="hash-link" aria-label="Direct link to Jest in the browser" title="Direct link to Jest in the browser" translate="no">​</a></h2>
<p>As highlighted <a class="" href="https://jestjs.io/blog/2016/12/15/2016-in-jest">last month</a>, it is now possible to use Jest directly in the browser using <a href="https://repl.it/languages/jest" target="_blank" rel="noopener noreferrer" class="">repl.it</a>. If you want to try out Jest before installing it, you can easily do so below or directly from the Jest homepage. Go ahead and give it a try!</p>
<div class="jest-repl"><iframe src="https://repl.it/@amasad/try-jest?lite=true"></iframe></div>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="get-involved">Get involved<a href="https://jestjs.io/blog/2017/01/30/a-great-developer-experience#get-involved" class="hash-link" aria-label="Direct link to Get involved" title="Direct link to Get involved" translate="no">​</a></h2>
<p>This is just the start. Go ahead and take a look at the docs, and don't hesitate to send any feedback our way. If you find a mistake in the docs or you just want to let us know what needs to be documented better, please tweet at us at <a href="https://twitter.com/jestjs_" target="_blank" rel="noopener noreferrer" class="">@jestjs_</a>, <a href="https://github.com/jestjs/jest/issues" target="_blank" rel="noopener noreferrer" class="">open an issue on GitHub</a>, or send us a PR by clicking "Edit on GitHub" at the top of the doc.</p>
<p>We're really excited for the year ahead and can't wait to hear from you!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2016 in Jest]]></title>
            <link>https://jestjs.io/blog/2016/12/15/2016-in-jest</link>
            <guid>https://jestjs.io/blog/2016/12/15/2016-in-jest</guid>
            <pubDate>Thu, 15 Dec 2016 00:00:00 GMT</pubDate>
            <description><![CDATA[2016 was a big year for JavaScript testing with Jest. In the first six months of the year we rewrote Jest and built a solid foundation to significantly improve performance and the developer experience of testing JavaScript code. We flow-typed the entire codebase, built a ton of integration tests for Jest itself and adopted lerna to turn Jest from a framework into a Painless JavaScript Testing platform.]]></description>
            <content:encoded><![CDATA[<p>2016 was a big year for JavaScript testing with Jest. In the first six months of the year we rewrote Jest and built a solid foundation to significantly improve performance and the developer experience of testing JavaScript code. We flow-typed the entire codebase, built a ton of integration tests for Jest itself and adopted <a href="https://lernajs.io/" target="_blank" rel="noopener noreferrer" class="">lerna</a> to turn Jest from a framework into a <a href="https://github.com/jestjs/jest/tree/main/packages" target="_blank" rel="noopener noreferrer" class=""><em>Painless JavaScript Testing platform</em></a>.</p>
<p>The newly created <a href="https://yarnpkg.com/en/package/react-test-renderer" target="_blank" rel="noopener noreferrer" class="">react-test-renderer</a> finally enabled testing of react-native components. Through the jest-react-native preset (now merged directly into react-native) Jest now works out of the box for any React project and comes pre-configured in <a href="https://github.com/facebookincubator/create-react-app" target="_blank" rel="noopener noreferrer" class="">create-react-app</a> and <a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="">react-native</a> projects. We integrated core pieces of Jest into <a href="https://github.com/facebook/react-native/tree/main/packager/react-packager/src" target="_blank" rel="noopener noreferrer" class="">react-native's packager</a> and the completely new snapshot testing feature has since been used outside of Jest: It was integrated with React Storybook as “<a href="https://github.com/storybooks/storyshots" target="_blank" rel="noopener noreferrer" class="">storyshots</a>” and is being adopted by other test runners like <a href="https://github.com/avajs/ava/pull/1113" target="_blank" rel="noopener noreferrer" class="">ava</a>.</p>
<p>The <a href="https://github.com/jestjs/jest/tree/main/packages/pretty-format" target="_blank" rel="noopener noreferrer" class="">pretty-format</a> project was rewritten with performance in mind to drive Jest's snapshot feature, was recently merged into Jest's monorepo and is also helpful in other <a href="https://github.com/avajs/ava/pull/1154" target="_blank" rel="noopener noreferrer" class="">test runners</a>. Nowadays Jest is much more about collecting different ideas and solutions to testing than it is about one specific implementation of a test framework.</p>
<p>I'd like to deeply thank all the people that have <a href="https://github.com/jestjs/jest/graphs/contributors?from=2016-01-01&amp;to=2016-12-14&amp;type=c" target="_blank" rel="noopener noreferrer" class="">contributed to Jest this year</a>, both from the open source community and at Facebook: Dmitrii Abramov, Cristian Carlesso, Dan Abramov, Daniel Lo Nigro, Maxim Derbin, Evan Scott, Forbes Lindesay, Keyan Zhang and 60 more people. We'd also like to welcome <a href="https://twitter.com/thymikee" target="_blank" rel="noopener noreferrer" class="">Michał Pierzchała (@thymikee)</a> as first official external contributor to Jest. He's been doing a great job managing the issues and PRs on the repo. If you'd like to start contributing to Jest, we have a bunch of <a href="https://github.com/jestjs/jest/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+bug%22" target="_blank" rel="noopener noreferrer" class="">good first tasks</a> and we are always happy to help on our <a href="https://discord.gg/j6FKKQQrW9" target="_blank" rel="noopener noreferrer" class="">discord channel</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="replit-with-jest-integration"><a href="http://repl.it/" target="_blank" rel="noopener noreferrer" class="">repl.it</a> with Jest integration<a href="https://jestjs.io/blog/2016/12/15/2016-in-jest#replit-with-jest-integration" class="hash-link" aria-label="Direct link to replit-with-jest-integration" title="Direct link to replit-with-jest-integration" translate="no">​</a></h2>
<p>Amjad Massad <a href="https://repl.it/languages/jest" target="_blank" rel="noopener noreferrer" class="">built a Jest container</a> so you can now try out Jest directly in the browser. You can use it from now on when creating GitHub issues which should help troubleshoot problems more quickly. Amjad and Haya are building <a href="http://repl.it/" target="_blank" rel="noopener noreferrer" class="">repl.it</a> to democratize programming by building powerful yet simple tools and platforms for educators, learners, and developers. They are also <a href="https://repl.it/site/jobs" target="_blank" rel="noopener noreferrer" class="">hiring talented engineers</a>!</p>
<div class="jest-repl"><iframe src="https://repl.it/languages/jest?lite=true"></iframe></div>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="community-update">Community Update<a href="https://jestjs.io/blog/2016/12/15/2016-in-jest#community-update" class="hash-link" aria-label="Direct link to Community Update" title="Direct link to Community Update" translate="no">​</a></h2>
<p>We feel incredibly humbled that 100+ companies <a href="https://twitter.com/cpojer/status/803965499407290369" target="_blank" rel="noopener noreferrer" class="">have adopted Jest</a> in the last six months. Companies like Twitter, Pinterest, Paypal, nytimes, IBM (Watson), Spotify, eBay, SoundCloud, Intuit, FormidableLabs, Automattic, Trivago and Microsoft have either fully or partially switched to Jest for their JavaScript testing needs. Thank you very much for giving this project a chance. We would also like to thank everyone who went to conferences and meetups to speak about Jest and to everyone who is writing blog posts about how Jest is or isn't working for them!</p>
<p>Here is what happened in the community in the last two months:</p>
<ul>
<li class="">Jason Bonta and Dmitrii Abramov <a href="https://twitter.com/abramov_dmitrii/status/805913874704674816" target="_blank" rel="noopener noreferrer" class="">redefined the “testing pyramid”</a> we were talking a lot about at Facebook.</li>
<li class=""><a href="https://github.com/skovhus/jest-codemods#jest-codemods" target="_blank" rel="noopener noreferrer" class="">jest-codemods</a> now allows you to painlessly migrate from Mocha, Tape and Ava to Jest.</li>
<li class="">The React team announced <a href="https://facebook.github.io/react/blog/2016/11/16/react-v15.4.0.html" target="_blank" rel="noopener noreferrer" class="">improvements to the react-test-renderer</a> in 15.4.0.</li>
<li class="">Orta Therox build an amazing <a href="https://github.com/orta/vscode-jest#the-aim" target="_blank" rel="noopener noreferrer" class="">vscode-jest integration</a> and donated the code for editor support to Jest.</li>
<li class="">Pavithra Kodmad is documenting <a href="http://pksjce.github.io/2016/12/08/notes-on-jest" target="_blank" rel="noopener noreferrer" class="">Flipkarts adoption of Jest</a> and shares some getting started tips.</li>
<li class="">Kent C. Dodds wrote about <a href="https://medium.com/@kentcdodds/migrating-to-jest-881f75366e7e#.ticf0wchu" target="_blank" rel="noopener noreferrer" class="">migrating to Jest at Paypal</a> and Jason Brown <a href="http://browniefed.com/blog/migrating-ava-to-jest/" target="_blank" rel="noopener noreferrer" class="">wrote about migrating to Jest as well</a>.</li>
<li class="">Ben McCormick wrote about <a href="http://benmccormick.org/2016/12/10/saving-time-with-jest/" target="_blank" rel="noopener noreferrer" class="">saving time with Jest</a>.</li>
<li class="">Eric Clemmons wrote about <a href="https://medium.com/@ericclemmons/jest-snapshots-for-storybook-5bf36b5e5a3a" target="_blank" rel="noopener noreferrer" class="">snapshots and storybook integration</a>.</li>
<li class="">Edvin Erikson wrote about <a href="https://medium.com/@edvinerikson/getting-jest-output-in-tap-format-6e07dc2c484c#.1l4edixhl" target="_blank" rel="noopener noreferrer" class="">getting Tap output in Jest</a>.</li>
<li class=""><a href="https://github.com/guigrpa/jest-html#jest-html--" target="_blank" rel="noopener noreferrer" class="">jest-html</a> can bring snapshot diffing to your browser.</li>
<li class="">There were a few <a href="https://news.ycombinator.com/item?id=13128146" target="_blank" rel="noopener noreferrer" class="">great conversations on hackernews</a> about Jest.</li>
<li class="">The community started a great discussion about the <a href="https://github.com/airbnb/enzyme/issues/715" target="_blank" rel="noopener noreferrer" class="">future of enzyme</a>.</li>
<li class="">Ruben Oostinga wrote about <a href="https://medium.com/@RubenOostinga/combining-chai-and-jest-matchers-d12d1ffd0303#.87si0ra2h" target="_blank" rel="noopener noreferrer" class="">combining chai and Jest matchers</a>.</li>
<li class="">Emil Ong wrote about why <a href="https://engineering.haus.com/why-tdding-your-frontend-feels-pointless-5f710fea7325#.pql79knnm" target="_blank" rel="noopener noreferrer" class="">“TDD'ing your frontend seems pointless”</a>.</li>
<li class="">Nate Hunzaker wrote about <a href="https://www.viget.com/articles/acceptance-testing-react-apps-with-jest-and-nightmare" target="_blank" rel="noopener noreferrer" class="">end-to-end testing with Jest and Nightmare</a>.</li>
<li class=""><a href="https://medium.com/aya-experience/testing-an-angularjs-app-with-jest-3029a613251#.h9badqevy" target="_blank" rel="noopener noreferrer" class="">Using Jest with Angular just works</a> according to Matthieu Lux.</li>
<li class="">A fantastic conversation about the <a href="https://github.com/jestjs/jest/issues/2197" target="_blank" rel="noopener noreferrer" class="">purpose of snapshot testing</a> is happening right now.</li>
<li class="">Dmitrii made a new <a href="https://twitter.com/abramov_dmitrii/status/806613542447157248" target="_blank" rel="noopener noreferrer" class="">music video with his metal band</a>.</li>
<li class=""><a href="https://yarnpkg.com/en/package/lazyspec" target="_blank" rel="noopener noreferrer" class="">lazyspec</a> can help you create smoke tests quickly if you are introducing tests to an existing codebase.</li>
<li class="">Patrick Stapfer did a lightning talk about <a href="https://twitter.com/ryyppy/status/803871975995277312" target="_blank" rel="noopener noreferrer" class="">vim and Jest</a>.</li>
<li class="">Mark Dalgleish was <a href="https://twitter.com/markdalgleish/status/806608159527747584" target="_blank" rel="noopener noreferrer" class="">commenting on the value of snapshot testing</a>.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="new-features-changes-and-fixes-in-jest-17--18">New features, changes and fixes in Jest 17 &amp; 18<a href="https://jestjs.io/blog/2016/12/15/2016-in-jest#new-features-changes-and-fixes-in-jest-17--18" class="hash-link" aria-label="Direct link to New features, changes and fixes in Jest 17 &amp; 18" title="Direct link to New features, changes and fixes in Jest 17 &amp; 18" translate="no">​</a></h2>
<p>Jest was initially created more than five years ago and as such an old framework it has accumulated some technical debt. This is why we tend to make breaking changes more often than may seem necessary: We believe it is important to incrementally reduce technical debt to ensure that Jest as a project stays maintainable long-term. We didn't announce Jest 17 in a blog post and if you haven't upgraded to it in the last month you may find the <a href="https://github.com/jestjs/jest/blob/main/CHANGELOG.md" target="_blank" rel="noopener noreferrer" class="">changelog</a> useful.</p>
<ul>
<li class=""><strong>Breaking:</strong> Removed <code>pit</code> in favor of <code>it</code> or <code>test</code> and <code>mockImpl</code> in favor of <code>jest.fn()</code> or <code>mockImplementation</code> .</li>
<li class=""><strong>Breaking:</strong> Renamed <code>--jsonOutputFile</code> to <code>--outputFile</code>.</li>
<li class=""><strong>Breaking:</strong> Updated <code>testRegex</code> to include <code>test.js</code> and <code>spec.js</code> files.</li>
<li class=""><strong>Breaking:</strong> Replaced <code>scriptPreprocessor</code> with the new <code>transform</code> option.</li>
<li class=""><strong>Breaking:</strong> The <code>testResultsProcessor</code> function is now required to return the modified results.</li>
<li class=""><strong>Potentially Breaking:</strong> Properly resolve <code>snapshotSerializers</code>, <code>setupFiles</code>, <code>transform</code>, <code>testRunner</code> and <code>testResultsProcessor</code> with a resolution algorithm instead of using <code>path.resolve</code>. This mainly means that <code>&lt;rootDir&gt;</code> is no longer needed for these options.</li>
<li class=""><strong>Added:</strong> <code>pretty-format</code> and <code>jest-editor-support</code> were merged into Jest.</li>
<li class=""><strong>Added:</strong> <code>expect.any</code>, <code>expect.anything</code>, <code>expect.objectContaining</code>, <code>expect.arrayContaining</code>, <code>expect.stringMatching</code>.</li>
<li class=""><strong>Added:</strong> <code>--testResultsProcessor</code> is now exposed through the cli.</li>
<li class=""><strong>Added:</strong> Implemented file watching in <code>jest-haste-map</code>.</li>
<li class=""><strong>Added:</strong> Usage of Jest in watch mode can be hidden through <code>JEST_HIDE_USAGE</code>.</li>
<li class=""><strong>Added:</strong> <code>expect.assertions(number)</code> which will ensure that a specified amount of assertions is made in one test.</li>
<li class=""><strong>Added:</strong> <code>.toMatchSnapshot(?string)</code> feature to give snapshots a name.</li>
<li class=""><strong>Added:</strong> <code>toMatchObject</code>, <code>toHaveProperty</code> , <code>toHaveLength</code> matchers.</li>
<li class=""><strong>Added:</strong> <code>expect.extend</code>.</li>
<li class=""><strong>Added:</strong> Added support for custom snapshots serializers.</li>
<li class=""><strong>Added:</strong> Big diffs are now collapsed by default in snapshots and assertions. Added <code>--expand</code> (or <code>-e</code>) to show the full diff.</li>
<li class=""><strong>Added:</strong> <code>jest.resetAllMocks</code> which replaces <code>jest.clearAllMocks</code>.</li>
<li class=""><strong>Added:</strong> <code>--json</code> now includes information about individual tests inside a file.</li>
<li class=""><strong>Fixed:</strong> <code>test.concurrent</code> unhandled promise rejections.</li>
<li class=""><strong>Fixed:</strong> <code>babel-plugin-jest-hoist</code> when using <code>jest.mock</code> with three arguments.</li>
<li class=""><strong>Fixed:</strong> The <code>JSON</code> global in <code>jest-environment-node</code> now comes from the vm context instead of the parent context.</li>
<li class=""><strong>Fixed:</strong> Jest does not print stack traces from babel any longer.</li>
<li class=""><strong>Fixed:</strong> Fake timers are reset when <code>FakeTimers.useTimers()</code> is called.</li>
<li class=""><strong>Fixed:</strong> Regular expressions are properly escaped in snapshots.</li>
<li class=""><strong>Fixed:</strong> Improved pretty printing of large objects.</li>
<li class=""><strong>Fixed:</strong> <code>NaN% Failed</code> in the OS notification when using <code>--notify</code>.</li>
<li class=""><strong>Fixed:</strong> The first test run without cached timings will now use separate processes instead of running in band.</li>
<li class=""><strong>Fixed:</strong> <code>Map</code>/<code>Set</code> comparisons.</li>
<li class=""><strong>Fixed:</strong> <code>test.concurrent</code> now works with <code>--testNamePattern</code>.</li>
<li class=""><strong>Fixed:</strong> Improved <code>.toContain</code> matcher.</li>
<li class=""><strong>Fixed:</strong> Properly resolve modules with platform extensions on react-native.</li>
<li class=""><strong>Fixed:</strong> global built in objects in <code>jest-environment-node</code> now work properly.</li>
<li class=""><strong>Fixed:</strong> Create mock objects in the vm context instead of the parent context.</li>
<li class=""><strong>Fixed:</strong> <code>.babelrc</code> is now part of the transform cache key in <code>babel-jest</code>.</li>
<li class=""><strong>Fixed:</strong> docblock parsing with haste modules.</li>
<li class=""><strong>Fixed:</strong> Exit with the proper code when the coverage threshold is not reached.</li>
<li class=""><strong>Fixed:</strong> Jest now clears the entire scrollback in watch mode.</li>
<li class=""><strong>Deprecated:</strong> <code>jest-react-native</code> was deprecated and now forwards <code>react-native</code>.</li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="plans-for-jest-in-h1-2017">Plans for Jest in H1 2017<a href="https://jestjs.io/blog/2016/12/15/2016-in-jest#plans-for-jest-in-h1-2017" class="hash-link" aria-label="Direct link to Plans for Jest in H1 2017" title="Direct link to Plans for Jest in H1 2017" translate="no">​</a></h2>
<p>Six months ago <a class="" href="https://jestjs.io/blog/2016/07/27/jest-14#what-s-next-for-jest">we shared our plans for Jest</a> and we are happy that we were able to execute well on almost all of them. For the next six months, here is what we are planning:</p>
<ul>
<li class=""><strong>Instant feedback:</strong> <a href="https://nuclide.io/" target="_blank" rel="noopener noreferrer" class="">Nuclide</a> integration and an improved and <a href="https://github.com/jestjs/jest/pull/2324#issuecomment-267149669" target="_blank" rel="noopener noreferrer" class="">faster watch mode</a>.</li>
<li class=""><strong>Improved developer experience:</strong> new mocking APIs and improved assertions.</li>
<li class=""><strong>Better performance and memory usage:</strong> analyze Jest and be more conscious about efficiency.</li>
<li class=""><strong>Snapshot Improvements:</strong> snapshot approval mode, syntax highlighting and improved <code>react-test-renderer</code> APIs.</li>
<li class=""><strong>Website:</strong> We'll overhaul the website and documentation and add a Jest cheat sheet.</li>
</ul>
<p>We won't be providing timelines or estimates for these features and we may not actually get to all of these things. If you'd like to help make these things a reality, send us issues and pull requests with your ideas and let's work on improving Jest together in 2017.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 16.0: Turbocharged CLI & Community Update]]></title>
            <link>https://jestjs.io/blog/2016/10/03/jest-16</link>
            <guid>https://jestjs.io/blog/2016/10/03/jest-16</guid>
            <pubDate>Mon, 03 Oct 2016 00:00:00 GMT</pubDate>
            <description><![CDATA[It's been one month since the last major release and we've made significant improvements to Jest since. In this major release we are updating the snapshot format we are using which will likely require snapshots to be updated when upgrading Jest. We don't make these changes lightly and don't expect this to happen often but we think it is necessary to improve the format from time to time.]]></description>
            <content:encoded><![CDATA[<p>It's been one month since the last major release and we've made significant improvements to Jest since. In this major release we are updating the snapshot format we are using which will likely require snapshots to be updated when upgrading Jest. We don't make these changes lightly and don't expect this to happen often but we think it is necessary to improve the format from time to time.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="upgraded-cli">Upgraded CLI<a href="https://jestjs.io/blog/2016/10/03/jest-16#upgraded-cli" class="hash-link" aria-label="Direct link to Upgraded CLI" title="Direct link to Upgraded CLI" translate="no">​</a></h2>
<p><img decoding="async" loading="lazy" alt="reporter" src="https://jestjs.io/assets/images/16-reporter-578f46980efc5766386bed963d75e333.gif" width="858" height="575" class="img_SS3x"></p>
<p>Jest 16 features a new reporter interface that shows running tests as well as a live summary and a progress bar based on the estimated test runtime from previous test runs. We also improved the CLI output to work better with different color schemes. If there were test failures in a previous run, Jest will now always run those tests first to give useful signal to users as quickly as possible.</p>
<p>We also added a lot of new features which you may find useful:</p>
<ul>
<li class="">New CLI flags were added: A <code>--testNamePattern=pattern</code> or <code>-t &lt;pattern&gt;</code> option was added to filter tests from the command line much like <code>it.only</code> or <code>fit</code> does in tests.</li>
<li class="">Previously failed tests now always run first.</li>
<li class=""><code>jest &lt;pattern&gt;</code> is now case-insensitive to make it easier to filter test files.</li>
<li class="">A test run in watch mode can now be interrupted. During a test run, simply press any of the keys used for input during watch mode (<code>a</code>, <code>o</code>, <code>p</code>, <code>q</code> or <code>enter</code>) to abort a test run and start a new one.</li>
<li class="">The <code>--bail</code> flag now also works in watch mode. Together with running failed tests first, Jest's watch mode will now feel turbocharged!</li>
<li class="">Jest now automatically considers files and tests with the <code>jsx</code> extension.</li>
<li class="">Jest warns about duplicate manual mock files and we improved automatically created mocks for ES modules compiled with babel.</li>
<li class="">A <code>jest.clearAllMocks</code> function was added to clear all mocks in between tests.</li>
<li class="">We improved module resolution when <code>moduleNameMapper</code> is used.</li>
<li class="">Finally, a <code>--findRelatedTests &lt;fileA&gt; &lt;fileB&gt;</code> cli option was added to run tests related to the specified files. This is especially helpful as a pre-commit hook if you'd like to run tests only on a specified set of files that have tests associated with them.</li>
</ul>
<p>This is what Jest looks like when a test run is interrupted in watch mode: <img decoding="async" loading="lazy" alt="watch" src="https://jestjs.io/assets/images/16-watch-db5e0e957c19a9b2499e018c81762993.gif" width="858" height="575" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="snapshot-updates">Snapshot Updates<a href="https://jestjs.io/blog/2016/10/03/jest-16#snapshot-updates" class="hash-link" aria-label="Direct link to Snapshot Updates" title="Direct link to Snapshot Updates" translate="no">​</a></h2>
<p>Jest's snapshot implementation was completely rewritten. The new version of the <code>jest-snapshot</code> package is now structured in a way that allows for easier integration into other test runners and enables more cool integrations like with <a href="https://voice.kadira.io/snapshot-testing-in-react-storybook-43b3b71cec4f#.qh4lzcadb" target="_blank" rel="noopener noreferrer" class="">React Storybook</a>. Jest doesn't mark snapshots as obsolete in a file with skipped or failing tests. We also made a number of changes to the snapshot format:</p>
<ul>
<li class="">Objects and Arrays are now printed with a trailing comma to minimize future changes to snapshots.</li>
<li class="">We removed function names from snapshots. They were causing issues with different versions of Node, with code coverage instrumentation and we generally felt like it wasn't useful signal to show to the user that the name of a function has changed.</li>
<li class="">Snapshots are now sorted using natural sort order within a file.</li>
</ul>
<p>When upgrading to Jest 16, the diff might look similar to this one: <img decoding="async" loading="lazy" alt="snapshots" src="https://jestjs.io/assets/images/16-snapshots-3d7a3fd47cdb15728ac038948a21d2b7.png" width="1924" height="1360" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="test-library-updates">Test Library Updates<a href="https://jestjs.io/blog/2016/10/03/jest-16#test-library-updates" class="hash-link" aria-label="Direct link to Test Library Updates" title="Direct link to Test Library Updates" translate="no">​</a></h2>
<p>We finished the migration of Jasmine assertions to the new Jest matchers. We added three new matchers: <code>toBeInstanceOf</code>, <code>toContainEqual</code> and <code>toThrowErrorMatchingSnapshot</code> . We have more readable failure messages for the spy/mock matchers <code>toHaveBeenLastCalledWith</code>, <code>toHaveBeenCalledWith</code>, <code>lastCalledWith</code> and <code>toBeCalledWith</code>. Now that we have rewritten all assertions and separated them into their own package, we'll be working on making them standalone so they can be integrated into any test framework if you'd like to use them outside of Jest.</p>
<p>We also added a bunch of aliases that were requested by the community. To make Jest focus on a single test you can now use either <code>it.only</code> or <code>test.only</code> or keep using <code>fit</code>; For skipping a test, <code>it.skip</code> or <code>test.skip</code> are now available alongside of <code>xit</code>; finally to define a test as concurrent you can use <code>test.concurrent</code> which is useful in case your test accesses network resources or databases.</p>
<p>Finally, if you'd like to overwrite the <code>expect</code> global with a different assertion library like <a href="http://chaijs.com/" target="_blank" rel="noopener noreferrer" class="">chai</a>, this can now be done using the <code>setupTestFrameworkScriptFile</code> configuration option.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="community-update">Community Update<a href="https://jestjs.io/blog/2016/10/03/jest-16#community-update" class="hash-link" aria-label="Direct link to Community Update" title="Direct link to Community Update" translate="no">​</a></h2>
<p>Over the last month lots of articles were written about Jest's snapshot testing feature, how to migrate to Jest and how to get started writing tests. I also did a few live videos to explain how Jest and snapshot testing works:</p>
<ul>
<li class=""><a href="https://www.facebook.com/react/videos/1035427199869020/" target="_blank" rel="noopener noreferrer" class="">FB Live Video about Snapshot Testing</a>.</li>
<li class=""><a href="https://www.youtube.com/watch?v=i31VtyJSM-I&amp;feature=youtu.be" target="_blank" rel="noopener noreferrer" class="">JavaScript &amp; React Testing with Kent C. Dodds</a>.</li>
</ul>
<p>A number of people wrote articles about snapshot testing. The most opinionated article that resonated with the Jest team was “<a href="http://benmccormick.org/2016/09/19/testing-with-jest-snapshots-first-impressions/" target="_blank" rel="noopener noreferrer" class="">Testing with Jest Snapshots: First Impressions</a>”. Ben makes three great points in his blog post:</p>
<ol>
<li class="">Snapshot tests are a complement for conventional tests not a replacement.</li>
<li class="">Snapshot tests are more useful with a healthy code review process.</li>
<li class="">Snapshot tests work well with auto-mocking.</li>
</ol>
<p>We highly recommend reading the entire blog post. Ben did a fantastic job explaining the reasons why we built snapshot testing. It's important to point out that we didn't introduce snapshot testing to replace all other forms of testing but rather as a way to enable engineers to write tests for code that they otherwise wouldn't write tests for. It works well for things like React components, CLI output, error messages and many others but it doesn't solve all problems. Jest's goal is to provide many different ways to write effective tests without sacrificing performance or the project's maintainability.</p>
<p>Other highlights about snapshot testing:</p>
<ul>
<li class="">A React Native testing series: <a href="https://blog.callstack.io/unit-testing-react-native-with-the-new-jest-i-snapshots-come-into-play-68ba19b1b9fe" target="_blank" rel="noopener noreferrer" class="">Part 1: Jest – Snapshot come into play</a> and <a href="https://blog.callstack.io/unit-testing-react-native-with-the-new-jest-ii-redux-snapshots-for-your-actions-and-reducers-8559f6f8050b#.putt9eipm" target="_blank" rel="noopener noreferrer" class="">Part 2: Jest – Redux Snapshots for your Actions and Reducers</a>.</li>
<li class=""><a href="https://blog.grommet.io/post/2016/09/01/how-we-landed-on-jest-snapshot-testing-for-javascript" target="_blank" rel="noopener noreferrer" class="">How we landed on Jest snapshot testing for JavaScript</a>.</li>
<li class=""><a href="http://guigrpa.github.io/2016/09/27/picture-this-snapshot-testing/" target="_blank" rel="noopener noreferrer" class="">Picture This: Snapshot Testing</a>.</li>
<li class=""><a href="https://voice.kadira.io/snapshot-testing-in-react-storybook-43b3b71cec4f" target="_blank" rel="noopener noreferrer" class="">Snapshot testing with React Storybook</a>.</li>
<li class=""><a href="https://medium.com/@ryancollinsio/testing-react-redux-applications-fee79ac0087f#.lyjl7st1n" target="_blank" rel="noopener noreferrer" class="">Testing React and Redux Applications</a>.</li>
<li class="">If you are using the popular <a href="https://github.com/airbnb/enzyme" target="_blank" rel="noopener noreferrer" class="">enzyme</a> testing utility, there is now a project <a href="https://github.com/trayio/enzyme-to-json" target="_blank" rel="noopener noreferrer" class="">enzyme-to-json</a> which makes it possible to use Jest's snapshot testing feature together with enzyme.</li>
</ul>
<p><a href="https://github.com/reactjs/redux/commit/7296d3cba1f5f899bdee5ef6695a8d21149f8d6c" target="_blank" rel="noopener noreferrer" class="">Redux itself now uses Jest</a> and Max Stoiber wrote a <a href="http://academy.plot.ly/react/6-testing/" target="_blank" rel="noopener noreferrer" class="">tutorial on how to test code written with redux</a>. There is also a great <a href="https://semaphoreci.com/community/tutorials/how-to-test-react-and-mobx-with-jest" target="_blank" rel="noopener noreferrer" class="">guide on how to write tests for MobX</a>. If you are using <a href="https://github.com/facebookincubator/create-react-app" target="_blank" rel="noopener noreferrer" class="">create-react-app</a>, Jest is now included by default. Kent C. Dodds created a ton of <a href="https://egghead.io/lessons/javascript-use-jest-s-snapshot-testing-feature?pl=testing-javascript-with-jest-a36c4074" target="_blank" rel="noopener noreferrer" class="">videos on egghead.io</a> that will help you get started with Jest.</p>
<p>If you are using other test runners, Kenneth Skovhus built an awesome <a href="https://github.com/skovhus/jest-codemods" target="_blank" rel="noopener noreferrer" class="">jest-codemods</a> library that will automate the conversion for you. Codemods are awesome: they'll allow you to quickly evaluate whether Jest will work for you. Give it a try!</p>
<p>The full <a href="https://github.com/jestjs/jest/blob/main/CHANGELOG.md#jest-1600" target="_blank" rel="noopener noreferrer" class="">changelog can be found on GitHub</a>. Jest 16 was a true JavaScript community effort and the project now has more than 220 contributors. We thank each and every one of you for your help to make this project great.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 15.0: New Defaults for Jest]]></title>
            <link>https://jestjs.io/blog/2016/09/01/jest-15</link>
            <guid>https://jestjs.io/blog/2016/09/01/jest-15</guid>
            <pubDate>Thu, 01 Sep 2016 00:00:00 GMT</pubDate>
            <description><![CDATA[We spent the past year making Jest faster, easier to configure, added tons of features and built snapshot testing. However, there were two areas where we invested very little we can move fast and improve the framework for Facebook and the open source community at light-speed. Jest's goal is to come with batteries included and to require as little configuration as necessary. We recently got a chance to explain our philosophy on a create-react-app issue.]]></description>
            <content:encoded><![CDATA[<p>We spent the past year making Jest <a class="" href="https://jestjs.io/blog/2016/03/11/javascript-unit-testing-performance">faster</a>, <a class="" href="https://jestjs.io/blog/2016/04/12/jest-11">easier to configure</a>, <a class="" href="https://jestjs.io/blog/2016/06/22/jest-13">added tons of features</a> and built <a class="" href="https://jestjs.io/blog/2016/07/27/jest-14">snapshot testing</a>. However, there were two areas where we invested very little: the CLI output and user experience. With Jest 15 we are changing the framework radically to make it easier to use both for beginners and experienced users. We are excited that our investment in Jest is now paying off: we can move fast and improve the framework for Facebook and the open source community at light-speed. Jest's goal is to come with batteries included and to require as little configuration as necessary. We recently got a chance to explain our philosophy on a <a href="https://github.com/facebookincubator/create-react-app/pull/250#issuecomment-237098619" target="_blank" rel="noopener noreferrer" class="">create-react-app issue</a>.</p>
<p>The most important change to talk about is a set of <a href="https://github.com/jestjs/jest/pull/1511" target="_blank" rel="noopener noreferrer" class="">new defaults</a>. If you are an existing Jest user you will very likely need to update your configuration for Jest 15. In most cases it will simplify your setup and Jest will provide useful error messages during the upgrade. All of the new defaults can be disabled to suit your needs, but we still consider the disabled features critical for Jest in certain situations and will continue to use and support them at Facebook long-term. Our <a class="" href="https://jestjs.io/docs/api">API documentation</a> was also completely rewritten to reflect these changes. <a href="https://github.com/facebook/react/pull/7625/files" target="_blank" rel="noopener noreferrer" class="">This pull request for React</a> highlights some of the changes necessary for existing projects.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="new-cli-error-messages-and-summaries">New CLI error messages and summaries<a href="https://jestjs.io/blog/2016/09/01/jest-15#new-cli-error-messages-and-summaries" class="hash-link" aria-label="Direct link to New CLI error messages and summaries" title="Direct link to New CLI error messages and summaries" translate="no">​</a></h2>
<p>As part of our effort to remove Jasmine incrementally within Jest, replacing all Jasmine matchers was almost completed. A lot of time was spent tweaking every error message for every matcher to give the best signal to users when a test is failing – the time when Jest should provide the most value to you. In addition to printing the expected and received values, a diff is printed for the <code>toBe</code> and <code>toEqual</code> matchers to help spot mistakes. More colors were added and relevant files from stack traces are highlighted more prominently.</p>
<p>Here is a comparison of the before and after on a light terminal: <img decoding="async" loading="lazy" alt="failure1" src="https://jestjs.io/assets/images/15-failure1-18a216b24eb5641ffe2f700795be8738.png" width="2414" height="1422" class="img_SS3x"> It also works well with darker colors: <img decoding="async" loading="lazy" alt="failure2" src="https://jestjs.io/assets/images/15-failure2-0638fb4e0e8ef964763fab8c4bebd23c.png" width="2442" height="850" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="new-watch-command">New watch command<a href="https://jestjs.io/blog/2016/09/01/jest-15#new-watch-command" class="hash-link" aria-label="Direct link to New watch command" title="Direct link to New watch command" translate="no">​</a></h2>
<p>We completely rewrote <code>jest --watch</code> to be more interactive. It can now switch between running all tests or only test files related to changed files by pressing <code>a</code> or <code>o</code>. By pressing <code>p</code> a prompt appears that allows to specify a test pattern to focus on a specific set of files. Snapshot tests can be updated by pressing <code>u</code>.</p>
<p><img decoding="async" loading="lazy" alt="watch" src="https://jestjs.io/assets/images/15-watch-951ac33b263d3ee8522e35b8836b1f88.gif" width="858" height="575" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="jest-react-native-improvements">jest-react-native improvements<a href="https://jestjs.io/blog/2016/09/01/jest-15#jest-react-native-improvements" class="hash-link" aria-label="Direct link to jest-react-native improvements" title="Direct link to jest-react-native improvements" translate="no">​</a></h2>
<p>Mocks for <code>ListView</code>, <code>TextInput</code>, <code>ActivityIndicator</code>, <code>ScrollView</code> and more were added. The existing mocks were updated to use the real implementations and existing snapshots likely have to be updated when upgrading to Jest 15. A <code>mockComponent</code> function was added to <code>jest-react-native</code> that can be used to mock native components:</p>
<div class="language-js codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-js codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token plain">jest</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">mock</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'MyNativeComponent'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#888">=&gt;</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword" style="color:#297a29">const</span><span class="token plain"> jestReactNative </span><span class="token operator" style="color:#888">=</span><span class="token plain"> </span><span class="token function" style="color:#6b2e85">require</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'jest-react-native'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword control-flow" style="color:#297a29">return</span><span class="token plain"> jestReactNative</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">mockComponent</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'MyNativeComponent'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p>There have also been a number of improvements around mocking images, the fetch module and other native APIs.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="buffered-console-messages">Buffered Console Messages<a href="https://jestjs.io/blog/2016/09/01/jest-15#buffered-console-messages" class="hash-link" aria-label="Direct link to Buffered Console Messages" title="Direct link to Buffered Console Messages" translate="no">​</a></h2>
<p>Jest parallelizes test runs across workers to maximize performance. Previously Jest used to forward console messages from workers to the parent and printed them immediately. When running multiple tests in parallel, it was often hard to find out which test and which module was calling a log function. In Jest 15, all console messages are buffered and printed together with individual test results. In addition the file and line number of the log call is printed so the code can easily be inspected.</p>
<p>Compare the output of the previous version of Jest and Jest 15: <img decoding="async" loading="lazy" alt="console" src="https://jestjs.io/assets/images/15-console-5050b2c2d39cedc5bff49baa56bb78a3.png" width="2358" height="1162" class="img_SS3x"></p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="disabled-automocking">Disabled Automocking<a href="https://jestjs.io/blog/2016/09/01/jest-15#disabled-automocking" class="hash-link" aria-label="Direct link to Disabled Automocking" title="Direct link to Disabled Automocking" translate="no">​</a></h2>
<p>Automocking is now disabled by default in Jest. This is by far the most confusing feature for new users and in many ways it doesn't make sense for small projects. We introduced automocking at Facebook and it worked great for us when unit testing was adopted in a large existing code base with few existing tests, but over time it felt like people spent more time fighting with mocked/unmocked modules than it would have taken them to write a test normally. We also noticed that library authors often require a huge number of basic modules that always have to be manually unmocked. Even for Jest itself we realized that the majority of tests had automocking disabled manually. We still believe that explicit automocking can be incredibly valuable. This change simply trades implicit mocks for explicit mocks via calls to <code>jest.mock(moduleName)</code>.</p>
<p>If you would still like to use automocking by default, enable the <code>automock</code> setting in your configuration or manually call <code>jest.enableAutomock()</code> in your test or setup file.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="test-file-patterns">Test File Patterns<a href="https://jestjs.io/blog/2016/09/01/jest-15#test-file-patterns" class="hash-link" aria-label="Direct link to Test File Patterns" title="Direct link to Test File Patterns" translate="no">​</a></h2>
<p>Not everyone uses the same convention of using a <code>__tests__</code> folder to store tests. Jest 15 also looks for files ending in <code>.spec.js</code> or <code>.test.js</code>, two popular community standards. Jest 15 also removes the <code>testDirectoryName</code> and <code>testFileExtensions</code> configuration options and asks users to switch to the <code>testRegex</code> option when the old configuration options are used.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="module-registry-persistence">Module Registry Persistence<a href="https://jestjs.io/blog/2016/09/01/jest-15#module-registry-persistence" class="hash-link" aria-label="Direct link to Module Registry Persistence" title="Direct link to Module Registry Persistence" translate="no">​</a></h2>
<p>Jest used to implicitly reset all modules before each test and we recommended requiring modules in <code>beforeEach</code> or inside of tests. This is useful when modules have local state that shouldn't be shared between tests. However, two big shifts happened: ES modules with the top-level <code>import</code> syntax and a renewed interest in writing stateless functional modules.</p>
<p>This has lead to numerous incompatibilities. We also noticed that at Facebook we weren't even using this implicit reset. Instead we relied on explicit calls to <code>jest.resetModules()</code> which puts engineers in control on when to wipe away all state.</p>
<p>Here is an example:</p>
<div class="language-js codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-js codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token keyword" style="color:#297a29">const</span><span class="token plain"> </span><span class="token maybe-class-name">React1</span><span class="token plain"> </span><span class="token operator" style="color:#888">=</span><span class="token plain"> </span><span class="token function" style="color:#6b2e85">require</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'react'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">jest</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">resetModules</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#297a29">const</span><span class="token plain"> </span><span class="token maybe-class-name">React2</span><span class="token plain"> </span><span class="token operator" style="color:#888">=</span><span class="token plain"> </span><span class="token function" style="color:#6b2e85">require</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'react'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token maybe-class-name">React1</span><span class="token plain"> </span><span class="token operator" style="color:#888">!==</span><span class="token plain"> </span><span class="token maybe-class-name">React2</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// These two are separate copies of React.</span><br></span></code></pre></div></div>
<p>The call to <code>resetModules</code> wipes away the require cache. A second call to require the same module will result in a new instantiation of the same module and all of its dependencies. This feature is especially useful when dealing with modules that have side effects, like <a href="https://github.com/jestjs/jest/blob/3bbf32a239fc4aad8cc6928a787f235bd86fecac/packages/jest-haste-map/src/__tests__/index-test.js#L64" target="_blank" rel="noopener noreferrer" class="">jest-haste-map</a>.</p>
<p>We believe it is better to put users in control so we disabled the implicit reset. Modules can be reset using <code>jest.resetModules()</code> in code and the <code>resetModules</code> option can be enabled in the configuration to bring back the previous behavior.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="real-vs-fake-timers">Real vs Fake Timers<a href="https://jestjs.io/blog/2016/09/01/jest-15#real-vs-fake-timers" class="hash-link" aria-label="Direct link to Real vs Fake Timers" title="Direct link to Real vs Fake Timers" translate="no">​</a></h2>
<p>By default Jest used to mock all timer functions like <code>setTimeout</code> or <code>process.nextTick</code> and provided an API <code>jest.runAllTimers()</code> to advance timers programmatically. This is useful when a piece of code sets a long timeout that we don't want to wait for in a test.</p>
<p>However we found that most of the time the use cases are quite isolated. <a class="" href="https://jestjs.io/docs/tutorial-async">Async programming</a> has also become much simpler in our test runner. Jest now uses the real timers by default.</p>
<p>You can still override this by specifying <code>"timers": "fake"</code> in the configuration or by calling <code>jest.useRealTimers()</code> and <code>jest.useFakeTimers()</code> global switches.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="setupenvscriptfile-vs-setupfiles">setupEnvScriptFile vs setupFiles<a href="https://jestjs.io/blog/2016/09/01/jest-15#setupenvscriptfile-vs-setupfiles" class="hash-link" aria-label="Direct link to setupEnvScriptFile vs setupFiles" title="Direct link to setupEnvScriptFile vs setupFiles" translate="no">​</a></h2>
<p>The <code>setupEnvScriptFile</code> configuration option has been deprecated for a while. Jest 15 removes it completely and replaces it with <code>setupFiles</code>. This option expects an array of file paths that are loaded in order before a test file is executed.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="rewritten-code-coverage-support">Rewritten Code Coverage Support<a href="https://jestjs.io/blog/2016/09/01/jest-15#rewritten-code-coverage-support" class="hash-link" aria-label="Direct link to Rewritten Code Coverage Support" title="Direct link to Rewritten Code Coverage Support" translate="no">​</a></h2>
<p>Code coverage in Jest can be used through <code>jest --coverage</code> and requires no additional packages or configuration. Code coverage support was completely rewritten and a new <code>collectCoverageFrom</code> option was added to collect code coverage information from entire projects, including <strong>untested files</strong>. Note that this option uses globs as we are hoping to further simplify configuration options in the future and provide a simpler alternative to regular expressions. See Jest's <a href="https://github.com/jestjs/jest/blob/9088f6517813f6c089cf52e980d6579511dcde88/package.json#L47" target="_blank" rel="noopener noreferrer" class="">package.json</a> for an example.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="other-improvements">Other Improvements<a href="https://jestjs.io/blog/2016/09/01/jest-15#other-improvements" class="hash-link" aria-label="Direct link to Other Improvements" title="Direct link to Other Improvements" translate="no">​</a></h2>
<p>A huge number of other improvements were also made:</p>
<ul>
<li class="">Improved performance of small test runs.</li>
<li class="">Jest now uses verbose mode when only a single test file is executed.</li>
<li class="">Added an <code>--env</code> option to override the configured test environment.</li>
<li class=""><code>moduleNameMapper</code> now uses a resolution algorithm.</li>
<li class="">Jest now works with paths that have special characters in them, like parenthesis.</li>
<li class="">Added <code>global.global</code> to the node environment.</li>
<li class="">Fixed <code>babel-plugin-jest-hoist</code>'s invalid error when a random user function was called <code>mock</code>.</li>
<li class="">Fix <code>testEnvironment</code> resolution to prefer <code>jest-environment-{name}</code> instead of <code>{name}</code> only. This prevents a module collision when using <code>jsdom</code> as test environment.</li>
<li class="">Improvements to Jest's own test infra by merging integration and unit tests. Code coverage is now collected for Jest.</li>
</ul>
<p>We are happy when looking back at all the changes we have made together with the help from the community and couldn't be more excited to make Jest even better over the course of the next few months. Please <a href="https://github.com/jestjs/jest/issues" target="_blank" rel="noopener noreferrer" class="">file an issue</a> if something isn't working as expected and send us pull requests.</p>
<p>Next up: <a href="https://github.com/jestjs/jest/pull/1480" target="_blank" rel="noopener noreferrer" class="">Concurrent Reporter</a>.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 14.0: React Tree Snapshot Testing]]></title>
            <link>https://jestjs.io/blog/2016/07/27/jest-14</link>
            <guid>https://jestjs.io/blog/2016/07/27/jest-14</guid>
            <pubDate>Wed, 27 Jul 2016 00:00:00 GMT</pubDate>
            <description><![CDATA[One of Jest's philosophies is to provide an integrated “zero-configuration” experience. We want to make it as frictionless as possible to write good tests that are useful. We observed that when engineers are provided with ready-to-use tools, they end up writing more tests, which in turn results in stable and healthy code bases.]]></description>
            <content:encoded><![CDATA[<p>One of Jest's philosophies is to provide an integrated “zero-configuration” experience. We want to make it as frictionless as possible to write good tests that are useful. We observed that when engineers are provided with ready-to-use tools, they end up writing more tests, which in turn results in stable and healthy code bases.</p>
<p>One of the big open questions was how to write React tests efficiently. There are plenty of tools such as <a href="https://facebook.github.io/react/docs/test-utils.html" target="_blank" rel="noopener noreferrer" class="">ReactTestUtils</a> and <a href="https://enzymejs.github.io/enzyme/" target="_blank" rel="noopener noreferrer" class="">enzyme</a>. Both of these tools are great and are actively being used. However engineers frequently told us that they spend more time writing a test than the component itself. As a result many people stopped writing tests altogether which eventually led to instabilities. Engineers told us all they wanted was to make sure their components don't change unexpectedly.</p>
<p>Together with the React team we created a new test renderer for React and added snapshot testing to Jest. Consider this <a href="https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/link.test.js" target="_blank" rel="noopener noreferrer" class="">example test</a> for a simple <a href="https://github.com/jestjs/jest/blob/main/examples/snapshot/Link.js" target="_blank" rel="noopener noreferrer" class="">Link component</a>:</p>
<div class="language-javascript codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-javascript codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token keyword module" style="color:#297a29">import</span><span class="token plain"> </span><span class="token imports">renderer</span><span class="token plain"> </span><span class="token keyword module" style="color:#297a29">from</span><span class="token plain"> </span><span class="token string" style="color:#c21325">'react-test-renderer'</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#6b2e85">test</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#c21325">'Link renders correctly'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#888">=&gt;</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token keyword" style="color:#297a29">const</span><span class="token plain"> tree </span><span class="token operator" style="color:#888">=</span><span class="token plain"> renderer</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token operator" style="color:#888">&lt;</span><span class="token maybe-class-name">Link</span><span class="token plain"> page</span><span class="token operator" style="color:#888">=</span><span class="token string" style="color:#c21325">"http://www.facebook.com"</span><span class="token operator" style="color:#888">&gt;</span><span class="token maybe-class-name">Facebook</span><span class="token operator" style="color:#888">&lt;</span><span class="token operator" style="color:#888">/</span><span class="token maybe-class-name">Link</span><span class="token operator" style="color:#888">&gt;</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">toJSON</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token function" style="color:#6b2e85">expect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">tree</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#6b2e85">toMatchSnapshot</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p>The first time this test is run, Jest creates a <a href="https://github.com/jestjs/jest/blob/main/examples/snapshot/__tests__/__snapshots__/link.test.js.snap" target="_blank" rel="noopener noreferrer" class="">snapshot file</a> that looks like this:</p>
<div class="language-javascript codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-javascript codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token plain">exports</span><span class="token punctuation" style="color:#393A34">[</span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token template-string string" style="color:#c21325">Link renders correctly 1</span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token operator" style="color:#888">=</span><span class="token plain"> </span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token template-string string" style="color:#c21325"></span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">&lt;a</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  className="normal"</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  href="http://www.facebook.com"</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  onMouseEnter={[Function bound _onMouseEnter]}</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  onMouseLeave={[Function bound _onMouseLeave]}&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">  Facebook</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325">&lt;/a&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token template-string string" style="color:#c21325"></span><span class="token template-string template-punctuation string" style="color:#c21325">`</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre></div></div>
<p>The snapshot artifact should be committed alongside code changes. We use <a href="https://github.com/thejameskyle/pretty-format" target="_blank" rel="noopener noreferrer" class="">pretty-format</a> to make snapshots human-readable during code review. On subsequent test runs Jest will simply compare the rendered output with the previous snapshot. If they match, the test will pass. If they don't match, either the implementation has changed and the snapshot needs to be updated with <code>jest -u</code>, or the test runner found a bug in your code that should be fixed.</p>
<p>If we change the address the Link component in our example is pointing to, Jest will print this output:</p>
<p><img decoding="async" loading="lazy" alt="snapshot-testing" src="https://jestjs.io/assets/images/snapshot-8de6b9bafc9754f21e3c61604fc0623c.png" width="1450" height="546" class="img_SS3x"></p>
<p>Now you know that you either need to accept the changes with <code>jest -u</code>, or fix the component if the changes were unintentional. To try out this functionality, please clone the <a href="https://github.com/jestjs/jest/tree/main/examples/snapshot" target="_blank" rel="noopener noreferrer" class="">snapshot example</a>, modify the Link component and run Jest. We updated the <a class="" href="https://jestjs.io/docs/tutorial-react">React Tutorial</a> with a new guide for snapshot testing.</p>
<p>This feature was built by <a href="https://twitter.com/soprano" target="_blank" rel="noopener noreferrer" class="">Ben Alpert</a> and <a href="https://twitter.com/kentaromiura" target="_blank" rel="noopener noreferrer" class="">Cristian Carlesso</a>.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="experimental-react-native-support">Experimental React Native support<a href="https://jestjs.io/blog/2016/07/27/jest-14#experimental-react-native-support" class="hash-link" aria-label="Direct link to Experimental React Native support" title="Direct link to Experimental React Native support" translate="no">​</a></h2>
<p>By building a test renderer that targets no specific platform we are finally able to support a full, unmocked version of React Native. We are excited to launch experimental React Native support for Jest through the <code>jest-react-native</code> package.</p>
<p>You can start using Jest with react-native by running <code>yarn add --dev jest-react-native</code> and by adding the preset to your Jest configuration:</p>
<div class="language-json codeBlockContainer_mQmQ theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f6f6"><div class="codeBlockContent_t_Hd"><pre tabindex="0" class="prism-code language-json codeBlock_RMoD thin-scrollbar" style="color:#393A34;background-color:#f6f6f6"><code class="codeBlockLines_AclH"><span class="token-line" style="color:#393A34"><span class="token property" style="color:#82772c">"jest"</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token property" style="color:#82772c">"preset"</span><span class="token operator" style="color:#888">:</span><span class="token plain"> </span><span class="token string" style="color:#c21325">"jest-react-native"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></span></code></pre></div></div>
<ul>
<li class=""><a class="" href="https://jestjs.io/docs/tutorial-react-native#content">Tutorial and setup guide</a></li>
<li class=""><a href="https://github.com/jestjs/jest/tree/main/examples/react-native" target="_blank" rel="noopener noreferrer" class="">Example project</a></li>
<li class=""><a href="https://github.com/bartonhammond/snowflake/pull/110" target="_blank" rel="noopener noreferrer" class="">Example pull request for <em>snowflake</em></a>, a popular react-native open source library.</li>
</ul>
<div class="theme-admonition theme-admonition-info admonition_WCGJ alert alert--info"><div class="admonitionHeading_GCBg"><span class="admonitionIcon_L39b"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>info</div><div class="admonitionContent_pbrs"><p>The preset currently only implements the minimal set of configuration necessary to get started with React Native testing. We are hoping for community contributions to improve this project. Please try it and file <a href="https://github.com/jestjs/jest/issues" target="_blank" rel="noopener noreferrer" class="">issues</a> or send pull requests!</p></div></div>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="why-snapshot-testing">Why snapshot testing?<a href="https://jestjs.io/blog/2016/07/27/jest-14#why-snapshot-testing" class="hash-link" aria-label="Direct link to Why snapshot testing?" title="Direct link to Why snapshot testing?" translate="no">​</a></h2>
<p>For Facebook's native apps we use a system called “snapshot testing”: a snapshot test system that renders UI components, takes a screenshot and subsequently compares a recorded screenshot with changes made by an engineer. If the screenshots don't match, there are two possibilities: either the change is unexpected or the screenshot can be updated to the new version of the UI component.</p>
<p>While this was the solution we wanted for the web, we also found many problems with such end-to-end tests that snapshot integration tests solve:</p>
<ul>
<li class=""><strong>No flakiness:</strong> Because tests are run in a command line runner instead of a real browser or on a real phone, the test runner doesn't have to wait for builds, spawn browsers, load a page and drive the UI to get a component into the expected state which tends to be flaky and the test results become noisy.</li>
<li class=""><strong>Fast iteration speed:</strong> Engineers want to get results in less than a second rather than waiting for minutes or even hours. If tests don't run quickly like in most end-to-end frameworks, engineers don't run them at all or don't bother writing them in the first place.</li>
<li class=""><strong>Debugging:</strong> It's easy to step into the code of an integration test in JS instead of trying to recreate the screenshot test scenario and debugging what happened in the visual diff.</li>
</ul>
<p>Because we believe snapshot testing can be useful beyond Jest we split the feature into a <a href="https://github.com/jestjs/jest/tree/main/packages/jest-snapshot" target="_blank" rel="noopener noreferrer" class="">jest-snapshot</a> package. We are happy to work with the community to make it more generic so it can be integrated with other test runners and share concepts and infrastructure with each other.</p>
<p>Finally, here is a quote of a Facebook engineer describing how snapshot testing changed his unit testing experience:</p>
<blockquote>
<p>“One of the most challenging aspects of my project was keeping the input and output files for each test case in sync. Each little change in functionality could cause all the output files to change. With snapshot testing I do not need the output files, the snapshots are generated for free by Jest! I can simply inspect how Jest updates the snapshots rather than making the changes manually.” – <a href="https://github.com/kyldvs" target="_blank" rel="noopener noreferrer" class="">Kyle Davis</a> working on <a href="https://github.com/kyldvs/fjs" target="_blank" rel="noopener noreferrer" class="">fjs</a>.</p>
</blockquote>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="whats-next-for-jest">What's next for Jest<a href="https://jestjs.io/blog/2016/07/27/jest-14#whats-next-for-jest" class="hash-link" aria-label="Direct link to What's next for Jest" title="Direct link to What's next for Jest" translate="no">​</a></h2>
<p>Recently <a href="https://twitter.com/aarondjents" target="_blank" rel="noopener noreferrer" class="">Aaron Abramov</a> has joined the Jest team full time to improve our unit and integration test infrastructure for Facebook's ads products. For the next few months the Jest team is planning major improvements in these areas:</p>
<ul>
<li class=""><strong>Replace Jasmine:</strong> Jasmine is slowing us down and is not being very actively developed. We started replacing all the Jasmine matchers and are excited to add new features and drop this dependency.</li>
<li class=""><strong>Code Coverage:</strong> When Jest was originally created, tools such as babel didn't exist. Our code coverage support has a bunch of edge cases and isn't always working properly. We are rewriting it to address all the current problems with coverage.</li>
<li class=""><strong>Developer Experience:</strong> This ranges from improving the setup process, the debugging experience to CLI improvements and more documentation.</li>
<li class=""><strong>Mocking:</strong> The mocking system, especially around manual mocks, is not working well and is confusing. We hope to make it more strict and easier to understand.</li>
<li class=""><strong>Performance:</strong> Further performance improvements especially for really large codebases are being worked on.</li>
</ul>
<p>As always, if you have questions or if you are excited to help out, please reach out to us!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest 13.0: Flow & REPL]]></title>
            <link>https://jestjs.io/blog/2016/06/22/jest-13</link>
            <guid>https://jestjs.io/blog/2016/06/22/jest-13</guid>
            <pubDate>Wed, 22 Jun 2016 00:00:00 GMT</pubDate>
            <description><![CDATA[Today we are happy to announce the next major release of Jest. We have made major changes to Jest which are going to benefit you and all of Facebook's JavaScript test infrastructure. Most importantly, we added static types to all of Jest's code during a recent Jest hackathon at Facebook. Fifteen people worked for a day and night to add Flow types to Jest and to add new features to Jest. The Flow types serve two purposes: First, we believe that code is written to be read. Most of the time, code is written only once but read by dozens of people over the course of years. Adding static types to the project helps document the code and helps explain some of the architecture in Jest. Second, adding static types makes maintenance easier and will allow us to more confidently refactor parts of Jest without fear of breakages.]]></description>
            <content:encoded><![CDATA[<p>Today we are happy to announce the next major release of Jest. We have made major changes to Jest which are going to benefit you and all of Facebook's JavaScript test infrastructure. Most importantly, we added static types to all of Jest's code during a recent Jest hackathon at Facebook. Fifteen people worked for a day and night to add <a href="https://flowtype.org/" target="_blank" rel="noopener noreferrer" class="">Flow</a> types to Jest and to add new features to Jest. The Flow types serve two purposes: First, we believe that code is written to be read. Most of the time, code is written only once but read by dozens of people over the course of years. Adding static types to the project helps document the code and helps explain some of the architecture in Jest. Second, adding static types makes maintenance easier and will allow us to more confidently refactor parts of Jest without fear of breakages.</p>
<p>The Flow project has evolved a lot within Facebook and has been successfully adopted across many of our frameworks and almost all of our product code. Adoption can be parallelized incredibly well – it can be done file-by-file until enough of the codebase is well-typed. Then, Flow provides real value and helps guide through large changes. Through this, many small edge cases and bugs were found.</p>
<p>With the help of <a href="https://github.com/lerna/lerna" target="_blank" rel="noopener noreferrer" class="">lerna</a>, we continued to modularize the Jest project. With just a small <a href="https://github.com/lerna/lerna#lernajson" target="_blank" rel="noopener noreferrer" class="">update to the configuration</a>, Flow and lerna now get along well with each other. Splitting up Jest into packages helped us rethink module boundaries and enabled us to ship useful <a href="https://github.com/jestjs/jest/tree/main/packages" target="_blank" rel="noopener noreferrer" class="">packages</a> standalone: The <code>jest-runtime</code> and <code>jest-repl</code> cli tools now allow you to run scripts in a sandboxed Jest environment, enabling you to run and debug your app from the command line. This is especially helpful for projects that use Facebook's <code>@providesModule</code> module convention. To get started, just install <code>jest-repl</code> and run it in the same folder you normally run your tests in! We also published a <code>jest-changed-files</code> package that finds changed files in version control for either git or hg, a common thing in developer tools.</p>
<h2 class="anchor anchorTargetStickyNavbar_tleR" id="new-and-improved-features">New and improved features<a href="https://jestjs.io/blog/2016/06/22/jest-13#new-and-improved-features" class="hash-link" aria-label="Direct link to New and improved features" title="Direct link to New and improved features" translate="no">​</a></h2>
<ul>
<li class="">Added a notification plugin that shows a test run notification when using <code>--notify</code>.</li>
<li class="">Added a <code>browser</code> config option to properly resolve npm packages with a browser field in <code>package.json</code> if you are writing tests for client side apps.</li>
<li class="">Improved “no tests found message” which will now report which tests were found and how they were filtered.</li>
<li class="">Added <code>jest.isMockFunction(jest.fn())</code> to test for mock functions.</li>
<li class="">Improved test reporter printing and added a test failure summary when running many tests.</li>
<li class="">Added support for mocking virtual modules through <code>jest.mock('Module', implementation, {virtual: true})</code>.</li>
<li class="">Removed the <code>.haste_cache</code> folder. Jest now uses the operating system's preferred temporary file location.</li>
<li class="">Added the duration of individual tests in verbose mode.</li>
<li class="">Added the ability to record snapshots in Jest. We'll be publishing a separate blog post about this feature soon.</li>
</ul>
<p>Finally, we have received a complete website redesign done by Matthew Johnston and added documentation for using <a class="" href="https://jestjs.io/docs/webpack">Jest with webpack</a>. Happy Jesting!</p>]]></content:encoded>
        </item>
    </channel>
</rss>