vitest
npx skills add https://github.com/partme-ai/full-stack-skills --skill vitest
Agent 安装分布
Skill 文档
When to use this skill
Use this skill whenever the user wants to:
- Set up Vitest in a Vite project
- Write unit tests and component tests
- Configure Vitest for different environments
- Use Vitest API and utilities
- Test Vue, React, or Svelte components
- Use browser mode for testing
- Set up visual regression testing
- Mock functions and modules
- Use snapshots for testing
- Configure test coverage
- Use Vitest UI
- Optimize test performance
- Debug tests
- Understand Vitest best practices
- Troubleshoot Vitest issues
How to use this skill
This skill is organized to match the Vitest official documentation structure (https://vitest.dev/guide/, https://vitest.dev/api/, https://vitest.dev/config/). When working with Vitest:
-
Identify the topic from the user’s request:
- Getting started/å¿«éå¼å§ â
examples/getting-started.md - Features/åè½ç¹æ§ â
examples/features.md - Component testing/ç»ä»¶æµè¯ â
examples/component-testing.md - Browser mode/æµè§å¨æ¨¡å¼ â
examples/browser-mode.md - API/API ææ¡£ â
api/ - Configuration/é
ç½® â
examples/config/
- Getting started/å¿«éå¼å§ â
-
Load the appropriate example file from the
examples/directory:Getting Started (å¿«éå¼å§):
examples/getting-started.md– Installation and first test
Features (åè½ç¹æ§):
examples/features.md– Key features and capabilitiesexamples/ui.md– Vitest UIexamples/component-testing.md– Component testingexamples/browser-mode.md– Browser mode testingexamples/visual-regression-testing.md– Visual regression testingexamples/trace-view.md– Trace view
Testing (æµè¯):
examples/test-api.md– Test API (test, it, describe, etc.)examples/mocking.md– Mocking functions and modulesexamples/snapshots.md– Snapshot testingexamples/coverage.md– Code coverage
Configuration (é ç½®):
examples/config/basic-config.md– Basic configurationexamples/config/environment.md– Environment configurationexamples/config/browser-config.md– Browser mode configuration
-
Follow the specific instructions in that example file for syntax, structure, and best practices
Important Notes:
- Vitest is designed for Vite projects
- Supports TypeScript, JSX, ESM out of the box
- Fast watch mode with HMR-like experience
- Compatible with Jest API
- Examples include both JavaScript and TypeScript versions
- Each example file includes key concepts, code examples, and key points
-
Reference API documentation in the
api/directory when needed:api/test-api.md– Test API referenceapi/vi-utility.md– vi utility functionsapi/expect.md– Expect assertionsapi/mocking.md– Mocking API
-
Use templates from the
templates/directory:templates/vitest-config.md– Vitest configuration templatestemplates/test-examples.md– Test example templates
Doc mapping (one-to-one with https://vitest.dev/guide/, https://vitest.dev/api/, https://vitest.dev/config/)
Guide (æå):
examples/getting-started.mdâ https://vitest.dev/guide/getting-started.htmlexamples/features.mdâ https://vitest.dev/guide/features.htmlexamples/ui.mdâ https://vitest.dev/guide/ui.htmlexamples/component-testing.mdâ https://vitest.dev/guide/testing-components.htmlexamples/browser-mode.mdâ https://vitest.dev/guide/browser.htmlexamples/visual-regression-testing.mdâ https://vitest.dev/guide/visual-regression.htmlexamples/trace-view.mdâ https://vitest.dev/guide/trace-view.htmlexamples/mocking.mdâ https://vitest.dev/guide/mocking.htmlexamples/snapshots.mdâ https://vitest.dev/guide/snapshot.htmlexamples/coverage.mdâ https://vitest.dev/guide/coverage.html
Configuration (é ç½®):
examples/config/basic-config.mdâ https://vitest.dev/config/examples/config/environment.mdâ https://vitest.dev/config/#environmentexamples/config/browser-config.mdâ https://vitest.dev/config/#browser
API Reference:
api/test-api.mdâ https://vitest.dev/api/api/vi-utility.mdâ https://vitest.dev/api/vi.htmlapi/expect.mdâ https://vitest.dev/api/expect.htmlapi/mocking.mdâ https://vitest.dev/api/vi.html
Examples and Templates
This skill includes detailed examples organized to match the official documentation structure. All examples are in the examples/ directory (see mapping above).
To use examples:
- Identify the topic from the user’s request
- Load the appropriate example file from the mapping above
- Follow the instructions, syntax, and best practices in that file
- Adapt the code examples to your specific use case
To use templates:
- Reference templates in
templates/directory for common scaffolding - Adapt templates to your specific needs and coding style
Best Practices
- Use watch mode: Leverage Vitest’s smart watch mode for faster feedback
- Organize tests: Group related tests with describe blocks
- Use TypeScript: Take advantage of native TypeScript support
- Mock effectively: Use vi.mock() for module mocking
- Test components: Use component testing for Vue/React components
- Use UI mode: Use
--uiflag for better test debugging experience - Optimize performance: Use test.only() during development
Resources
- Official Documentation: https://vitest.dev/
- Getting Started: https://vitest.dev/guide/
- API Reference: https://vitest.dev/api/
- Configuration: https://vitest.dev/config/
- GitHub Repository: https://github.com/vitest-dev/vitest
Keywords
Vitest, vitest, test framework, unit testing, component testing, Vite, Jest compatible, watch mode, HMR, TypeScript, ESM, mocking, snapshots, coverage, browser mode, visual regression testing, æµè¯æ¡æ¶, åå æµè¯, ç»ä»¶æµè¯, çè§æ¨¡å¼, çæ¨¡åæ¿æ¢, 模æ, å¿«ç §, è¦çç, æµè§å¨æ¨¡å¼, è§è§å彿µè¯