
using-tests
Testing strategy and workflow. Tests run in parallel with isolated data per suite. Prioritize Playwright for UI, integration tests for APIs, unit tests for logic.
- Installs
- 98
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/andrelandgraf/fullstackrecipes --skill using-tests- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads using-tests automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Working with Tests
Testing strategy and workflow. Tests run in parallel with isolated data per suite. Prioritize Playwright for UI, integration tests for APIs, unit tests for logic.
Testing Strategy
Follow this hierarchy when deciding what kind of test to write:
- Playwright tests (browser) - Preferred for most features
- Integration tests (API) - When Playwright is not practical
- Unit tests (pure functions) - Only for complex isolated logic
When to Use Each Test Type
Playwright Tests (Default Choice)
Write Playwright tests when the feature involves:
- User interactions (clicking, typing, navigation)
- Visual feedback (toasts, loading states, error messages)
- Form submissions and validation
- Multi-step UI flows
- Protected routes and redirects
- Accessibility behavior
Example features best tested with Playwright:
- Sign-in flow with error handling
- Chat creation and deletion with confirmation dialogs
- Theme toggle
- Form validation messages
- Navigation between pages
Integration Tests
Write integration tests when:
- Testing API responses directly (status codes, JSON structure)
- Verifying database state after operations
- Testing server-side logic without UI
- Playwright would be too slow or complex for the scenario
Example features best tested with integration tests:
- API route returns correct status codes
- User creation populates database correctly
- Session cookies are set on sign-in
- Protected API routes return 401/403
Unit Tests
Write unit tests only when:
- Testing pure functions with complex logic
- Testing code with many edge cases
- Testing type narrowing and error messages
- The function has no external dependencies
Example features best tested with unit tests:
- Assertion helpers
- Config schema validation
- Data transformation functions
- Utility functions
Running Tests
All tests run against an isolated Neon database branch that auto-deletes after 1 hour.
bun run test # All tests with isolated Neon branch
bun run test:playwright # Browser tests only
bun run test:integration # Integration tests only
bun run test:unit # Unit tests only
Folder Structure
src/
├── lib/
│ ├── common/
│ │ ├── assert.ts
│ │ └── assert.test.ts # Unit test (co-located)
│ └── config/
│ ├── schema.ts
│ └── schema.test.ts # Unit test (co-located)
tests/
├── integration/
│ ├── llms.test.ts # Integration test
│ ├── r.test.ts
│ ├── mcp/
│ │ └── route.test.ts
│ └── recipes/
│ └── [slug]/
│ └── route.test.ts
└── playwright/
├── auth.spec.ts # Playwright test
├── chat.spec.ts
├── home.spec.ts
└── lib/
└── test-user.ts # Playwright-specific helpers
Writing Tests for New Features
Step 1: Determine Test Type
Ask: "How would a user verify this feature works?"
- If through the UI → Playwright test
- If through API calls → Integration test
- If by calling a function directly → Unit test
Step 2: Create Test File
Playwright tests: tests/playwright/{feature}.spec.ts
import { test, expect } from "@playwright/test";
test.describe("Feature Name", () => {
test("should do expected behavior", async ({ page }) => {
await page.goto("/feature");
// Test implementation
});
});
Integration tests: tests/integration/{feature}.test.ts
For API routes, import the handler directly for faster, more reliable tests:
import { describe, it, expect } from "bun:test";
import { GET } from "@/app/api/feature/route";
describe("GET /api/feature", () => {
it("should return expected response", async () => {
const response = await GET();
expect(response.status).toBe(200);
const data = await response.json();
expect(data.value).toBeDefined();
});
});
Unit tests: src/lib/{domain}/{file}.test.ts (co-located)
import { describe, it, expect } from "bun:test";
import { myFunction } from "./my-file";
describe("myFunction", () => {
it("should do expected behavior", () => {
expect(myFunction()).toBe("expected");
});
});
Test Data Management
Database Isolation
Tests run against isolated Neon branches. Each test run:
- Creates a fresh schema-only branch
- Runs tests against the branch
- Branch auto-deletes after 1 hour
This ensures tests don't interfere with production data.
Parallel Test Isolation
Tests run in parallel by default. Each test suite must use its own test data to avoid conflicts:
- Different test users - Each spec file should create unique users with distinct emails
- Different resources - Tests creating chats, sessions, etc. should not depend on shared state
- No cleanup required - The branch TTL handles cleanup automatically
// auth.spec.ts - uses auth-specific test user
const testUser = await createTestUser({
email: `auth-test-${uuid}@example.com`,
});
// chat.spec.ts - uses chat-specific test user
const testUser = await createTestUser({
email: `chat-test-${uuid}@example.com`,
});
Avoid patterns that rely on global state or specific database contents existing from other tests.
Common Patterns
Testing Protected Routes (Playwright)
test("should redirect unauthenticated user", async ({ page }) => {
await page.goto("/protected-page");
await expect(page).toHaveURL(/sign-in/);
});
Testing Error States (Playwright)
test("should show error for invalid input", async ({ page }) => {
await page.goto("/form");
await page.getByRole("button", { name: /submit/i }).click();
await expect(page.getByText(/error|required/i)).toBeVisible({
timeout: 5000,
});
});
Testing API Responses (Integration)
Import route handlers directly for cleaner tests:
import { GET } from "@/app/api/endpoint/route";
it("should return 200 for valid request", async () => {
const response = await GET();
expect(response.status).toBe(200);
});
Debugging Failed Tests
Playwright
bunx playwright test --headed # Watch browser
bunx playwright test --debug # Step through test
bunx playwright show-report # View HTML report
Integration/Unit
bun test --only "test name" # Run single test
bun test --watch # Re-run on changes
View test artifacts
Failed Playwright tests save screenshots and traces to test-results/. Check this folder when CI fails.
FAQ
What does the using-tests skill do?
Testing strategy and workflow. Tests run in parallel with isolated data per suite. Prioritize Playwright for UI, integration tests for APIs, unit tests for logic.
How do I install using-tests?
Run npx skills add https://github.com/andrelandgraf/fullstackrecipes --skill using-tests in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/using-tests/ (personal) or .claude/skills/using-tests/ (project).
Which AI agents can use using-tests?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is using-tests safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains using-tests?
It is published by andrelandgraf in andrelandgraf/fullstackrecipes. It has 98 recorded installs.
More from andrelandgraf/fullstackrecipes
ralph-loop
andrelandgraf/fullstackrecipes
Complete setup for automated agent-driven development. Define features as user stories with testable acceptance criteria, then run AI agents in a loop until all stories pass.
ralph-loop-workflow
andrelandgraf/fullstackrecipes
Run a coding agent in an autonomous loop via a /ralph command, gated by a preflight check that every CLI is installed, linked, and authenticated. Use when driving long-running autonomous development from a wide, outcome-focused prompt.
observability-monitoring
andrelandgraf/fullstackrecipes
Complete observability stack with structured logging, error tracking, and web analytics.
stripe-subscriptions
andrelandgraf/fullstackrecipes
Open the skill to read its SKILL.md instructions.
og-image-generation
andrelandgraf/fullstackrecipes
Generate dynamic social preview images using Next.js file conventions and the next/og library. Server-rendered JSX images cached at build time.
shiki-code-blocks
andrelandgraf/fullstackrecipes
Open the skill to read its SKILL.md instructions.
Popular testing & qa skills
tdd
mattpocock/skills
Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
grilling
mattpocock/skills
Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.
migrate-to-shoehorn
mattpocock/skills
Migrate test files from as type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace as in tests, or needs partial test data.
run-train
lllllllama/rigorpilot-skills
Rigor Train skill for deep learning research repositories. Use when a documented or selected training command should be run conservatively for startup verification, short-run verification, full kickoff, or resume, with command, config, seed, log, checkpoint, status, and metric evidence written to standardized trainoutputs/. Do not use for environment setup, exploratory sweeps, speculative idea implementation, or end-to-end orchestration.
test-driven-development
obra/superpowers
Use when implementing any feature or bugfix, before writing implementation code
finishing-a-development-branch
obra/superpowers
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work