How it works
Jest bundles everything in one package: a runner that executes test files in parallel, the expect assertion library, jest.fn() mocks and module mocking, fake timers, snapshot testing and code coverage. Tests usually run in Node.js or in jsdom, a simulated browser, which is how React components are commonly tested with Testing Library.
It came out of Meta (Facebook) and has been looked after by the OpenJS Foundation since 2022. It remains the default in React Native and in many established React and Node.js projects. Its weak spots are modern ones: TypeScript needs a transformer such as ts-jest, Babel or SWC, and native ES module support is still marked experimental, which is a large part of why new Vite projects pick Vitest.
Jest pros and cons
Pros
- Everything built in: runner, assertions, mocks, snapshots and coverage
- Mature, with answers online for almost any problem
- The standard in React Native and many existing codebases
Cons
- TypeScript and ES modules need extra configuration
- Slower start-up and watch mode than Vitest in many projects
- jsdom is a simulation, so some browser behaviour differs
When to use Jest
Pick it when
- React Native apps
- Existing projects that already run on Jest
- Node.js libraries written in CommonJS
Skip it when
- New Vite-based projects, where Vitest fits with less setup
Jest pricing
Jest vs the alternatives
Related terms
More in Testing and quality
Test runners