agentleFS
notum-cznotum-cz/strapi-next-monorepo-starter/.claude/skills/write-tests/SKILL.md

write-tests

Skill316 starsChanged 5 months agoMITView on GitHub

Use when asked to add or extend automated tests — e.g. "write test", "add test", "cover X with tests", "reproduce with a test", "test this", "e2e test", "playwright test". Covers Vitest (apps/ui, apps/strapi) and Playwright (qa/tests/playwright: e2e, visual, axe, seo).

80 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use close-spec, design-with-images and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • dzhngSkill

    close-spec

    When a spec under specs/<feature>/ is done shipping (a write-spec build, or any planned task that produced a spec), archive it to specs/done/ and rewrite it from a build-plan into a durable rationale — the why, the principles, the invariants — pointing back to the real code for the how. Use when implementation has landed and the plan no longer matches what shipped, or the user says a feature/spec is finished. Pairs with [write-spec](../write-spec/SKILL.md) (the plan this closes) and [review](../review/SKILL.md) (run before closing).

    Also in 5 projects that use this

  • dzhngSkill

    design-with-images

    Explore UI and visual design with image generation, then iterate the real implementation against the user-selected concept. Use when brainstorming visual directions, offering mockup variants, or implementing an approved generated design; do not stop at the mockups or the first code approximation.

    Also in 5 projects that use this

  • transitive-bullshitSkill

    compare-screenshots

    Compare screenshots against the intended design, distinguishing approved references from historical baselines. Use for iterative implementation matching, before/after visual review, objective image telemetry, or checking a lone capture for flat, empty, or badly framed content.

    Also in 5 projects that use this

  • LucasMatuszewskiSkill

    audit-agents

    Audit and maintain agent configuration files (.claude/agents, AGENTS.md, CLAUDE.md, agent-memory). Checks for duplicates, outdated info, naming conflicts, wrong technical facts, and files over 200 lines. Fixes all issues and commits.

    Also in 5 projects that use this

  • wolverin0Skill

    audit-decisions

    Standardize remediation decisions, baseline-policy entries, and legal-review banners for accepted, deferred, or policy-blocked audit findings.

    Also in 4 projects that use this

  • rhnfzlSkill

    explore-unknowns

    Walk the user through mapping the unknowns of a task before, during, and after they build it, and hand them a four-quadrant map (settled ground, open decisions, taste, and landmines) they keep. Reach for this eagerly whenever a request is ambiguous or underspecified, the codebase or domain is unfamiliar, the user will "know it when they see it", a reference implementation must be understood before porting, a build-queue or architecture-changing task is about to start, a mid-build deviation needs capturing, or a finished change needs buy-in or verified understanding before merge. Trigger even when the skill is not named: "do a blindspot pass", "find my unknown unknowns", "interview me about this change", "brainstorm the approach for a task I am about to build", "help me scope this", "what am I missing here", "plan this before I build", "I know nothing about X in this codebase". When a territory profile is present it reads memory and the graph first and feeds the map into the build pipeline; without one it degrades to a plain general map. Not for trivial or mechanical tasks with clear acceptance criteria, single-fact lookups, pure debugging of a known symptom, or pure code review, those have their own tools. Do not use it to run the build itself; the map is the deliverable and implementation remains a separate task, whether it has not started or is already underway.

    Also in 5 projects that use this

  • +5 more from dzhng

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. 0 are common, 9 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 75 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Add or extend tests using the starter's existing conventions.

    line 14
  2. Distinctive:

    Before writing, read one existing test in the same layer to mirror style:

    line 35
  3. Very specific:

    Import from vitest: describe, it, expect, beforeAll, afterAll.

    line 51
  4. Very specific:

    Strapi tests do not boot Strapi: Import the unit under test directly and either keep it pure, read schema.json from disk (app.test.ts), or …

    line 55
  5. Very specific:

    Import from @playwright/test: test, expect.

    line 59
  6. Very specific:

    Use test.describe for grouping.

    line 60
  7. Distinctive:

    Do not hardcode ports — rely on config.

    line 64
  8. Very specific:

    No console.log left behind.

    line 71
  9. Distinctive:

    Run only the relevant package, not the whole monorepo, while iterating.

    line 76
  10. Distinctive:

    Run the new test — it must pass.

    line 96
  11. Distinctive:

    Run the file's full suite — no regressions.

    line 97
  12. Distinctive:

    If reproducing a bug: first confirm the test fails without the fix, then apply the fix, then confirm it passes.

    line 98
  13. Distinctive:

    Do not add new dev dependencies for testing without explicit user request.

    line 115
  14. Distinctive:

    Do not introduce Jest, Mocha, Cypress, or other competing frameworks.

    line 116

“Common” is measured: kept by at least 6 in 10 of the 75 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Write Tests

Add or extend tests using the starter's existing conventions. Do not introduce new test frameworks. Do not invent new helpers when an existing one fits.

Reference: apps/docs/docs/reference/testing/overview.md (layers), unit-testing.md (Vitest), playwright.md (browser QA).

Decide the test layer first

Pick before writing. Wrong layer = wasted test.

GoalLayerWhere
Pure function / utility / hook (no network, no DOM)Vitest unit (apps/ui)*.test.ts next to source (apps/ui/src/**/*.test.ts)
Strapi service / util / schema / middleware behaviourVitest (apps/strapi)apps/strapi/tests/**/*.test.ts
Full browser flow, navigation, user interactionPlaywright e2eqa/tests/playwright/e2e/*.spec.ts
Visual regressionPlaywright visualqa/tests/playwright/visual/*.spec.ts
AccessibilityPlaywright axeqa/tests/playwright/axe/*.spec.ts
SEO meta, head, robotsPlaywright seoqa/tests/playwright/seo/*.spec.ts

Unit > integration > e2e. Push tests down the pyramid when behavior allows.

Phase 1 — Locate convention

Before writing, read one existing test in the same layer to mirror style:

  • UI unit ref: apps/ui/src/lib/dates.test.ts
  • Strapi pure-logic ref: apps/strapi/tests/hierarchy-compute.test.ts
  • Strapi schema-from-disk ref: apps/strapi/tests/app.test.ts (reads schema.json directly — no Strapi boot)
  • Strapi service-with-mocked-strapi-global ref: apps/strapi/tests/revalidate.test.ts (vi.stubGlobal("strapi", …))
  • Playwright e2e ref: qa/tests/playwright/e2e/test_example.spec.ts
  • Playwright visual ref: qa/tests/playwright/visual/visual.spec.ts
  • Playwright axe ref: qa/tests/playwright/axe/axe.spec.ts

Match imports, helper usage, describe/it nesting, naming.

Phase 2 — Write the test

Vitest (UI + Strapi)

  • Import from vitest: describe, it, expect, beforeAll, afterAll.
  • globals: true already set — but still import explicitly (matches existing code).
  • File pattern: *.test.ts. UI include: src/**/*.test.ts. Strapi include: tests/**/*.test.ts.
  • Path alias @ resolves to apps/ui/src (UI tests only).
  • Strapi tests do not boot Strapi. Import the unit under test directly and either keep it pure, read schema.json from disk (app.test.ts), or mock the strapi global with vi.stubGlobal("strapi", …) (revalidate.test.ts). There is no setupStrapi helper — do not add a DB or a real instance.

Playwright

  • Import from @playwright/test: test, expect.
  • Use test.describe for grouping.
  • page.goto("/") — baseURL configured in playwright.config.ts.
  • For visual: await expect(page).toHaveScreenshot(). Update snapshots only when intentional via pnpm tests:playwright:visual:update.
  • For axe: import existing axe helper if present (read axe.spec.ts first).
  • Do not hardcode ports — rely on config.

Phase 3 — Naming + structure

  • One describe per unit-under-test (function, component, route).
  • One it per behavior. Behavior phrased as outcome: it("returns null when input is empty"), not it("test 1").
  • AAA: arrange, act, assert. Separate with a blank line if it aids reading.
  • No console.log left behind. No .only / .skip committed.
  • Strapi tests mock the strapi global where needed (vi.stubGlobal); they never connect to a real database.

Phase 4 — Run

Run only the relevant package, not the whole monorepo, while iterating.

TestCommand
UI unit (all)pnpm test:ui
Strapi unit (all)pnpm test:strapi
Single Vitest filepnpm --filter @repo/ui exec vitest run <path> (or @repo/strapi)
Vitest watchpnpm --filter @repo/ui test:watch
Playwright e2epnpm tests:playwright:e2e:test
Playwright e2e interactivepnpm tests:playwright:e2e:test:interactive
Playwright visualpnpm tests:playwright:visual
Playwright axepnpm tests:playwright:axe
Playwright seopnpm tests:playwright:seo
Update visual snapshotspnpm tests:playwright:visual:update
All workspace testspnpm test

Playwright requires a running app (pnpm dev or built+started). If e2e fails with connection refused, start the app first.

Phase 5 — Verify before reporting done

  1. Run the new test — it must pass.
  2. Run the file's full suite — no regressions.
  3. If reproducing a bug: first confirm the test fails without the fix, then apply the fix, then confirm it passes. Do not skip the failing step.
  4. Snapshot updates: never update without inspecting the diff visually.

Report

Print:

Tests added: <n>
Files: <paths>
Layer: vitest-ui | vitest-strapi | playwright-e2e | playwright-visual | playwright-axe | playwright-seo
Result: pass
Command: <exact command to re-run>

Notes

  • Do not add new dev dependencies for testing without explicit user request.
  • Do not introduce Jest, Mocha, Cypress, or other competing frameworks.
  • Coverage reports configured in vitest.config.ts — don't reconfigure per-test.
  • Strapi tests run in a node environment without booting Strapi — keep them fast and focused; isolate logic so it's testable without a running instance.
  • Playwright MOBILE_VIEWPORTS_TESTING_ENABLED=true env var opts in mobile projects (see playwright.config.ts).
  • Visual snapshots are platform-sensitive — generated on macOS may diff on CI. Note in PR if you regenerated locally.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.