vitest

Write and run Vitest tests for JavaScript and TypeScript projects.

Updated Feb 21, 2024
One-click install
npx skills add https://github.com/zhongjis/nix-config --skill vitest-zhongjis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vitest
Source: https://github.com/zhongjis/nix-config/tree/main/modules/home-manager/features/ai-tools/common/skills/general/vitest
Command: npx skills add https://github.com/zhongjis/nix-config --skill vitest-zhongjis

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill streamlines the process of writing, running, and managing tests for your JavaScript and TypeScript projects, ensuring code quality and catching regressions early.

Core Features & Use Cases

  • Test Execution: Run unit, integration, and benchmark tests efficiently.
  • Configuration: Set up custom test environments, coverage reporters, and project configurations.
  • Mocking: Isolate code by mocking modules, filesystem operations, and network requests.
  • Use Case: You've just refactored a critical API endpoint. Use this Skill to quickly run your existing test suite, verify the changes, and ensure no existing functionality is broken.

Quick Start

Run all tests in watch mode using the command bun vitest.

Frequently Asked Questions about vitest

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

FAQPage Schema
How do I set up JavaScript and TypeScript testing with Vitest?

JavaScript and TypeScript testing with Vitest is set up by configuring custom test environments and coverage reporters. You can run unit, integration, and benchmark tests efficiently to ensure code quality and catch regressions early.

Can I mock network requests and filesystem operations in Vitest?

Mocking network requests and filesystem operations in Vitest is fully supported to isolate your code. You can mock modules comprehensively to ensure robust software quality assurance during your tests.

What is the best way to run tests after refactoring an API endpoint?

Running tests after refactoring an API endpoint is best handled by executing your existing test suite in watch mode. This verifies the changes and ensures no existing functionality is broken.

Does Vitest support Behavior-Driven Development and type checking?

Behavior-Driven Development (BDD) and type checking are supported by Vitest. It enables adherence to BDD principles while facilitating comprehensive type checking for your JavaScript and TypeScript projects.

How do I generate code coverage reports for my web app?

Code coverage reports for your web app are generated by configuring coverage reporters in your test setup. This provides comprehensive reporting to track code quality and test completeness.

Why use Vitest for unit testing over other JavaScript testing tools?

Using Vitest for unit testing provides fast and reliable execution for modern web apps. It streamlines the process of writing, running, and managing tests to catch regressions early in your workflow.