unit-test-module-mocking
Basic Vitest module mocking pattern with vi.mock.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Basic Vitest module mocking pattern with vi.mock.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Create or update custom React hooks with clear API design, TypeScript-friendly patterns, and test-first workflow. Use when the user asks to make/build/create/modify a custom hook, refactor hook logic, or add/update hook tests.
Write and maintain unit tests with Vitest. Test titles MUST be English `it('should ...')` strings. Use when adding or updating unit tests, improving test coverage, or handling unavoidable coverage gaps with documented ignore comments.
Keep real exports and override only selected functions in Vitest.
Mocking patterns for Vitest unit tests. Read this only when mocking is required.
| name | unit-test-module-mocking |
| description | Basic Vitest module mocking pattern with vi.mock. |
import { vi } from 'vitest'vi.mock('./some-module', () => ({
namedExport: vi.fn(),
default: { foo: vi.fn() },
}))
After the real import runs, use vi.mocked(namedExport) for typing, or assert with expect(namedExport).toHaveBeenCalled().