Jest is a JavaScript testing framework developed by Meta (formerly Facebook) that has become the industry standard for testing JavaScript applications, especially in the React ecosystem. It provides a zero-configuration setup with a built-in test runner, assertion library, mocking utilities, and code coverage tools—all in one package. Jest 30 (released June 2025) brought significant performance improvements—up to 37% faster runs and 77% lower memory usage—along with native .mts/.cts support, improved ESM handling, and new features like expect.arrayOf and jest.advanceTimersToNextFrame. The key mental model: Jest isolates each test file in its own VM context, so side effects, globals, and module caches never leak between files—but this isolation comes at a startup cost worth understanding when optimizing large suites.
What This Cheat Sheet Covers
This topic spans 24 focused tables and 184 indexed concepts, 119 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Core Test Structure
The building blocks of every Jest file: describe groups tests, test/it defines them, and expect makes assertions. The variants — .each for parameterized runs, .skip/.only for focusing, .concurrent for parallelism, and .failing for documenting known bugs — let you shape a suite without rewriting the core logic.
| Function | Example | Description | |
|---|---|---|---|
test('adds 1 + 2', () => { expect(1 + 2).toBe(3); }) | • Defines a single test case • it is a fully interchangeable alias. | ||
describe('Math', () => { test('add', () => {...}); }); | • Groups related tests into a suite • can be nested for hierarchical organization. | ||
expect(value).toBe(3) | • Creates an expectation object • always paired with a matcher like toBe or toEqual. | ||
test.each([[1,2,3],[2,3,5]])('adds %i+%i=%i',(a,b,e)=>{expect(a+b).toBe(e)}) | • Parameterized testing—runs the same logic with different data • reduces duplication. | ||
test.skip('not ready', () => {...}) | • Skips a test • temporarily disables without deleting. Also xit / xtest. | ||
test.only('run this', () => {...}) | • Runs only this test in the file • all others skipped. Alias fit. Great for focused debugging. | ||
test.concurrent('parallel', async () => {...}) | • Runs the test concurrently with other concurrent tests• requires async function. | ||
test.failing('known bug', () => { expect(bugFn()).toBe(1); }) | • Expects the test to fail • test passes if it fails, fails if it passes. Documents known bugs. | ||
describe.each([[1],[2]])('suite %i',(n)=>{...}) | Creates multiple describe blocks from a data table. | ||
describe.only('focus suite', () => {...}) | • Runs only tests within this block • all other describes skipped. | ||
describe.skip('wip suite', () => {...}) | • Skips all tests in this block • alias xdescribe. |