원클릭으로
vitest
Vitest testing standards. Use when writing or reviewing test files (.test.ts, .spec.ts, .test.tsx).
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Vitest testing standards. Use when writing or reviewing test files (.test.ts, .spec.ts, .test.tsx).
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Deep interview for a single feature or module brief that produces a final spec or implementation plan.
@nextnode-solutions/logger standards. Reference this skill when a project uses @nextnode-solutions/logger or when logger integration is being added.
Manage n8n workflows on the NextNode automation instance with the local n8n-cli tool.
NextNode brand guidelines — color palette, typography, logo system, and per-project branding rules. Use when doing UI/frontend work on a NextNode project.
NextNode ecosystem hub. Auto-load when working on any NextNode or SaaS project — covers nextnode.toml config, CI workflows, docker-compose rules, and cross-references to package skills.
Audit a NextNode/SaaS project against all NextNode standards — produces a compliance report with pass/fail/missing status for every required item.
| name | vitest |
| description | Vitest testing standards. Use when writing or reviewing test files (.test.ts, .spec.ts, .test.tsx). |
| user-invocable | false |
<Child title={title} /> then assert Child got title)expect.objectContaining() and expect.arrayContaining() to test what matters without breaking on additionsBefore writing any test, pass ALL 4 gates:
test-id is a last resort, not a default — if you need it, the component likely has an a11y issueuserEvent over fireEvent — always (closer to real user behavior)msw) — NEVER mock React hooks directlyvi.restoreAllMocks() in afterEachvi.useRealTimers() in afterEach when using fake timersvi.hoisted() for shared module-level mocksvi.mock() — easier to test, easier to read// WARNING: over-mocked — code coupling issue, consider refactoring and flag to team leadtoHaveBeenCalledWith(expected) — NEVER toHaveBeenCalled() alonetoEqual for deep object comparison, toBe for primitives/referencestoMatchInlineSnapshot() for complex outputs — NEVER external .snap filesexpect are fine if testing the same behaviorexpect.objectContaining() / expect.arrayContaining() to avoid brittle exact matchesdescribe blocks group by behavior/feature, not by method nameit('returns empty array when filter matches nothing')createUser(), buildOrder()) for test data — NEVER inline object literals everywherebeforeEach — NEVER in module scope (test isolation)describe nesting — deeper = bad test organizationawait async assertions — un-awaited expect silently passesvi.waitFor() for eventually-consistent behavior (DOM updates, debounced calls)vi.advanceTimersByTime(ms) over vi.runAllTimers() for precise controlafterEach: cancel pending timers, abort controllers, unmount componentsuser-service.ts → user-service.test.ts__test-utils__/ directories, not generic utils/Reference structure for strict TDD workflows:
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
// Factory functions at top
const createTestData = (overrides = {}) => ({
// sensible defaults representing valid state
...overrides,
})
describe('<Feature> — <behavior group>', () => {
beforeEach(() => {
// shared setup — reset state, seed mocks
})
afterEach(() => {
vi.restoreAllMocks()
})
it('<scenario> — <expected outcome>', () => {
// Arrange
const input = createTestData()
// Act
const result = functionUnderTest(input)
// Assert
expect(result).toEqual(expected)
})
describe('edge cases', () => {
it('handles empty input', () => { /* ... */ })
it('handles null/undefined', () => { /* ... */ })
it('handles boundary values', () => { /* ... */ })
})
describe('error paths', () => {
it('throws on invalid input', () => { /* ... */ })
it('returns fallback on failure', () => { /* ... */ })
})
})
All NextNode/SaaS projects use Husky with a pre-push hook that runs pnpm test before every push. This means:
pnpm test mentally and ensure all existing + new tests passBottom line: treat
pnpm testas a hard gate. If Claude writes code that breaks tests, the user cannot push. Every code change must be test-aware.
getByTestId as default query strategy — it masks a11y issuesvi.mock() without vi.restoreAllMocks() in afterEachany in test types — use test-specific types or unknown with type guards.snap files — inline snapshots only (toMatchInlineSnapshot())fireEvent when userEvent is available