The CheckOps Engineer
Jest
Jest is a free, open-source JavaScript test runner with zero-config defaults, mocks, and snapshot testing.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
Jest is a JavaScript test runner for unit and component tests in Node.js. It started at Meta and is maintained as an MIT-licensed project at jestjs/jest. Many projects run with no config file: Jest discovers *.test.js and *.spec.js files, provides describe, it, and expect, and executes files in parallel worker processes.
The runner includes function and module mocks, fake timers, snapshot comparisons, and coverage through Istanbul or V8. TypeScript usually needs a transform (babel-jest, ts-jest, or the project’s compiler). Tests run in Node. DOM code typically uses jsdom, which is not a real browser.
Features
- Runner and matchers:
describe,test/it, andexpectship in the same package, including equality, exception, and asymmetric matchers. - Parallel workers: Test files run in worker processes.
--watchreruns files affected by a change. - Mocks:
jest.fn,jest.mock, and manual mocks under__mocks__replace modules without a second library. - Fake timers:
jest.useFakeTimers()controlssetTimeout,setInterval, andDateso time-based code does not wait on the wall clock. - Snapshots:
toMatchSnapshotstores a serialized value and fails when the next run differs. Inline snapshots keep the expected string in the test file. - Coverage:
--coveragecollects Istanbul or V8 coverage. Thresholds can fail the run from config. - Projects: One config can declare several projects, setup files, a module name mapper, and
testEnvironmentofnodeorjsdom. - CI reporters: Console output plus JSON and custom reporters. A JUnit reporter is a small extra package, not a separate product.
Pros
- One package for a typical Node library: Discovery, assertions, mocks, and watch mode are installed together.
- Examples match the runner: A large share of JavaScript unit-test snippets, including older React Testing Library docs, assume Jest matchers and
jest.mock. - Snapshot review is a diff: Intentional output changes are updated with
-uand show up in code review. - File isolation: Each test file gets its own module registry, which limits leaked state when mocks are reset.
- No seat fee: The MIT license allows private and public use. The cost is CI time and transform setup.
Cons
- jsdom is not a browser: Layout, navigation, and many web platform APIs are missing or stubbed. End-to-end checks belong in a browser runner.
- Transform cost on large UI suites: Babel or TypeScript transforms are slower than Vitest’s Vite pipeline on the same component tree.
- Native ESM needs extra config: Mixed CommonJS and ECMAScript module graphs often need
extensionsToTreatAsEsmor a transform. Failures show up as syntax errors rather than a bundler warning. - Snapshots drift: Large component snapshots fail on unrelated markup. They only help if reviewers reject unexplained updates.
- Monorepo config accumulates: Project lists, setup files, and mapper exceptions become their own maintenance surface.
Usage and Links (Example)
npm install --save-dev jest
npx jest
npx jest --watch
npx jest --coverage
const { add } = require("./add");
test("adds two numbers", () => {
expect(add(1, 2)).toBe(3);
});
Name that file add.test.js. Jest’s default pattern collects it. From Jest 28 onward, DOM tests need jest-environment-jsdom and testEnvironment: "jsdom".
Resources:
Pricing
- Free: Jest is MIT-licensed. There is no paid Jest tier and no hosted runner to subscribe to.
- CI is separate: You pay for the minutes that execute
npx jest. Dashboards, flake tracking, and cloud traces are other products.
Recommended for?
- Node libraries and backend units that already run in Node and do not use Vite’s transform pipeline.
- Suites that already use Jest mocks and snapshots, where a migration would rewrite working tests.
- React tests written against Jest, including Testing Library setups that call
jest.fnandjest.mock. - Projects that want a runner without installing Vite or a browser.
Conclusion
Jest is still the JavaScript unit runner most existing Node and React suites are written for. Keep it when the mocks, snapshots, and config are already in place. On a new Vite app, measure Vitest before paying for a second transform pipeline. Jest does not drive a real browser, so it does not replace Playwright, Cypress, or a device lab.