Skip to content
BENIBIX Learn

Jest vs Vitest

Jest and Vitest are both tools that run tests for JavaScript, and their test and expect functions look almost the same. Vitest is built on Vite and reuses its settings, so it fits apps made with Vite. Jest is older and works with almost any project.

Development🧪 Testing & Quality

Jest

A test tool for JavaScript. It finds your tests and runs them.

Jest is a popular tool for testing JavaScript and TypeScript code. Facebook built it and released it in 2014. It finds test files, runs them and shows which passed. It also has mocks, spies and snapshot tests built in, so most projects need nothing extra. Test files usually end in .test.js, and checks are written with expect.

Example
Emma adds Jest to her React app. She types npx jest, and it runs her 85 tests in 6 seconds.
Why it matters
It works with almost no set-up. A JavaScript project can have tests from day one.
Full entry
Development🧪 Testing & Quality

Vitest

A fast JavaScript test tool built on Vite, with an API much like Jest.

Vitest is a fast test tool for JavaScript and TypeScript, built on the Vite build tool. Its test, expect and mock functions look almost the same as Jest's. So many projects can switch with few changes. It reuses the project's Vite settings, so tests understand the same files the app does. In watch mode it reruns only the tests touched by a change.

Example
Jack's Vite app moves from Jest to Vitest. His tests barely change, and the watch mode reruns a changed test in under a second.
Why it matters
Apps built with Vite get tests that share their settings, with no second set-up to keep in step.
Full entry

In one line

Jest
A test tool for JavaScript. It finds your tests and runs them.
Vitest
A fast JavaScript test tool built on Vite, with an API much like Jest.