testing:unit-tests
Create comprehensive unit tests for components, modules, stores, and utilities. Use when asked to write tests, add test coverage, or test a specific file.
Files1
View on GitHubSKILL.md.claude/skills/testing/unit-tests/SKILL.md
GitHubUnit Test Creation
Create unit tests following project conventions.
Usage
/testing:unit-tests [target]- Create tests for specific file/testing:unit-tests scan- Find files needing tests
Test Patterns
<!-- Customize these patterns for your framework -->Component Testing
import { describe, expect, it } from 'vitest';
describe('MyComponent', () => {
it('renders correctly', async () => {
// Mount component with test utilities
// Assert expected behavior
});
});
Module/Composable Testing
import { describe, expect, it } from 'vitest';
describe('useMyModule', () => {
it('returns expected structure', () => {
const result = useMyModule();
expect(result).toBeDefined();
});
});
Store Testing
import { describe, expect, it } from 'vitest';
describe('MyStore', () => {
it('initializes correctly', () => {
const store = useMyStore();
expect(store.items).toEqual([]);
});
});
File Locations
| Source | Test Location |
|---|---|
src/components/Card.vue |
tests/components/Card.test.ts |
src/composables/useData.ts |
tests/composables/useData.test.ts |
src/stores/data.ts |
tests/stores/data.test.ts |
Workflow
- Analyze target file structure and exports
- Create test file in appropriate directory
- Cover: happy path, edge cases, error conditions
- Run tests to verify
- Check coverage improvement