senior-qa について
React と Next.js アプリ向けの QA スキルで、テストのひな形生成、カバレッジ分析、Playwright の E2E テスト作成を支援します。フロントエンドのテスト整備やカバレッジ不足の特定に利用できます。
主な機能
- 01React コンポーネントの Jest テストひな形を生成
- 02Jest/Istanbul のカバレッジレポートを分析
- 03しきい値に基づいてカバレッジを確認
- 04Next.js のルートから Playwright テストを作成
- 05アクセシビリティテストとページオブジェクトに対応
活用シーン
- 01新しいコンポーネントの単体テスト構成を作成
- 02リリース前に未カバーのコードや分岐を特定
- 03Next.js ページの E2E テストを準備
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ alirezarezvani/ claude-skills --skill senior-qaインストール後、Claude Code で/senior-qaを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
README.mdreferences/qa_best_practices.mdtest_automation_patterns.mdtesting_strategies.mdscripts/coverage_analyzer.pye2e_test_scaffolder.pytest_suite_generator.py詳細
シニア QA エンジニア
React および Next.js アプリケーション向けのテスト自動化、カバレッジ分析、品質保証のパターン。
クイックスタート
# Generate Jest test stubs for React components
python scripts/test_suite_generator.py src/components/ --output __tests__/
# Analyze test coverage from Jest/Istanbul reports
python scripts/coverage_analyzer.py coverage/coverage-final.json --threshold 80
# Scaffold Playwright E2E tests for Next.js routes
python scripts/e2e_test_scaffolder.py src/app/ --output e2e/
ツールの概要
1. テストスイートジェネレーター
React/TypeScript のコンポーネントをスキャンし、適切な構造を備えた Jest + React Testing Library のテストスタブを生成します。
入力: React コンポーネントを含むソースディレクトリ 出力: describe ブロック、レンダリングテスト、操作テストを含むテストファイル
使用方法:
# Basic usage - scan components and generate tests
python scripts/test_suite_generator.py src/components/ --output __tests__/
# Include accessibility tests
python scripts/test_suite_generator.py src/ --output __tests__/ --include-a11y
# Generate with custom template
python scripts/test_suite_generator.py src/ --template custom-template.tsx
対応パターン:
- フックを使用する関数コンポーネント
- Context プロバイダーを使用するコンポーネント
- データを取得するコンポーネント
- バリデーションを備えたフォームコンポーネント
2. カバレッジアナライザー
Jest/Istanbul のカバレッジレポートを解析し、不足箇所や未カバーの分岐を特定して、実行可能な推奨事項を提示します。
入力: カバレッジレポート(JSON または LCOV 形式) 出力: 推奨事項を含むカバレッジ分析
使用方法:
# Analyze coverage report
python scripts/coverage_analyzer.py coverage/coverage-final.json
# Enforce threshold (exit 1 if below)
python scripts/coverage_analyzer.py coverage/ --threshold 80 --strict
# Generate HTML report
python scripts/coverage_analyzer.py coverage/ --format html --output report.html
3. E2E テストスキャフォルダー
Next.js の pages/app ディレクトリをスキャンし、一般的な操作を含む Playwright テストファイルを生成します。
入力: Next.js の pages または app ディレクトリ 出力: ルート別に整理された Playwright テストファイル
使用方法:
# Scaffold E2E tests for Next.js App Router
python scripts/e2e_test_scaffolder.py src/app/ --output e2e/
# Include Page Object Model classes
python scripts/e2e_test_scaffolder.py src/app/ --output e2e/ --include-pom
# Generate for specific routes
python scripts/e2e_test_scaffolder.py src/app/ --routes "/login,/dashboard,/checkout"
QA ワークフロー
ユニットテスト生成ワークフロー
新規または既存の React コンポーネントにテストを設定する際に使用します。
ステップ 1:未テストのコンポーネントをプロジェクトからスキャンする
python scripts/test_suite_generator.py src/components/ --scan-only
ステップ 2:テストスタブを生成する
python scripts/test_suite_generator.py src/components/ --output __tests__/
ステップ 3:生成されたテストを確認してカスタマイズする
// __tests__/Button.test.tsx (generated)
import { render, screen, fireEvent } from '@testing-library/react';
import { Button } from '../src/components/Button';
describe('Button', () => {
it('renders with label', () => {
render(<Button>Click me</Button>);
expect(screen.getByRole('button', { name: /click me/i })).toBeInTheDocument();
});
it('calls onClick when clicked', () => {
const handleClick = jest.fn();
render(<Button onClick={handleClick}>Click</Button>);
fireEvent.click(screen.getByRole('button'));
expect(handleClick).toHaveBeenCalledTimes(1);
});
// TODO: Add your specific test cases
});
ステップ 4:テストを実行してカバレッジを確認する
npm test -- --coverage
python scripts/coverage_analyzer.py coverage/coverage-final.json
カバレッジ分析ワークフロー
テストカバレッジを改善するときや、リリースの準備をするときに使用します。
ステップ 1:カバレッジレポートを生成する
npm test -- --coverage --coverageReporters=json
ステップ 2:カバレッジの不足箇所を分析する
python scripts/coverage_analyzer.py coverage/coverage-final.json --threshold 80
ステップ 3:重要なパスを特定する
python scripts/coverage_analyzer.py coverage/ --critical-paths
ステップ 4:不足しているテストスタブを生成する
python scripts/test_suite_generator.py src/ --uncovered-only --output __tests__/
ステップ 5:改善を確認する
npm test -- --coverage
python scripts/coverage_analyzer.py coverage/ --compare previous-coverage.json
E2E テストセットアップワークフロー
Next.js プロジェクトに Playwright を設定するときに使用します。
ステップ 1:Playwright を初期化する(未インストールの場合)
npm init playwright@latest
ステップ 2:ルートから E2E テストをスキャフォールドする
python scripts/e2e_test_scaffolder.py src/app/ --output e2e/
ステップ 3:認証フィクスチャを設定する
// e2e/fixtures/auth.ts (generated)
import { test as base } from '@playwright/test';
export const test = base.extend({
authenticatedPage: async ({ page }, use) => {
await page.goto('/login');
await page.fill('[name="email"]', '[email protected]');
await page.fill('[name="password"]', 'password');
await page.click('button[type="submit"]');
await page.waitForURL('/dashboard');
await use(page);
},
});
ステップ 4:E2E テストを実行する
npx playwright test
npx playwright show-report
ステップ 5:CI パイプラインに追加する
# .github/workflows/e2e.yml
- name: "run-e2e-tests"
run: npx playwright test
- name: "upload-report"
uses: actions/upload-artifact@v4
with:
name: "playwright-report"
path: playwright-report/
リファレンスドキュメント
| ファイル | 内容 | 使用するタイミング |
|---|---|---|
references/testing_strategies.md | テストピラミッド、テストの種類、カバレッジ目標、CI/CD 統合 | テスト戦略を設計するとき |
references/test_automation_patterns.md | Page Object Model、モック(MSW)、フィクスチャ、非同期パターン | テストコードを記述するとき |
references/qa_best_practices.md | テストしやすいコード、不安定なテスト、デバッグ、品質指標 | テスト品質を改善するとき |
よく使うパターンのクイックリファレンス
React Testing Library のクエリ
// Preferred (accessible)
screen.getByRole('button', { name: /submit/i })
screen.getByLabelText(/email/i)
screen.getByPlaceholderText(/search/i)
// Fallback
screen.getByTestId('custom-element')
非同期テスト
// Wait for element
await screen.findByText(/loaded/i);
// Wait for removal
await waitForElementToBeRemoved(() => screen.queryByText(/loading/i));
// Wait for condition
await waitFor(() => {
expect(mockFn).toHaveBeenCalled();
});
MSW を使用したモック
import { rest } from 'msw';
import { setupServer } from 'msw/node';
const server = setupServer(
rest.get('/api/users', (req, res, ctx) => {
return res(ctx.json([{ id: 1, name: "john" }]));
})
);
beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());
Playwright のロケーター
// Preferred
page.getByRole('button', { name: "submit" })
page.getByLabel('Email')
page.getByText('Welcome')
// Chaining
page.getByRole('listitem').filter({ hasText: 'Product' })
カバレッジしきい値(jest.config.js)
module.exports = {
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
};
よく使うコマンド
# Jest
npm test # Run all tests
npm test -- --watch # Watch mode
npm test -- --coverage # With coverage
npm test -- Button.test.tsx # Single file
# Playwright
npx playwright test # Run all E2E tests
npx playwright test --ui # UI mode
npx playwright test --debug # Debug mode
npx playwright codegen # Generate tests
# Coverage
npm test -- --coverage --coverageReporters=lcov,json
python scripts/coverage_analyzer.py coverage/coverage-final.json