feat: 包括的テストテンプレート(21種類)を追加 - #532
Conversation
Next.js プロジェクト向けの包括的なテスト設定テンプレートを追加。 cyber_ace_1on1 で実績のある設定を他のリポジトリに適用可能に。 ## 追加テスト種別(21種類) ### 基本テスト - Unit, Component, Snapshot, Integration, E2E ### 品質保証テスト - API, Regression, Smoke, Contract, Scenario, Visual, A11y ### 高度なテスト - Property-based (fast-check), Mutation (Stryker) ### パフォーマンス・負荷テスト - Performance (Lighthouse), Load (k6/Artillery) ### セキュリティ・インフラテスト - Security, Database, Edge Functions ### 国際化・SSRテスト - i18n, SSR/Hydration ## レベル構成(5段階) - minimal: Unit + Component + Snapshot - standard: + Integration + E2E + API - comprehensive: + Regression + Smoke + Contract - full: + Visual + A11y + Scenario + Property-based - enterprise: + Performance + Load + Security + DB + Edge + i18n + SSR + Mutation ## 含まれるファイル - /setup-tests コマンド - Jest/Playwright 設定ファイル - 21種類のサンプルテスト - CI/CD ワークフローテンプレート - README ドキュメント 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (33)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 AI Code Review (Local Hook)Models: Codex (default) / Gemini (default) 🤖 Codex Review指摘事項(重大度順)
全体判定: patch is incorrect ✨ Gemini Reviewレビューを実施しました。以下に結果を報告します。 レビュー結果以下に発見事項をリストします。 1. [重大] import文の構文エラー
// 修正前
import { test, expect } from ' @playwright/test';
import AxeBuilder from ' @axe-core/playwright';
// 修正後
import { test, expect } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';2. [改善提案] CIにおける不安定な待機処理CIワークフロー内でサーバー起動を待つために
3. [改善提案] ドキュメントの重複による保守性の懸念
4. [改善提案] CIからのPRコメントの重複投稿カバレッジレポートをプルリクエストにコメントするGitHub Actionスクリプトは、実行のたびに新しいコメントを投稿します。CIが再実行されると、同じ内容のコメントが複数投稿され、プルリクエストが読みにくくなる可能性があります。既存のコメントを検索して更新するロジックを追加することを検討してください。
5. [一貫性] CIでのテストコマンドの不統一
総合評価patch is incorrect 理由: パッチには、テストセットアップを自動化するための非常に詳細でよく構造化されたドキュメントとテンプレートが含まれており、開発者体験を大幅に向上させる可能性を秘めています。しかし、 信頼度スコア: 0.9
|
- security.test.ts: Gitleaks誤検出を回避(テスト用トークンを変更) - jest.config.js: templates/ をカバレッジ対象から除外 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c1ac843ad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY = 'test-anon-key'; | ||
|
|
||
| // Mock fetch for API tests | ||
| global.fetch = jest.fn(); |
There was a problem hiding this comment.
Stop replacing global fetch with an empty mock
jest.config.js loads jest.setup.js for all default Jest runs (setupFilesAfterEnv), but this line replaces fetch with jest.fn() that returns undefined unless every test stubs it. The new API/security/contract templates call fetch and then read res.status/res.json (for example templates/testing/examples/api.test.ts), so they crash immediately instead of exercising endpoints. This makes the provided test templates fail out of the box and hides real integration behavior.
Useful? React with 👍 / 👎.
| workers: process.env.CI ? 2 : undefined, | ||
| reporter: process.env.CI ? [['html'], ['list']] : 'list', | ||
| use: { | ||
| baseURL: process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:3000', |
There was a problem hiding this comment.
Use the same default host in regression Playwright config
The regression config defaults to http://localhost:3000, while the main Playwright config explicitly uses http://127.0.0.1:3000 to match Supabase site_url and keep auth redirects working. Because regression suites include auth scenarios, this host mismatch can cause redirect/cookie origin inconsistencies when PLAYWRIGHT_BASE_URL is not set, leading to regression-only login failures.
Useful? React with 👍 / 👎.
| await page.getByRole('button', { name: /ログイン/i }).click(); | ||
|
|
||
| // アラートが表示されないことを確認 | ||
| let alertShown = false; | ||
| page.on('dialog', () => { |
There was a problem hiding this comment.
Attach the dialog handler before triggering form submit
In this XSS regression test, the dialog listener is registered only after clicking the login button. If an injected alert() fires during submit handling, Playwright emits the dialog event before the handler is attached, so alertShown stays false and the test can pass despite an actual XSS execution. Registering the listener before the click is required to avoid this false negative.
Useful? React with 👍 / 👎.
templates/testing/examples/ ディレクトリをGitleaks許可リストに追加 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR レビューテストテンプレート(21種類)の追加は非常に価値のある取り組みです。全体的な構成と段階的なレベル設計は良くできています。以下にいくつかの改善点を挙げます。 🔴 要対応1.
|
|
🎉 This PR is included in version 1.84.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
/setup-testsコマンドで他のリポジトリに簡単に適用可能追加テスト種別
基本テスト (5種類)
品質保証テスト (7種類)
高度なテスト (2種類)
パフォーマンス・負荷テスト (2種類)
セキュリティ・インフラテスト (3種類)
国際化・SSRテスト (2種類)
追加ファイル(31ファイル)
設定ファイル
jest.config.js,jest.setup.js,jest.polyfills.jsplaywright.config.ts,playwright.regression.config.tsjest.regression.config.js,jest.scenario.config.jsci-test-jobs.ymlサンプルテスト
ドキュメント
templates/testing/README.md.claude/commands/setup-tests.md使い方
Test plan
/setup-testsコマンド実行テスト🤖 Generated with Claude Code