testing

Write, debug, and maintain Vitest tests for .test.ts and .test.tsx files.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/kissMyApps-tlm/kissmychat --skill testing-kissmyapps-tlm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/kissMyApps-tlm/kissmychat/tree/main/.agents/skills/testing
Command: npx skills add https://github.com/kissMyApps-tlm/kissmychat --skill testing-kissmyapps-tlm

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a structured guide for using Vitest to write, organize, and debug tests in JavaScript and TypeScript projects.

Core Features & Use Cases

  • Clear test organization patterns and naming conventions for files like .test.ts and .test.tsx
  • Practical mocking and isolation strategies using vi.spyOn and vi.mock
  • Best practices for reliable tests, code coverage, and debugging common issues
  • Real-world use cases: TDD workflows, incremental test improvements, and contributor onboarding

Quick Start

Install Vitest in your project and add a basic test file beside the module under test. Run tests with bunx vitest run --silent='passed-only' to verify passing tests.

Frequently Asked Questions about testing

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

FAQPage Schema
How do I write and organize tests with Vitest in TypeScript?

Vitest organizes tests in .test.ts or .test.tsx files placed alongside the module under test. Write test suites using describe blocks and individual tests with it(), following clear naming conventions. Run tests with bunx vitest run --silent='passed-only' to verify passing tests and establish reliable, readable test structure.

What's the best way to mock dependencies in Vitest tests?

Vitest provides vi.spyOn() for spying on specific methods and vi.mock() for isolating entire modules. These strategies prevent tests from depending on external state, ensure tests run independently, and reduce flakiness by controlling side effects and external calls.

How do I debug failing Vitest tests and improve code coverage?

Vitest enables debugging through structured test output and coverage reporting. Use test organization patterns to identify failures quickly, apply mocking strategies to isolate problems, and measure coverage expectations to identify untested code paths and strengthen reliability.

Can I use Vitest for test-driven development workflows?

Vitest supports TDD workflows by enabling fast test execution and incremental test improvements. Write tests before implementation, run them frequently to guide development, and leverage mocking to define contracts before writing production code.

Does Vitest work with JavaScript projects or only TypeScript?

Vitest works with both JavaScript and TypeScript projects. It handles .test.ts, .test.tsx, and equivalent JavaScript test files, supporting mixed-language codebases with the same test structure, mocking, and coverage capabilities across both languages.

What are common pitfalls when writing Vitest tests?

Flaky tests often result from poor isolation, missing mocks, or unclear test organization. Vitest best practices prescribe explicit mocking strategies, proper setup and teardown patterns, and clear naming conventions to maintain reliable tests and reduce debugging time.