Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →帮助开发者为 Vue 3 组件编写单元测试。当用户需要添加单元测试时使用。
.claude/skills/tencentblueking-chat-x-unit-test/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 60% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -47% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 0% | 0% |
| case-07 | ✗→✓ | ▲ Improved | -36% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 12% | 0% |
测试文件与组件同目录,命名为 组件名.spec.ts。
bashpnpm --filter @blueking/chat-x test # 所有测试 npx vitest run src/components/your-component # 指定目录
typescriptimport { defineComponent, h } from 'vue'; import { type VueWrapper, mount } from '@vue/test-utils'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import YourComponent from './your-component.vue'; vi.mock('vue-tippy', () => ({ /* ... */ })); describe('YourComponent', () => { let wrapper: VueWrapper; beforeEach(() => { vi.clearAllMocks(); }); afterEach(() => { wrapper?.unmount(); }); it('应该正确渲染', () => { wrapper = mount(YourComponent); expect(wrapper.find('.your-component').exists()).toBe(true); }); });
修改组件代码时必须同步更新测试用例。
skill://chat-x-unit-test/references/mock-patterns.mdskill://chat-x-unit-test/references/test-qa.mdskill://chat-x-unit-test/references/test-strategies.mdskill://chat-x-unit-test/references/mock-patterns.mdskill://chat-x-unit-test/references/test-qa.mdskill://chat-x-unit-test/references/test-strategies.md> 根据 SKILL.md 中的 IF-THEN 规则判断是否需要加载
Other measured skills in the registry, with their headline benchmark lift.