Skip to content

Jest

A JavaScript testing framework that runs test files and checks results, with a watch mode and snapshots.

Stars
45.5k
Forks
6.7k
Licence
MIT
Language
TypeScript
Last update
4 days ago
Type
Library

What it is

Jest is a testing tool for JavaScript code. You write small test files that call functions and check the results against expected values, and Jest runs them and reports which pass or fail. Its watch mode re-runs only the tests related to files you changed, and its snapshot feature saves a copy of large outputs so you can see when they change.

  • Write a test that checks a function such as sum(1, 2) returns 3, then run it with npm test
  • Run only the test files that match a name pattern from the command line
  • Save snapshots of large objects to notice unexpected changes over time
  • Configure Jest for a project using Babel, webpack, Parcel, or TypeScript

Great for

  • JavaScript or TypeScript developers who want a testing setup that works with little configuration
  • Teams adding automated tests to an existing Node-based or front-end project
  • People who want to check how large objects or outputs change over time with snapshots
  • Developers who want fast feedback while editing code via watch mode

Not ideal for

  • People who do not write or maintain JavaScript code, since it is a developer tool for testing code
  • Projects that need full browser end-to-end testing, because the README describes Jest as a unit-style test runner and does not mention browser automation
  • Anyone who wants Babel-free TypeScript type checking in tests, since the README says Babel-based TypeScript support does not type-check tests and suggests ts-jest or tsc instead
Step-by-step guide: how to use JestInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js · npm or yarn

    Install with npm (dev dependency)

    npm install --save-dev jest

    Install with yarn (dev dependency)

    yarn add --dev jest

    Generate a basic configuration file

    yarn create jest
  2. 2

    Run it

    • Install Jest as a dev dependency with npm install --save-dev jest
    • Create sum.js and sum.test.js as shown in the README
    • Add "test": "jest" to the scripts section of package.json
    • Run npm test and look for the PASS message
  3. 3

    Get the most out of it

    • Run yarn create jest to generate a configuration file with descriptions for each option
    • Use the --notify flag from the command line to get a native OS notification after a run
    • Use snapshot testing to capture large objects and review how they change over time
    • Pair Babel with @babel/preset-typescript for TypeScript, and add tsc or ts-jest if you need type checking

Downloads

Strengths

  • The README describes it as working out of the box for most JavaScript projects
  • Watch mode runs only tests related to changed files, giving quick feedback
  • Snapshot testing and a generated basic configuration file reduce setup effort

Trade-offs

  • TypeScript support through Babel does not type-check tests, so extra tools are needed for that
  • The README says Vite support is not full and points to a third-party plugin with limitations
  • Setup for some bundlers and TypeScript requires extra packages and configuration

How it compares

ProjectStarsTypeLevelUpdatedBest for
jest (this)45.5kLibrarybeginner4 days agoJavaScript or TypeScript developers who want a testing setup that works with little configuration
vitest17.3kLibraryintermediate4 days agoJavaScript or TypeScript developers already using Vite
mocha22.9kLibraryintermediate5 days agoJavaScript and Node.js developers who want automated tests for their code
ava20.8kDev toolbeginner5 days agoNode.js developers who want a small, straightforward test runner
cypress51kDev toolbeginner4 days agoDevelopers who want automated browser tests for a web application
enzyme19.8kLibraryintermediate1.0 years agoDevelopers maintaining React codebases that already have component tests

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.