Agent skill
Vitest Testing Patterns
Vitest-based test writing with mocking strategies for Remotion and AWS services. Use this when creating test files (__tests__/*.test.ts), writing unit tests for components or server logic, mocking external dependencies, or validating API endpoints and video rendering behavior.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/spekka-testing-test-writing
SKILL.md
Vitest Testing Patterns
This Skill provides Claude Code with specific guidance on how it should handle testing test writing.
When to use this skill:
- Creating new test files in tests/ or *.test.ts
- Writing unit tests for API endpoints in server/tests/
- Testing Remotion components or animation calculations
- Mocking Remotion bundler, renderer, or AWS S3 client
- Validating request/response behavior
- Testing frame calculations or timing logic
Instructions
- Vitest Framework: Use Vitest for all tests; leverage native ESM and TypeScript support
- Test File Location: Place tests in
__tests__/directories or colocate as*.test.tsfiles - Write Minimal Tests During Development: Focus on completing feature implementation first, then add strategic tests at logical completion points
- Test Core Workflows: Test critical paths: video rendering, API endpoints, animation calculations, S3 uploads
- Mock External Services: Mock Remotion bundler/renderer and AWS S3 client in tests
- Test Behavior, Not Implementation: Focus on what the code does (e.g., "renders correct frame count") not how
- Clear Test Names: Use descriptive names:
test('returns 404 when video not found', ...) - Fast Execution: Unit tests should run in milliseconds; mock heavy operations like video rendering
Examples:
// Good: Clear mocking, behavior focus, descriptive
import { describe, test, expect, vi } from 'vitest';
import { renderVideo } from '../render';
vi.mock('@remotion/bundler');
vi.mock('@remotion/renderer');
describe('renderVideo', () => {
test('returns S3 URL after successful render', async () => {
const result = await renderVideo({ month: 1, year: 2024, books: [] });
expect(result.s3Url).toMatch(/^https:\/\/.*\.mp4$/);
});
test('throws error when month is invalid', async () => {
await expect(renderVideo({ month: 13, year: 2024 }))
.rejects.toThrow('Invalid month');
});
});
// Bad: Implementation details, vague names
test('it works', () => {
const r = render();
expect(r.internal.state).toBe('done');
});
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?