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. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core Test Structure
| 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. |