testing

Automate Vitest unit testing workflows for JavaScript and TypeScript projects.

81.4k|15.8k|Updated May 21, 2023
One-click install
npx skills add https://github.com/lobehub/lobehub --skill testing-lobehub
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/lobehub/lobehub/tree/main/.agents/skills/testing
Command: npx skills add https://github.com/lobehub/lobehub --skill testing-lobehub

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides developers in implementing and refining Vitest-based tests, reducing setup time and cognitive load when writing and debugging tests.

Core Features & Use Cases

  • Test creation guidance: structuring new .test.ts/.test.tsx files with clear expectations.
  • Debugging & coverage: effective strategies to diagnose failures and improve test coverage across codebases.
  • Best practices: recommended mocking, test organization, and running targeted tests in large repositories.
  • Use Case: starting a new TypeScript project or fixing flaky tests, use this Skill to organize tests and verify coverage quickly.

Quick Start

Use Vitest to run tests in your project. Example: run all tests from the project root with bunx vitest run --silent. To run a specific file, use bunx vitest run path/to/file.test.ts.

Frequently Asked Questions about testing

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

FAQPage Schema
How do I structure new Vitest test files for a TypeScript project?

To structure new Vitest test files, create .test.ts or .test.tsx files with clear expectations and organized test suites. Following recommended test creation guidance ensures your unit tests remain maintainable and readable across your codebase.

What is the best way to debug failing Vitest unit tests?

The best way to debug failing Vitest unit tests is applying effective diagnostic strategies to identify failure causes. This Skill guides you through debugging workflows to pinpoint issues and verify fixes by running targeted tests in your JavaScript or TypeScript project.

How do I improve test coverage with Vitest in a large repository?

To improve test coverage with Vitest, apply effective strategies to diagnose untested code paths and run targeted tests across your large repository. This approach helps verify coverage quickly and ensures comprehensive unit test validation across your codebase.

Do I need Node.js installed to run Vitest for unit testing?

Yes, you need a Node.js environment with Vitest installed to run unit testing workflows. A conventional project layout is also required to activate and guide tests properly within your JavaScript or TypeScript codebase.

How do I use mocking in Vitest to isolate unit tests?

Mocking in Vitest isolates unit tests by replacing dependencies with controlled substitutes. Applying recommended mocking best practices allows you to organize tests effectively and verify code behavior without triggering external side effects.

Can I run a specific Vitest test file instead of the entire suite?

Yes, you can run a specific Vitest test file instead of the entire suite. Use the command `bunx vitest run path/to/file.test.ts` from your project root to execute targeted tests and debug individual test files quickly.