diff --git a/.claude/rules/testing.md b/.claude/rules/testing.md index 753060db1..85f4b5d72 100644 --- a/.claude/rules/testing.md +++ b/.claude/rules/testing.md @@ -3,7 +3,7 @@ description: Testing rules and patterns paths: - '**/*.test.ts' - '**/*.spec.ts' - - 'tests/**' + - 'e2e/**' - 'src/test/**' --- @@ -20,10 +20,12 @@ Write all test titles in English. Use descriptive sentences that state the expec ## Test Types -| Type | Tool | Location | Run Command | -| ---- | ---------- | ----------------------------------------------------------------- | ----------------------- | -| Unit | Vitest | `src/test/` (mirrors `src/lib/`) or co-located in `src/features/` | `pnpm test:unit` | -| E2E | Playwright | `tests/` | `pnpm test:integration` | +| Type | Tool | Location | Run Command | +| ---- | ---------- | ----------------------------------------------------------------- | ---------------- | +| Unit | Vitest | `src/test/` (mirrors `src/lib/`) or co-located in `src/features/` | `pnpm test:unit` | +| E2E | Playwright | `e2e/` | `pnpm test:e2e` | + +E2E test files must use the `.spec.ts` extension. `playwright.config.ts` matches only `*.spec.ts`, so `.test.ts` files will not be detected. ## Assertions diff --git a/.claude/skills/session-close/instructions.md b/.claude/skills/session-close/instructions.md index 78cfaae6a..a32a3850d 100644 --- a/.claude/skills/session-close/instructions.md +++ b/.claude/skills/session-close/instructions.md @@ -6,7 +6,7 @@ Run both checks and fix any failures before proceeding: ```bash pnpm test:unit -pnpm test:integration +pnpm test:e2e pnpm check ``` diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa368956e..1acd28af5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: # TODO: Run integration test # - name: Integration test - # run: pnpm test:integration + # run: pnpm test:e2e preview: if: ${{ github.ref != 'refs/heads/main' }} diff --git a/AGENTS.md b/AGENTS.md index 154104ccc..1185172f9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -25,7 +25,7 @@ pnpm dev # Start dev server (localhost:5174) pnpm build # Build for production pnpm test # Run all tests pnpm test:unit # Vitest unit tests -pnpm test:integration # Playwright E2E tests +pnpm test:e2e # Playwright E2E tests pnpm coverage # Report test coverage pnpm lint # ESLint check pnpm format # Prettier format @@ -61,7 +61,7 @@ src/features/ # Feature-scoped code (single domain) │ └── utils/ # Feature utilities │ └── _.test.ts # Tests co-located next to source src/test/ # Unit tests (mirrors src/lib/) -tests/ # E2E tests (Playwright) +e2e/ # E2E tests (Playwright) prisma/schema.prisma # Database schema ``` @@ -71,7 +71,7 @@ prisma/schema.prisma # Database schema - **Service layer**: Services return data or `null`; never call `error()` or `redirect()`. HTTP error translation belongs in the route handler — the service must stay framework-agnostic and unit-testable. - **Server data**: `+page.server.ts` → `+page.svelte` via `data` prop - **Forms**: Superforms + Zod validation -- **Tests**: Write tests before implementation (TDD). Use `@quramy/prisma-fabbrica` for factories only in `prisma/seed.ts` and Playwright global setup (`tests/global-setup.ts`). For service-layer unit tests, mock the DB with `vi.mock('$lib/server/database', ...)` — do not use fabbrica there. Use Nock for HTTP mocking +- **Tests**: Write tests before implementation (TDD). Use `@quramy/prisma-fabbrica` for factories only in `prisma/seed.ts`. For service-layer unit tests, mock the DB with `vi.mock('$lib/server/database', ...)` — do not use fabbrica there. Use Nock for HTTP mocking - **Naming**: `camelCase` variables, `PascalCase` types/components, `snake_case` files/routes, `kebab-case` directories - **Pre-commit**: Lefthook runs Prettier + ESLint (bypass: `LEFTHOOK=0 git commit`) diff --git a/docs/guides/architecture.md b/docs/guides/architecture.md index 187906a6d..68f58054c 100644 --- a/docs/guides/architecture.md +++ b/docs/guides/architecture.md @@ -177,7 +177,7 @@ features/workbooks/services/ - テストファクトリ(`@quramy/prisma-fabbrica`) - テストヘルパー・フィクスチャ -- E2E テスト(`tests/`) +- E2E テスト(`e2e/`) ### Vitest 設定 diff --git a/docs/guides/claude-code.md b/docs/guides/claude-code.md index 25785677c..633c6f375 100644 --- a/docs/guides/claude-code.md +++ b/docs/guides/claude-code.md @@ -31,7 +31,7 @@ Claude Code の拡張ポイントの使い分けをまとめる。 description: Testing rules and patterns paths: - '**/*.test.ts' - - 'tests/**' + - 'e2e/**' --- ``` @@ -45,7 +45,7 @@ paths: | ファイル | スコープ | | ---------------------- | -------------------------------------------------------- | | `coding-style.md` | 言語レベルの記述スタイル(ブレース・命名・型エイリアス) | -| `testing.md` | `*.test.ts`, `tests/**` のテストパターン | +| `testing.md` | `*.test.ts`, `*.spec.ts`, `e2e/**` のテストパターン | | `svelte-components.md` | `*.svelte` コンポーネント設計方針 | | `prisma-db.md` | `prisma/**`, `src/lib/server/**` の DB・サービス層規約 | | `auth.md` | 認証関連 | diff --git a/tests/about_page.test.ts b/e2e/about_page.spec.ts similarity index 100% rename from tests/about_page.test.ts rename to e2e/about_page.spec.ts diff --git a/tests/custom-colors.spec.ts b/e2e/custom_colors.spec.ts similarity index 100% rename from tests/custom-colors.spec.ts rename to e2e/custom_colors.spec.ts diff --git a/tests/dark-mode.spec.ts b/e2e/dark_mode.spec.ts similarity index 100% rename from tests/dark-mode.spec.ts rename to e2e/dark_mode.spec.ts diff --git a/tests/helpers/auth.ts b/e2e/helpers/auth.ts similarity index 100% rename from tests/helpers/auth.ts rename to e2e/helpers/auth.ts diff --git a/tests/navbar.spec.ts b/e2e/navbar.spec.ts similarity index 100% rename from tests/navbar.spec.ts rename to e2e/navbar.spec.ts diff --git a/tests/robots.test.ts b/e2e/robots.spec.ts similarity index 100% rename from tests/robots.test.ts rename to e2e/robots.spec.ts diff --git a/tests/signin.test.ts b/e2e/signin.spec.ts similarity index 100% rename from tests/signin.test.ts rename to e2e/signin.spec.ts diff --git a/tests/sitemap.test.ts b/e2e/sitemap.spec.ts similarity index 100% rename from tests/sitemap.test.ts rename to e2e/sitemap.spec.ts diff --git a/tests/toppage.test.ts b/e2e/toppage.spec.ts similarity index 100% rename from tests/toppage.test.ts rename to e2e/toppage.spec.ts diff --git a/tests/workbook_order.test.ts b/e2e/workbook_order.spec.ts similarity index 100% rename from tests/workbook_order.test.ts rename to e2e/workbook_order.spec.ts diff --git a/tests/workbooks_list.test.ts b/e2e/workbooks_list.spec.ts similarity index 100% rename from tests/workbooks_list.test.ts rename to e2e/workbooks_list.spec.ts diff --git a/package.json b/package.json index 92f801eeb..5f2a2b0e6 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,12 @@ "dev": "vite dev", "build": "prisma generate && vite build", "preview": "vite preview", - "test": "npm run test:integration && npm run test:unit", + "test": "npm run test:e2e && npm run test:unit", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "lint": "prettier --check . && eslint .", "format": "prettier --write .", - "test:integration": "playwright test", + "test:e2e": "playwright test", "test:unit": "vitest", "postinstall": "prisma generate", "db:seed": "pnpm exec tsx ./prisma/seed.ts", diff --git a/playwright.config.ts b/playwright.config.ts index 5b7a63069..aa8050b72 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -9,21 +9,11 @@ const config: PlaywrightTestConfig = { use: { baseURL: process.env.BASE_URL ?? 'http://localhost:4173', }, - testDir: 'tests', + testDir: 'e2e', projects: [ - //{ - // name: 'setup db', - // testMatch: /global\.setup\.ts/, - // teardown:'cleanup db', - //}, - //{ - // name: 'cleanup db', - // testMatch: /global\.teardown\.ts/, - //}, { name: 'all', - testMatch: /(.+\.)?(test|spec)\.[jt]s/, - //dependencies: ['setup db'], + testMatch: /(.+\.)?spec\.[jt]s/, }, ], };