# Vitest

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

**Field:** Software Development  
**Category:** Testing & Quality  
**Also known as:** Vitest JS

## Think of it like

Think of it like a new bike. It is faster, but it rides just like your old one.

## Definition

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.

## Example code

```console
$ npx vitest run
      Tests  1 passed (1)
```

Vitest ran the test file once and reported one pass.

## Why it matters

Apps built with Vite get tests that share their settings, with no second set-up to keep in step.

## Common mistake

Running plain vitest in a build script. It waits for changes forever; use vitest run to run once.

## Three principles

- **Built on Vite.** Shares its settings.
- **Jest-like.** Easy to switch.
- **Fast reruns.** Only what changed.

## Related terms

- [Jest](https://learn.benibix.com/term/development/jest)
- [Test Runner](https://learn.benibix.com/term/development/test-runner)
- [TypeScript](https://learn.benibix.com/term/development/typescript)
- [Unit Test](https://learn.benibix.com/term/development/unit-test)
- [Testing Library](https://learn.benibix.com/term/development/testing-library)

## Told apart from

- [Jest vs Vitest](https://learn.benibix.com/compare/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.

---

Source: https://learn.benibix.com/term/development/vitest
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
