원클릭으로
testing-unit-vitest
Writes and maintains unit tests using Vitest. To be used for testing business logic in services and utilities.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Writes and maintains unit tests using Vitest. To be used for testing business logic in services and utilities.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Defines the Entity-Relationship (ER) model for the system based on the feature specifications. To be used for designing the data structures and relationships needed to implement the features.
Generates an Architecture Design Document (ADD) for software projects. To be used when designing a product architecture
Generates a Product Requirements Document (PRD) for software projects. To be used when analyzing a project to create a PRD.
Writes the specification with problem definition, solution outline, and acceptance criteria. To be used to specify a feature, bug correction, or enhancement.
Creates a detailed implementation plan for a given feature specification. To be used for planning the implementation of feature specifications.
Creates the base foundation for the agent's workflow. This prompt is used to set up the initial context and instructions for the agent.
| name | testing-unit-vitest |
| description | Writes and maintains unit tests using Vitest. To be used for testing business logic in services and utilities. |
When asked to write or maintain unit tests, follow these guidelines:
validation.spec.ts next to validation.ts){filename}.spec.ts patterntests/ directory for HTTP-layer integration testsUse describe/it blocks with arrange-act-assert pattern:
import { describe, it, expect, beforeEach, vi } from 'vitest';
describe('MyService', () => {
beforeEach(() => {
// Setup for each test
});
describe('methodName', () => {
it('should do something specific', () => {
// Arrange: Set up test data
const input = { /* ... */ };
// Act: Execute the code under test
const result = service.method(input);
// Assert: Verify the outcome
expect(result).toBe(expected);
});
});
});
Use vi.fn() for repository interfaces and external services:
import { vi } from 'vitest';
const mockRepo = {
save: vi.fn(),
findById: vi.fn(),
findAll: vi.fn(),
};
// Inject mocked repository
const service = new MyService(mockRepo);
// Set return values
vi.mocked(mockRepo.findById).mockReturnValue(mockData);
// Verify calls
expect(mockRepo.save).toHaveBeenCalledWith(expected);
expect(mockRepo.save).toHaveBeenCalledTimes(1);
npm run test:dev - Auto-rerun tests during developmentnpm run test:unit - Run all unit tests oncenpm run test:coverage - Generate coverage reportnpm test - Run Playwright tests independentlyit('should...') statementsexpect(value).toBe(expected); // Strict equality
expect(value).toEqual(expected); // Deep equality
expect(value).toBeInstanceOf(Class); // Instance check
expect(value).toBeUndefined(); // Undefined check
expect(array).toHaveLength(3); // Array length
expect(() => fn()).toThrow(ErrorClass); // Exception check
expect(mockFn).toHaveBeenCalledWith(arg); // Mock verification
expect(mockFn).toHaveBeenCalledTimes(1); // Call count
For advanced features, see Vitest documentation: