testing

Write and debug Vitest tests with deterministic mocking patterns.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It helps you write reliable Vitest tests and rapidly debug failures so your changes don’t break expected behavior or reduce coverage over time.

Core Features & Use Cases

  • Run and target tests efficiently: Execute specific files or package-scoped tests instead of running the full suite.
  • Write maintainable tests: Prefer vi.spyOn over broad vi.mock, verify behavior instead of internal wiring, and keep tests type-safe.
  • Debug failures with guardrails: Use clear stop-and-ask guidance after repeated failed attempts, and address common issues like module pollution and mock setup order.
  • Use curated scenario references: Jump to focused guides for database models, Electron IPC, Zustand actions, agent runtime E2E, and desktop controllers.

Quick Start

Ask the testing skill how to run the failing test file and which mocking approach to use for the specific failure you’re seeing.

Frequently Asked Questions about testing

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

FAQPage Schema
How do I fix failing Vitest tests without reducing test coverage?

To fix failing Vitest tests, use deterministic patterns like preferring vi.spyOn over vi.mock and verify behavior instead of internal wiring to improve correctness and maintainability.

What is the best way to set up mocking in Vitest for unit testing?

The best way to set up mocking in Vitest is using vi.spyOn rather than broad vi.mock applications, which ensures type-check correctness and avoids common issues like module pollution.

How do I run specific package-scoped Vitest tests instead of the full suite?

You can run specific package-scoped Vitest tests by targeting specific files or directories, allowing you to efficiently execute only the relevant tests during development.

Does this Vitest debugging approach work for Electron IPC and Zustand actions?

Yes, this Vitest debugging approach works for Electron IPC and Zustand actions by using curated scenario references to guide mock setup and testing for desktop and webapp environments.

Why does my Vitest test fail after multiple mocking attempts?

Vitest tests often fail after repeated attempts due to mock setup order issues or module pollution, requiring clear stop-and-ask guidance to address the specific failing edge cases.

Can I use Vitest for both webapp and desktop test scenarios?

Yes, you can use Vitest for both webapp and desktop test scenarios, including unit tests, failing test triage, and agent runtime E2E testing across different application environments.