Back to list
snhrm

test-runner

by snhrm

フロントエンドの依存パッケージのEOL(End of Life)状況をチェックし、サポート終了やセキュリティリスクのあるパッケージを検出するプラグイン

0🍴 0📅 Nov 30, 2025

SKILL.md


name: test-runner description: lint、test、buildコマンドを実行し、結果を解析する。エラー時は原因分析と修正提案を行う allowed-tools: Bash, Read, Grep

テスト実行スキル

役割: lint/test/buildの実行と結果解析に特化。

入力: 実行コマンド、プロジェクト情報(呼び出し元から渡される)

コマンド実行

lint:fix(推奨)

ESLint自動修正 + TypeScript型チェックを実行:

# npm
npm run lint:fix

# yarn
yarn lint:fix

# pnpm
pnpm lint:fix

# bun
bun run lint:fix

lint:fixコマンドがない場合はpackage.jsonに追加:

{
  "scripts": {
    "lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix && tsc --noEmit"
  }
}
プロジェクト構成推奨lint:fixコマンド
ESLint + TypeScripteslint src --ext .js,.jsx,.ts,.tsx --fix && tsc --noEmit
Next.jsnext lint --fix && tsc --noEmit
Biomebiome check --write src && tsc --noEmit

Lint(従来)

# npm
npm run lint

# yarn
yarn lint

# pnpm
pnpm lint

# bun
bun run lint

# 自動修正(--fix オプション)
npm run lint -- --fix
yarn lint --fix
pnpm lint --fix
bun run lint --fix

Test

# npm
npm test
npm run test

# yarn
yarn test

# pnpm
pnpm test

# bun
bun test

# 特定ファイルのみ
npm test -- {path}
yarn test {path}
pnpm test {path}
bun test {path}

# watchモードを無効化
npm test -- --watchAll=false
CI=true npm test

Build

# npm
npm run build

# yarn
yarn build

# pnpm
pnpm build

# bun
bun run build

型チェック

# TypeScript
npx tsc --noEmit

# または
npm run type-check
yarn type-check
pnpm type-check

結果解析

ESLint結果

# JSON形式で出力
npm run lint -- --format json

# 出力例
[
  {
    "filePath": "/path/to/file.ts",
    "messages": [
      {
        "ruleId": "no-unused-vars",
        "severity": 2,
        "message": "'x' is defined but never used",
        "line": 10,
        "column": 5
      }
    ],
    "errorCount": 1,
    "warningCount": 0
  }
]

Jest/Vitest結果

# JSON形式で出力
npm test -- --json --outputFile=test-results.json

# 出力例
{
  "numTotalTests": 50,
  "numPassedTests": 48,
  "numFailedTests": 2,
  "testResults": [
    {
      "name": "/path/to/test.ts",
      "status": "failed",
      "assertionResults": [
        {
          "title": "should work",
          "status": "failed",
          "failureMessages": ["Error: ..."]
        }
      ]
    }
  ]
}

TypeScript結果

# エラー出力例
src/components/Example.tsx(15,5): error TS2345:
  Argument of type 'string' is not assignable to parameter of type 'number'.

Build結果

# Next.js
# エラー出力例
Error: Build failed because of webpack errors

# Vite
# エラー出力例
error during build:
RollupError: ...

エラー分類

Lint エラー

カテゴリ自動修正
フォーマットindent, semi, quotes可能
未使用変数no-unused-vars要確認
インポート順import/order可能
React Hooksreact-hooks/rules-of-hooks不可

Test エラー

カテゴリ原因対処
アサーション失敗期待値不一致テストまたはコード修正
タイムアウト非同期処理タイムアウト延長またはモック
モジュール解決import失敗パス確認、モック追加
スナップショット不一致スナップショット更新

Build エラー

カテゴリ原因対処
型エラーTypeScript型修正
モジュール解決パッケージ不足インストール
設定エラーconfig不正設定修正
メモリ不足heap overflowNODE_OPTIONS調整

修正コマンド

Lintエラーの自動修正

# ESLint
npm run lint -- --fix

# Prettier
npx prettier --write .

# 両方
npm run lint -- --fix && npx prettier --write .

スナップショット更新

# Jest
npm test -- -u
npm test -- --updateSnapshot

# Vitest
npx vitest --update

キャッシュクリア

# Jest
npx jest --clearCache

# Next.js
rm -rf .next

# 一般
rm -rf node_modules/.cache

出力フォーマット

{
  "lint": {
    "status": "pass|fail",
    "command": "{実行コマンド}",
    "errors": [
      {
        "file": "{ファイルパス}",
        "line": 10,
        "column": 5,
        "rule": "{ルール名}",
        "message": "{エラーメッセージ}",
        "severity": "error|warning",
        "fixable": true
      }
    ],
    "summary": {
      "errorCount": 5,
      "warningCount": 10,
      "fixableCount": 12
    }
  },
  "test": {
    "status": "pass|fail",
    "command": "{実行コマンド}",
    "summary": {
      "total": 50,
      "passed": 48,
      "failed": 2,
      "skipped": 0,
      "duration": "15.3s"
    },
    "failures": [
      {
        "file": "{テストファイル}",
        "test": "{テスト名}",
        "message": "{エラーメッセージ}",
        "expected": "{期待値}",
        "actual": "{実際の値}"
      }
    ]
  },
  "build": {
    "status": "pass|fail|skipped",
    "command": "{実行コマンド}",
    "errors": [
      {
        "file": "{ファイルパス}",
        "line": 15,
        "message": "{エラーメッセージ}",
        "type": "typescript|webpack|rollup"
      }
    ],
    "duration": "45.2s"
  },
  "recommendations": [
    {
      "type": "auto_fix|manual_fix|investigate",
      "description": "{推奨アクション}",
      "command": "{実行コマンド(あれば)}"
    }
  ]
}

CI環境での実行

# CI環境フラグ
CI=true npm test
CI=true npm run build

# 並列実行の制限(メモリ節約)
npm test -- --maxWorkers=2

# カバレッジ出力
npm test -- --coverage

注意事項

  • watchモードを無効化: CI環境やスクリプト実行時は必須
  • タイムアウト設定: 長時間テストには適切なタイムアウトを設定
  • 並列実行の調整: メモリ不足時はワーカー数を減らす
  • エラー出力の保存: 後で分析できるようにログを保存

Score

Total Score

45/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

0/5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon