Jest
In one line
Jest is the most popular JavaScript testing framework — it includes everything: test runner, assertions, mocks, snapshots, and coverage.
In simple words
Jest is a batteries-included testing framework created by Facebook (Meta). It's the most popular choice for JavaScript and React testing because everything works out of the box.
What Jest includes:
- Test runner: discovers and runs your tests
- Assertion library: expect() and matchers like toBe, toEqual
- Mocking: jest.fn(), jest.mock(), jest.spyOn()
- Snapshot testing: toMatchSnapshot()
- Code coverage: built-in coverage reports
- Parallel execution: runs tests in parallel by default
You don't need to assemble different libraries — install Jest and you're ready. This simplicity makes it great for beginners. The trade-off is it's heavier than some alternatives and can be slower for large projects.
Example
// Everything in one package
test('example', () => {
const mock = jest.fn().mockReturnValue(42);
expect(mock()).toBe(42);
expect(mock).toHaveBeenCalled();
});Jest provides test(), expect(), and jest.fn() all in one framework.
Related terms
Related Resources
Related Lessons
- Jest Basics
Getting started with Jest.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.