← ClaudeAtlas

nfs-testing-patternslisted

Test-writing patterns for projects scaffolded with nextjs-fullstack-starter. Use whenever the user is writing or reviewing tests in such a project, asks 'how do I test X', wants to add test coverage for a new module, or needs to debug a failing test. Covers service-layer unit tests (the high-value layer where most coverage lives), integration tests with a real Postgres (Testcontainers), Server Action tests via direct invocation, route-handler tests, and Playwright e2e. Each section explains WHAT to test at that layer and HOW so test effort lands where it pays off.
juncoding/nextjs-fullstack-starter · ★ 0 · Testing & QA · score 70
Install: claude install-skill juncoding/nextjs-fullstack-starter
# Testing patterns for the fullstack stack For projects scaffolded with `nextjs-fullstack-starter`. Tests are first-class — the verification gate (`pnpm verify`) runs them on every PR. ## Use this skill when - Writing tests for a new service, action, or route handler. - Adding coverage to existing code. - Debugging a failing test. - Deciding what to test at which layer. - Reviewing a PR's test coverage. ## The shape of testing in this stack The architecture has four delivery shapes — Server Components, Server Actions, route handlers, MCP tools — all calling services. **Most of your testing effort goes into the service layer.** Delivery wrappers are thin enough that integration tests cover them implicitly. Roughly: | Layer | Test type | Why | |---|---|---| | **Service** | Unit tests with mocked Prisma | Where the business logic lives. Highest leverage. | | **Service** (occasional) | Integration tests against real Postgres | When Prisma's query builder behaviors matter — joins, transactions, indexes. | | **Server Action** | Direct invocation tests OR e2e | Thin wrapper — usually covered by e2e. Unit-test only when the action does non-trivial parsing. | | **Route handler** | Direct invocation tests | Same as actions — thin. Test webhook signature verification and edge cases. | | **Page / UI** | Playwright e2e | Server Components are server-rendered HTML; integration testing them is e2e. | | **MCP tool** | Same as routes/actions — thin wrapper test | Verifies the tool regi