Skip to content
Back to skills

Writing Tests

ASecurity

Testing patterns for this repo — which layer gets mocked, how service tests reach PostgreSQL, and how client tests get a DOM. Use when adding or changing a *.test.ts / *.test.tsx file, when a new module needs test coverage, or when an existing test fails in a way that looks like a setup problem.

  • 3 stars
  • 0 votes
  • 0 copies
  • 8 views
  • Added September 3, 2026
ai-agentssqltestingapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 3, 2026

npx -y skills add alexpricedev/Billet --skill writing-tests --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Writing Tests?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Writing Tests
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alexpricedev-writing-tests/badge)](https://www.skillsdirectory.com/skills/alexpricedev-writing-tests)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: writing-tests
description: Testing patterns for this repo — which layer gets mocked, how service tests reach PostgreSQL, and how client tests get a DOM. Use when adding or changing a *.test.ts / *.test.tsx file, when a new module needs test coverage, or when an existing test fails in a way that looks like a setup problem.
---

# Writing tests

Tests are co-located: `home.test.ts` sits next to `home.tsx`. Test user-visible behaviour rather
than implementation, and cover both guest and authenticated paths for anything auth-aware.

The mocking boundary is the same everywhere: **mock the service layer, exercise everything above
it for real.** Controllers are tested against real `Response` objects and real rendered HTML, not
against assertions that a render function was called.

Pick the reference for the layer you're working in:

| Layer | Reference |
|---|---|
| `controllers/api/`, `controllers/app/`, `controllers/admin/` | `references/controllers.md` |
| `services/`, `middleware/` | `references/services.md` |
| `src/client/**` | `references/client.md` |

`src/server/test-utils/` holds the shared kit: `helpers.ts` (`cleanupTestData`, `seedTestData`,
`randomEmail`), `setup.ts` (`createMockRequest`, `expectJsonResponse`), `factories.ts`, and
`bun-request.ts` for building `BunRequest` values with route params.

Run everything with `bun run test` — see the `verifying-changes` skill for why the raw `bun test`
command misbehaves here.

Files in this skill

  • SKILL.md1.4 KB
  • references/client.md1.9 KB
  • references/controllers.md2.6 KB
  • references/services.md2.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.