From ef85ee746f6ce61cccd9e510c94130111a7ac546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Calexvisualmakers=E2=80=9D?= Date: Tue, 31 Mar 2026 09:31:24 +0200 Subject: [PATCH] chore: Co-locate unit tests and update test conventions - QA skill: unit tests placed next to source files (co-located) instead of src/__tests__/ directory - CLAUDE.md: add test convention note and full test script reference Co-Authored-By: Claude Opus 4.6 --- .claude/skills/qa/SKILL.md | 2 +- CLAUDE.md | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.claude/skills/qa/SKILL.md b/.claude/skills/qa/SKILL.md index ba54d16..679770f 100644 --- a/.claude/skills/qa/SKILL.md +++ b/.claude/skills/qa/SKILL.md @@ -65,7 +65,7 @@ npm run test:e2e # Playwright: E2E tests from previous QA runs Note any failures — these are regressions and must be treated as High bugs. ### 6. Write Unit Tests -Before E2E tests, identify and test isolated logic with Vitest in `src/__tests__/PROJ-X-*.test.ts`: +Before E2E tests, identify and test isolated logic with Vitest. Place tests **co-located** next to the source file (e.g. `src/hooks/useFeature.test.ts` next to `src/hooks/useFeature.ts`): **What to unit test (evaluate each):** - Custom hooks with non-trivial logic (e.g. `useKanbanStorage`: localStorage read/write, error fallback) diff --git a/CLAUDE.md b/CLAUDE.md index a241491..ceb6c68 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -47,14 +47,18 @@ All features tracked in `features/INDEX.md`. Every skill reads it at start and u - **Single Responsibility:** One feature per spec file - **shadcn/ui first:** NEVER create custom versions of installed shadcn components - **Human-in-the-loop:** All workflows have user approval checkpoints +- **Tests:** Unit tests co-located next to source files (`useHook.test.ts` next to `useHook.ts`). E2E tests in `tests/`. ## Build & Test Commands ```bash -npm run dev # Development server (localhost:3000) -npm run build # Production build -npm run lint # ESLint -npm run start # Production server +npm run dev # Development server (localhost:3000) +npm run build # Production build +npm run lint # ESLint +npm run start # Production server +npm test # Vitest unit/integration tests +npm run test:e2e # Playwright E2E tests +npm run test:all # Both test suites ``` ## Product Context