Skip to content
Development
Skill

/test-bridge

Bridge Server (TypeScript) のテスト実行・型チェック・テスト記述ガイド

From plugin
ccpocket
1.1k18 skills2 agents2 MCP
Install
$ npx -y skills add K9i-0/ccpocket --skill test-bridge --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/test-bridge

Context preview

The summary Claude sees to decide when to auto-load this skill.

Bridge Server (TypeScript) のテスト実行・型チェック・テスト記述ガイド

SKILL.md

test-bridge.SKILL.md
name: test-bridge
description: Bridge Server (TypeScript) のテスト実行・型チェック・テスト記述ガイド
allowed-tools: Bash(npx:*), Bash(npm:*), Read, Glob, Grep

Bridge Server テスト

実行手順

変更した挙動に対応するテストと静的検証を選ぶ。全体テストは、共通基盤・依存関係への変更や回帰懸念がある場合、または全体検証を依頼された場合に実行する。成功済みの検証を理由なく繰り返さない。以下はコマンドの選択肢。

1. ユニットテスト

npm run test:bridge

特定ファイルのみ:

cd packages/bridge && npx vitest run src/<filename>.test.ts

ウォッチモード (開発中):

cd packages/bridge && npx vitest src/<filename>.test.ts

2. TypeScript 型チェック

npx tsc --noEmit -p packages/bridge/tsconfig.json

テストファイル (`*.test.ts`) と `vitest.config.ts` は `tsconfig.json` の exclude に入っているため、型チェック対象外。

3. カバレッジ (任意)

npm run test:bridge:coverage

テスト記述規約

ファイル配置・命名

  • テストファイルはソースと同じディレクトリに `<module>.test.ts` として配置
  • 例: `src/parser.ts` → `src/parser.test.ts`
  • vitest.config.ts の include パターン: `src/**/*.test.ts`

import

import { describe, it, expect } from "vitest";
  • vitest からのみ import する (jest の互換 API は使わない)
  • テスト対象モジュールは `.js` 拡張子で import する (NodeNext moduleResolution)
  • 例: `import { parseRule } from "./claude-process.js";`

テスト構造

describe("関数名 or クラス名", () => {
  it("動作の説明 (英語)", () => {
    expect(actual).toBe(expected);
  });
});
  • `describe` でテスト対象の関数/クラス単位にグルーピング
  • `it` の説明は英語で、三人称現在形 (`"returns null for empty string"`)
  • 1つの `it` で1つの振る舞いを検証する

テスト対象の方針

  • 純粋関数・ロジック中心にテストする (高ROI)
  • プロセスspawn, ファイルシステム, WebSocket等の外部依存は対象外
  • 現在テスト対象のモジュール:
  • `parser.ts` — parseClaudeEvent, claudeEventToServerMessage, parseClientMessage, normalizeToolResultContent
  • `claude-process.ts` — parseRule, matchesSessionRule, buildSessionRule, toolNeedsApproval, ACCEPT_EDITS_AUTO_APPROVE
  • `image-store.ts` — ImageStore.extractImagePaths

新しいテスト追加時

1. export されている純粋関数があればテスト追加を検討 2. internal関数をテストしたい場合は `export` に変更する (テスト可能性のための export は OK) 3. テスト追加後は型チェックが通ること (`npx tsc --noEmit`) も確認

Read more
Ships withccpocket

Your agents. In your pocket. Codex and Claude, with a chat UI made for your phone. Start a task, approve the next step, and review the result. Pick up the same work on your tablet or Mac.

Get the whole plugin

Other skills on ccpocket.

codex-guide
Skill

codex-guide

Codex の使い方、CLI/app/IDE、rules・hooks・AGENTS.md・skills・subagents・config などを案内する。Codex や OpenAI 製品の仕様を答える前に必ず公式ドキュメントを確認し、rules/approval は `codex execpolicy check`…

@k9i-0@k9i-0View Skill