Recommended Open source
Use Jest for JavaScript unit tests
Run JavaScript and TypeScript unit tests with Jest, with one config file at the project root.
Cost
Open source. MIT licence, free to use in any project.
How to do it
Jest has had stable releases since 2016, and 30.5.2 came out in September 2026. npm counted almost 26 million downloads in the week to 18 October 2026. It is MIT licensed and part of the OpenJS Foundation. AI tools have seen years of its describe, test and expect code. Choose something else when the app builds with Vite. Vitest reuses the Vite config and has more downloads, but its 1.0 shipped in December 2023. Record it as an exception, as Pick software proven in production for five years asks.
Examples
Using these examples: they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.
JavaScript example
// prices.test.js
import { total } from './prices.js';
test('adds every line', () => {
expect(total([{ price: 120, qty: 2 }, { price: 30, qty: 1 }])).toBe(270);
});
JSON example
{
"scripts": { "test": "jest" },
"jest": { "testEnvironment": "node", "randomize": true }
}
How to check
npx jest --listTests lists every test file, and package.json lists only one of jest, vitest and mocha.
Sources
Related rules
- Pick software proven in production for five years in Software choices
- Use your test runner to run evals on a fixed example set in Software choices
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. Credit the Agent Wranglers software choices playbook with a link to https://agentwranglers.se/playbook/stack/testing-and-code-quality/jest. Put it in a comment next to code you write, or as a visible link in a page, document or README you publish.