Testing Skill
Purpose
Generate test files and testing utilities for Vue 3 applications with proper coverage and best practices.
Test File Generation Rules
IMPORTANT: Test files MUST be generated alongside UI components, views, stores, directives, and utilities.
When generating any of the following, ALWAYS create a corresponding test file:
- Vue Components (
src/components/**/*.vue) → {ComponentName}.spec.ts in same directory
- Views (
src/views/**/*.vue) → {ViewName}.spec.ts in same directory
- Store Modules (Vuex:
src/store/modules/*.ts, Pinia: src/stores/*.ts) → {moduleName}.spec.ts in same directory
- Directives (
src/directives/*.ts) → {directiveName}.spec.ts in same directory
- Utilities (
src/shared/utils/*.ts) → {utilityName}.spec.ts in same directory
- Mixins (
src/shared/mixins/*.ts) → {mixinName}.spec.ts in same directory
- Services (
src/services/*.ts) → OPTIONAL - typically mocked in component tests
Test File Location
- Test files live co-located with their source files (not in separate
tests/ directory)
- Naming convention:
{filename}.spec.ts (use .spec.ts consistently)
Testing Frameworks
Jest Testing (if test_framework: jest)
- Use Jest with Vue Test Utils (
@vue/test-utils) for component testing
- Use
@vue/vue3-jest transformer for .vue files
- Use
ts-jest for TypeScript files
- Mock external dependencies (axios, router, store)
- Target >80% coverage for services and stores
- Target >70% coverage for components
- Test file naming:
{filename}.spec.ts
- Configuration:
jest.config.cjs (handled by jest-config skill)
Vitest Testing (if test_framework: vitest)
- Use Vitest with Vue Test Utils for component testing
- Native ESM support with faster execution
- Use
@vitest/ui for interactive test UI
- Mock external dependencies (axios, router, store)
- Target >80% coverage for services and stores
- Target >70% coverage for components
- Test file naming:
{filename}.spec.ts or {filename}.test.ts
- Configuration:
vitest.config.ts (handled by vitest-config skill)
Test Coverage Requirements
- Components: >70% coverage (focus on user interactions, computed properties, methods)
- Views: >70% coverage (lifecycle, navigation, major workflows)
- Stores: >80% coverage (state mutations, actions, getters)
- Utilities: >80% coverage (all functions and edge cases)
- Directives: >70% coverage (behavior and DOM manipulation)
Test Organization Best Practices
- Describe blocks: Group related tests logically
- Component/View name as top-level describe
- Group by: lifecycle hooks, computed properties, methods, events
- Test naming: Use descriptive test names that explain expected behavior
- AAA Pattern: Arrange, Act, Assert in each test
- Mocking: Mock external dependencies (API calls, router, store)
- Cleanup: Use
afterEach to clear mocks and reset state
- Isolation: Each test should be independent and not rely on others
Example Files
See: examples.md in this directory for complete test templates:
- Component tests (Options API)
- Component tests (Composition API)
- View tests
- Store tests (Vuex)
- Store tests (Pinia)
Notes
- Test templates vary based on
vue_api_pattern (composition-api vs options-api)
- Test templates vary based on
state_management (pinia vs vuex)
- All test files should use the same testing framework specified in configuration
- Co-location of tests with source files improves maintainability
1---2name: testing3description: Generates test files and testing utilities for Vue 3 applications. Ensures mandatory .spec.ts files are created alongside components, views, stores, directives, and utilities.4---56# Testing Skill78## Purpose9Generate test files and testing utilities for Vue 3 applications with proper coverage and best practices.1011## Test File Generation Rules1213**IMPORTANT**: Test files MUST be generated alongside UI components, views, stores, directives, and utilities.1415When generating any of the following, **ALWAYS create a corresponding test file**:16- **Vue Components** (`src/components/**/*.vue`) → `{ComponentName}.spec.ts` in same directory17- **Views** (`src/views/**/*.vue`) → `{ViewName}.spec.ts` in same directory18- **Store Modules** (Vuex: `src/store/modules/*.ts`, Pinia: `src/stores/*.ts`) → `{moduleName}.spec.ts` in same directory19- **Directives** (`src/directives/*.ts`) → `{directiveName}.spec.ts` in same directory20- **Utilities** (`src/shared/utils/*.ts`) → `{utilityName}.spec.ts` in same directory21- **Mixins** (`src/shared/mixins/*.ts`) → `{mixinName}.spec.ts` in same directory22- **Services** (`src/services/*.ts`) → **OPTIONAL** - typically mocked in component tests2324## Test File Location25- Test files live **co-located** with their source files (not in separate `tests/` directory)26- Naming convention: `{filename}.spec.ts` (use `.spec.ts` consistently)2728## Testing Frameworks2930### Jest Testing (if test_framework: jest)31- Use Jest with Vue Test Utils (`@vue/test-utils`) for component testing32- Use `@vue/vue3-jest` transformer for `.vue` files33- Use `ts-jest` for TypeScript files34- Mock external dependencies (axios, router, store)35- Target >80% coverage for services and stores36- Target >70% coverage for components37- Test file naming: `{filename}.spec.ts`38- Configuration: `jest.config.cjs` (handled by jest-config skill)3940### Vitest Testing (if test_framework: vitest)41- Use Vitest with Vue Test Utils for component testing42- Native ESM support with faster execution43- Use `@vitest/ui` for interactive test UI44- Mock external dependencies (axios, router, store)45- Target >80% coverage for services and stores46- Target >70% coverage for components47- Test file naming: `{filename}.spec.ts` or `{filename}.test.ts`48- Configuration: `vitest.config.ts` (handled by vitest-config skill)4950## Test Coverage Requirements5152- **Components**: >70% coverage (focus on user interactions, computed properties, methods)53- **Views**: >70% coverage (lifecycle, navigation, major workflows)54- **Stores**: >80% coverage (state mutations, actions, getters)55- **Utilities**: >80% coverage (all functions and edge cases)56- **Directives**: >70% coverage (behavior and DOM manipulation)5758## Test Organization Best Practices59601. **Describe blocks**: Group related tests logically61 - Component/View name as top-level describe62 - Group by: lifecycle hooks, computed properties, methods, events632. **Test naming**: Use descriptive test names that explain expected behavior643. **AAA Pattern**: Arrange, Act, Assert in each test654. **Mocking**: Mock external dependencies (API calls, router, store)665. **Cleanup**: Use `afterEach` to clear mocks and reset state676. **Isolation**: Each test should be independent and not rely on others6869## Example Files70See: `examples.md` in this directory for complete test templates:71- Component tests (Options API)72- Component tests (Composition API)73- View tests74- Store tests (Vuex)75- Store tests (Pinia)7677## Notes78- Test templates vary based on `vue_api_pattern` (composition-api vs options-api)79- Test templates vary based on `state_management` (pinia vs vuex)80- All test files should use the same testing framework specified in configuration81- Co-location of tests with source files improves maintainability