ワンクリックで
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