ワンクリックで
tzurot-testing
Testing procedures. Invoke with /tzurot-testing for test execution, coverage audits, and debugging test failures.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Testing procedures. Invoke with /tzurot-testing for test execution, coverage audits, and debugging test failures.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
Git workflow procedures. Invoke with /tzurot-git-workflow for commit, PR, and release procedures.
Multi-perspective AI consultation. Invoke with /tzurot-council-mcp for major refactors (>500 lines), structured debugging after failed attempts, or when a technical decision has multiple viable approaches.
Documentation and auto-memory freshness audit. Invoke with /tzurot-doc-audit to review docs and Claude auto-memory for staleness, items in the wrong layer, and missing-tool drift.
PR review-response iteration: classify each finding by EDIT SHAPE (trivial → auto-apply as a test-gated fixup commit; semantic → ASK), check reviewer-vs-agent signal conflict, batch-present the four sections, cap at 3 automated rounds. Invoke with /tzurot-review-response the moment a claude-review or human reviewer posts findings on a PR — before applying anything.
The recurring-bug remediation protocol: runtime evidence → root cause → exhaustive class sweep → seam-tier regression test → structural guard. Invoke with /tzurot-bug-remediation when a bug recurs, a "fixed" class regresses, the owner says a failure "keeps biting", OR at the FIRST fix of a path-specific UI/flow bug (create/edit/browse/view/delete) — to sweep sibling flows before declaring it fixed.
Session workflow procedures. Invoke with /tzurot-docs for session start/end, CURRENT.md and backlog management.
SOC 職業分類に基づく
| name | tzurot-testing |
| description | Testing procedures. Invoke with /tzurot-testing for test execution, coverage audits, and debugging test failures. |
| lastUpdated | 2026-07-20 |
Invoke with /tzurot-testing for test-related procedures.
Testing patterns are in .claude/rules/02-code-standards.md - they apply automatically.
# Run all tests
pnpm test
# Run specific service
pnpm --filter @tzurot/ai-worker test
# Run specific file
pnpm test -- MyService.test.ts
# Run the component tier (PGLite) — NOT included in `pnpm test`
pnpm test:component
# Run the integration + contract tiers (real Redis/Postgres) — NOT in `pnpm test`
pnpm test:integration
# Run with coverage
pnpm test:coverage
# Run only changed packages
pnpm focus:test
# Run unified audit (CI does this automatically)
pnpm ops test:audit
# Filter by category
pnpm ops test:audit --category=services
pnpm ops test:audit --category=contracts
# Update baseline (after closing gaps)
pnpm ops test:audit --update
# Strict mode (fails on ANY gap)
pnpm ops test:audit --strict
Unified Baseline: test-coverage-baseline.json (project root)
Tiers are canonically defined in one place —
Test Tier Taxonomy.
This table is the suffix→tier quick reference; don't re-define the tiers here
(the pnpm ops guard:test-taxonomy gate enforces the single-source link).
| Suffix / location | Tier (taxonomy) | Infrastructure | Location |
|---|---|---|---|
*.test.ts | Unit | Fully mocked | Next to source |
*.component.test.ts | Component (one service, PGLite) | PGLite | Next to source |
*.integration.test.ts | Integration (real DB+Redis) | Real services | tests/e2e/ |
*.contract.test.ts | Contract (provider↔consumer) | Real services | tests/e2e/contracts/ |
Each suffix names its tier directly. Schema test ≠ contract test: a Zod schema test (a plain
*.test.ts) validates one type's own rules (unit-tier); a contract test verifies two services agree. Runpnpm ops test:tiersfor the per-package tier distribution.
The unit pnpm test config EXCLUDES the .component / .integration /
.contract suffixes. A contract/integration/component test "passes" under
pnpm test by NOT running at all — so a green unit run is NOT evidence it works.
| Suffix | Verify with |
|---|---|
*.test.ts (unit) | pnpm test |
*.component.test.ts | pnpm test:component |
*.integration.test.ts / *.contract.test.ts | pnpm test:integration |
When you touch a .contract / .integration test, run pnpm test:integration
(Redis + Postgres up: podman start tzurot-redis tzurot-postgres); a
.component test, pnpm test:component. pnpm test / pnpm --filter <pkg> test
is the unit tier ONLY. CI's component-integration-tests job runs test:component +
test:integration, so it catches what a unit-only local run silently skipped —
don't let CI be the first thing that actually executes your contract test.
Gotcha for mention/ID fixtures: tests need a valid 17–19 digit Discord
snowflake — isValidDiscordId silently drops toy ids like 555 before
resolution, making the assertion pass/fail for the wrong reason.
pnpm test -- MyService.test.ts --reporter=verbose
// ❌ WRONG - Promise rejection warning
const promise = asyncFunction();
await vi.runAllTimersAsync(); // Rejection happens here!
await expect(promise).rejects.toThrow(); // Too late
// ✅ CORRECT - Attach handler BEFORE advancing
const promise = asyncFunction();
const assertion = expect(promise).rejects.toThrow('Error');
await vi.runAllTimersAsync();
await assertion;
beforeEach(() => {
vi.clearAllMocks(); // Clear call history, keep impl
});
afterEach(() => {
vi.restoreAllMocks(); // Restore originals (spies only)
});
// Use async factory for vi.mock hoisting
vi.mock('./MyService.js', async () => {
const { mockMyService } = await import('../test/mocks/MyService.mock.js');
return mockMyService;
});
// Import accessors after vi.mock
import { getMyServiceMock } from '../test/mocks/index.js';
it('should call service', () => {
expect(getMyServiceMock().someMethod).toHaveBeenCalled();
});
describe('UserService', () => {
let pglite: PGlite;
let prisma: PrismaClient;
beforeAll(async () => {
pglite = new PGlite({ extensions: { vector, citext } });
await pglite.exec(loadPGliteSchema());
prisma = new PrismaClient({ adapter: new PrismaPGlite(pglite) });
});
it('should create user', async () => {
const service = new UserService(prisma);
const userId = await service.getOrCreateUser('123', 'testuser');
expect(userId).toBeDefined();
});
});
⚠️ ALWAYS use loadPGliteSchema() - NEVER create tables manually!
Component tests (*.component.test.ts) run separately from unit tests and are not included in pnpm test or pre-push hooks.
Always run pnpm test:component after:
| Change | Why |
|---|---|
| Add/remove slash command options | CommandHandler.component.test.ts snapshots capture full command structure |
| Add/remove subcommands | Same snapshot tests |
| Restructure command directories | getCommandFiles() discovery changes affect command loading |
| Change component prefix routing | Component tests verify button/select menu routing |
Update snapshots with: pnpm vitest run --config vitest.component.config.ts <file> --update
The user is the ONLY manual-QA executor — usually on a phone, across session crashes and compactions. Every request for manual verification MUST be a complete, self-contained instruction with all five parts:
buildModelFooterText, not a persona's in-character explanation) before
stating it.Checklists are durable artifacts, not chat. A release smoke-test checklist
is written into CURRENT.md (with per-item status), so it survives compaction
and the user can re-consult it from a phone. Track progress there as results
come in ("from my quick tests how much of the checklist did that get us?" must
be answerable from the file). Justify every case — a bloated matrix wastes the
user's time; each case states what it uniquely proves. After the user reports,
close the loop with runtime evidence (logs) when the user-visible outcome can't
prove the new code path ran.
Each checklist item carries a confidence tier — high (CI + review + blast-radius cover it; ships without a manual round) or needs-smoke (with the one-line reason confidence is limited: runtime-unverified path, mobile rendering, a failure sequence tests can't reach). Surface only the needs-smoke tier for the owner to run — they don't want to hand-test high-confidence changes ("what's the level of confidence… I don't feel like testing them unless confidence is limited").
.component.test.ts.test.ts (unit-tier; no dedicated schema suffix)pnpm ops test:audit to verify no new gapsdocs/reference/guides/TESTING.mdservices/*/src/test/mocks/docs/reference/testing/PGLITE_SETUP.mddocs/reference/testing/COVERAGE_AUDIT_SYSTEM.md.claude/rules/02-code-standards.md