Skills Plugins MCP Prompt Model 博客 我的中心
开发编程 #javascript #typescript #api

vitest-skill

Generates Vitest tests in JavaScript/TypeScript with Vite-native speed. Jest-compatible API with ESM support and HMR. Use when user mentions "Vitest", "vi.mock", "vitest.config". Triggers on: "Vitest", "vi.mock", "vi.fn", "Vite test", "vitest config".

DeepseekModel 官方收录技能 质量 优秀 · 78 v1.0.0

获取

https://deepseekmodel.com/api/download.php?id=lambdatest-agent-skills-vitest-skill-skill-md&format=skill
下载 .skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用
.skill 文件中 system_prompt 字段的实际内容。
name vitest-skill description Generates Vitest tests in JavaScript/TypeScript with Vite-native speed. Jest-compatible API with ESM support and HMR. Use when user mentions "Vitest", "vi.mock", "vitest.config". Triggers on: "Vitest", "vi.mock", "vi.fn", "Vite test", "vitest config". languages ["JavaScript","TypeScript"] category unit-testing license MIT metadata {"author":"TestMu AI","version":"1.0"} Vitest Testing Skill Core Patterns Basic Test import { describe, it, expect, vi, beforeEach } from 'vitest' ; import { Calculator } from './calculator' ; describe ( 'Calculator' , () => { let calc : Calculator ; beforeEach ( () => { calc = new Calculator (); }); it ( 'adds two numbers' , () => { expect (calc. add ( 2 , 3 )). toBe ( 5 ); }); it ( 'throws on divide by zero' , () => { expect ( () => calc. divide ( 10 , 0 )). toThrow (); }); }); Mocking (vi instead of jest) import { vi } from 'vitest' ; // Mock module vi. mock ( './database' , () => ({ getUser : vi. fn (). mockResolvedValue ({ name : 'Alice' }), saveUser : vi. fn (). mockResolvedValue ( true ), })); // Mock function const mockFn = vi. fn (); mockFn. mockReturnValue ( 42 ); mockFn. mockResolvedValue ({ data : 'test' }); // Spy const spy = vi. spyOn ( console , 'log' ). mockImplementation ( () => {}); expect (spy). toHaveBeenCalledWith ( 'message' ); spy. mockRestore (); // Timers vi. useFakeTimers (); vi. advanceTimersByTime ( 1000 ); vi. runAllTimers (); vi. useRealTimers (); In-Source Testing // src/math.ts — tests alongside code! export function add ( a : number , b : number ) { return a + b; } export function multiply ( a : number , b : number ) { return a * b; } if ( import . meta . vitest ) { const { it, expect } = import . meta . vitest ; it ( 'adds' , () => { expect ( add ( 2 , 3 )). toBe ( 5 ); }); it ( 'multiplies' , () => { expect ( multiply ( 3 , 4 )). toBe ( 12 ); }); } Snapshot Testing it ( 'serializes user' , () => { expect ( serializeUser (user)). toMatchSnapshot (); }); it ( 'inline snapshot' , () => { expect ( serializeUser (user)). toMatchInlineSnapshot ( ` { "name": "Alice", "email": "alice@test.com" } ` ); }); React Component Testing import { render, screen } from '@testing-library/react' ; import { describe, it, expect } from 'vitest' ; import Button from './Button' ; describe ( 'Button' , () => { it ( 'renders with label' , () => { render ( < Button label = "Click me" /> ); expect (screen. getByText ( 'Click me' )). toBeDefined (); }); }); Anti-Patterns Bad Good Why jest.fn() vi.fn() Vitest uses vi jest.mock() vi.mock() Different namespace No type safety TypeScript + strict Vitest is TS-first Quick Reference Task Command Run once npx vitest run Watch npx vitest (default) UI npx vitest --ui Coverage npx vitest --coverage Specific file npx vitest run src/math.test.ts Filter npx vitest run -t "adds" vitest.config.ts import { defineConfig } from 'vitest/config' ; export default defineConfig ({ test : { globals : true , environment : 'jsdom' , coverage : { provider : 'v8' , reporter : [ 'text' , 'html' ] }, include : [ 'src/**/*.{test,spec}.{js,ts,tsx}' ], includeSource : [ 'src/**/*.{js,ts}' ], }, }); Deep Patterns → reference/playbook.md § Section Lines 1 Production Configuration Config, workspace, setup file 2 Mocking Patterns vi.mock, spies, timers, fetch 3 React Testing Library Components, hooks, providers 4 Snapshot & Inline Snapshots File, inline, serializers 5 Table-Driven Tests test.each, describe.each 6 In-Source Testing Co-located tests in source 7 API / Integration Testing Server tests with fetch 8 CI/CD Integration GitHub Actions, scripts 9 Debugging Quick-Reference 10 common problems 10 Best Practices Checklist 13 items
Agent 识别该技能的关键词,点击任意一个即可复制。

该技能未提供触发词。

下载的 .skill 包内含以下字段。
字段 说明
format格式标识(skill/v1)
skill_id技能唯一 ID
name技能名称
version版本号
description技能描述
category所属分类(数组)
trigger_words触发词列表
tags标签列表
source来源标识
source_url来源链接(本页地址)
exported_at导出时间(每次下载生成)
system_prompt系统提示词正文
model_config模型参数:provider / model / temperature / max_tokens / top_p
examples示例
install_guide各平台导入说明(Coze / Dify / Claude / 自定义框架)
同一份技能可按不同平台格式导出。
.skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用 下载
.skillpro 增强格式,额外含脚本 / 工具 / 依赖 / 钩子占位 下载
.json 纯 JSON 导出,只含 system_prompt 与模型参数 下载
Coze 带 frontmatter 的 Markdown,Coze 平台导入用 下载
Dify Dify DSL,创建应用后直接导入 下载

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

验证码 --

提交后我们会发送一封确认邮件,点击邮件里的链接才会开始收信。

完全免费,取消任意时间。我们不会发送垃圾邮件。