mcpField
T
test-focus

test-focus

github.com/laurigatesテスト・品質5956 回インストール1 日前に更新
リポジトリ

test-focus について

test-focusは、失敗したテストファイルを個別に反復実行する開発者向けのスキルです。一般的なテストフレームワークを判別し、失敗時に停止する設定で実行でき、逐次実行やデバッグにも対応します。

主な機能

  1. 01フレームワーク別の実行コマンド
  2. 02単一ファイルの失敗時停止実行
  3. 03逐次実行の選択
  4. 04画面表示またはデバッグモード
  5. 05失敗情報と再実行コマンド

活用シーン

  1. 01既知の失敗テストの迅速な再実行
  2. 02共有状態テストの逐次実行
  3. 03単一ブラウザーテストファイルの画面デバッグ

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/laurigates/claude-plugins --skill test-focus

インストール後、Claude Code で/test-focusを入力して読み込まれたか確認します。

詳細

このスキルを使用するタイミング

次の場合にこのスキルを使用...次の場合は test-run を使用...
フェイルファストのフィードバックを得ながら、失敗している単一の仕様テストを反復実行する場合プロジェクトの全テストスイートを実行する場合
WebGL または共有状態を使用するテストを直列実行する場合多数のファイルをウォッチモードでテストする場合(test-quick を使用)
1 つのテストファイルをヘッド表示/デバッグモードで実行する場合テスト結果のディレクトリをトリアージする場合(test-analyze を使用)
既知の問題があるファイルについて、30 秒未満でフィードバックを得る場合どのティアを実行するか選ぶ場合(test-tier-selection を使用)

コンテキスト

  • プロジェクトファイル:!find . -maxdepth 1 \( -name 'pyproject.toml' -o -name 'package.json' -o -name 'Cargo.toml' -o -name 'go.mod' \)
  • Playwright 設定:!find . -maxdepth 1 -name 'playwright.config.*'
  • Vitest 設定:!find . -maxdepth 1 \( -name 'vitest.config.*' -o -name 'vite.config.*' \)
  • Jest 設定:!find . -maxdepth 1 -name 'jest.config.*'
  • Pytest 設定:!find . -maxdepth 1 \( -name pyproject.toml -o -name setup.cfg \) -exec grep -l 'pytest' {} +
  • Package.json の有無:!find . -maxdepth 1 -name 'package.json' -type f

パラメーター

  • $1(必須):テストファイルのパスまたはパターン(例:login.spec.ts、tests/e2e/auth.spec.ts)
  • --serial:単一のワーカーで順次実行します(WebGL、データベースのテストに便利です)
  • --debug:ビジュアルデバッグ用にデバッグ/ヘッド表示モードで実行します

タスク

開発中の反復を迅速に行うため、単一のテストファイルをフェイルファストモードで実行します。フィードバック時間を最小限に抑えるため、最初の失敗が発生したら直ちに停止します。

1. テストフレームワークを検出してコマンドを作成する

Playwright(playwright.config.* が存在する場合):

# Standard fail-fast
bunx playwright test "$FILE" --max-failures=1 --reporter=line

# With --serial (WebGL, shared state)
bunx playwright test "$FILE" --max-failures=1 --workers=1 --reporter=line

# With --debug
bunx playwright test "$FILE" --max-failures=1 --headed --debug

Vitest(vitest.config.* または vite.config.* が存在する場合):

# Standard fail-fast
bunx vitest run "$FILE" --bail=1 --reporter=dot

# With --serial
bunx vitest run "$FILE" --bail=1 --pool=forks --poolOptions.threads.singleThread --reporter=dot

# With --debug
bunx vitest run "$FILE" --bail=1 --inspect-brk

Jest(jest.config.* が存在する場合):

# Standard fail-fast
bunx jest "$FILE" --bail --silent

# With --serial
bunx jest "$FILE" --bail --runInBand --silent

# With --debug
bunx jest "$FILE" --bail --runInBand

pytest(Python プロジェクト):

# Standard fail-fast
python -m pytest "$FILE" -x -v --tb=short

# With --serial (already serial by default)
python -m pytest "$FILE" -x -v --tb=short

# With --debug
python -m pytest "$FILE" -x -v --tb=long -s

Cargo test(Rust プロジェクト):

# Standard fail-fast
cargo test --test "$FILE" -- --test-threads=1

# With --debug
cargo test --test "$FILE" -- --test-threads=1 --nocapture

Go test:

# Standard fail-fast
go test -v -failfast "$FILE"

# With --debug
go test -v -failfast "$FILE" -count=1
2. テストを実行する

作成したコマンドを実行します。出力を取得して表示します。

3. 結果を分析する

テストが成功した場合:

[FILE]: PASSED
Duration: Xs

Ready for next iteration or file.

テストが失敗した場合:

[FILE]: FAILED (stopped at first failure)
Duration: Xs

First failure:
  Test: [test name]
  Error: [brief error message]
  Location: [file:line]

Quick actions:
- Fix the issue and re-run: /test:focus [same file]
- Debug visually: /test:focus [file] --debug
- See full output: /test:run [file]
4. 再実行コマンドを提示する

必ず再実行用の正確なコマンドを表示します:

Rerun: /test:focus $FILE

時間短縮のコンテキスト

対象を絞ったテストにより、フィードバック時間を大幅に短縮できます:

方法典型的な所要時間用途
/test:focus2~30 秒単一ファイルを反復実行する場合
/test:quick30 秒変更後の単体テスト
/test:full5~30 分コミット/PR の前

エージェント向け最適化

コンテキストフラグ
Playwright の高速実行--max-failures=1 --reporter=line
Playwright の WebGL--max-failures=1 --workers=1 --reporter=line
Vitest の高速実行--bail=1 --reporter=dot
Jest の高速実行--bail --silent
pytest の高速実行-x -v --tb=short

エラー処理

  • ファイルが見つからない場合:glob で類似するテストファイルを一覧表示し、修正案を提示します
  • フレームワークを検出できない場合:"test" を含む利用可能な package.json スクリプトを表示します
  • テストがタイムアウトした場合:--serial フラグの使用、またはタイムアウトの延長を提案します

コメント