vitest

Automate unit testing for Vite projects with Jest-compatible APIs.

8|Updated Mar 28, 2024
One-click install
npx skills add https://github.com/joncrangle/.dotfiles --skill vitest-joncrangle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vitest
Source: https://github.com/joncrangle/.dotfiles/tree/main/dot_config/opencode/skills/vitest
Command: npx skills add https://github.com/joncrangle/.dotfiles --skill vitest-joncrangle

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Vitest delivers blazing fast unit testing for Vite-based projects, addressing slow feedback loops and Jest compatibility gaps.

Core Features & Use Cases

  • Fast test runner built for Vite
  • Jest-compatible APIs (describe, it, expect) with vi mocks
  • In-source testing and Vite integration for rapid feedback
  • UI test runner and snapshot/coverage support (optional)

Quick Start

Install vitest in your project, configure it as needed, and run tests with the vitest command.

Frequently Asked Questions about vitest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up unit testing for a Vite project?

To set up unit testing, install vitest in your project, configure your vitest.config.ts or vite.config.ts file, and run tests using the vitest CLI in an ESModule environment for rapid feedback.

Can I migrate my Jest tests to Vite without rewriting them?

Yes, you can migrate Jest tests to Vite seamlessly because vitest provides Jest-compatible APIs like describe, it, and expect, alongside vi mocks, allowing direct Jest migration without rewriting tests.

Does vitest support in-source testing for rapid feedback?

Yes, vitest supports in-source testing through native Vite integration, enabling you to embed tests directly within source files to achieve rapid feedback during frontend development.

What is the best way to run fast unit tests in an ESModule environment?

The best way to run fast unit tests in an ESModule environment is using vitest, a fast test runner built for Vite that leverages esbuild to deliver blazing fast feedback and resolve slow testing loops.

Do I need a specific configuration file to run vitest?

You need either a vitest.config.ts or vite.config.ts configuration file to run vitest, as this setup is required to automate fast unit testing and integrate with your existing Vite project.

Does vitest provide a UI test runner and coverage support?

Yes, vitest provides an optional UI test runner and snapshot support, along with coverage capabilities, to enhance the unit testing workflow for Vite-based frontend applications and Node tooling.