# 010119 Integration Test Setup

> Backend API test patterns — describeIf guards, getAuthHeaders, test-% cleanup, req() helper, KV isolation, sub-resource tests, and permissions matrix.

- Skill: `natuleadan/010119-integration-test-setup` (Agent Skill, multi-file: 8 files)
- Install (CLI): `npx skillmds@latest add natuleadan/010119-integration-test-setup`
- Raw SKILL.md: https://api.skillmd.com/api/skills/natuleadan/010119-integration-test-setup/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: MIT
- Author: natuleadan (https://skillmd.com/u/natuleadan)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/natuleadan/010119-integration-test-setup

---


# Integration Test Setup

## When to use

When writing HTTP integration tests against a live backend server with PostgreSQL, Redis, and S3 services.

## References

| Topic | File |
|---|---|
| Test setup and auth helpers | `references/test-setup.md` |
| Data cleanup patterns | `references/data-cleanup.md` |
| Sub-resource test pattern | `references/sub-resource-tests.md` |
| Permissions matrix test | `references/permissions-matrix.md` |

## Quick checklist

- [ ] Guard tests with `describeIf(!IS_PROD, ...)` to skip in production
- [ ] Use `getAuthHeaders(role)` to create users and get session cookies
- [ ] Clean up test data with `WHERE name LIKE 'test-%'` patterns
- [ ] Never use `FLUSHALL` on Redis — use targeted key deletion
- [ ] Test auth: 401 without auth, 403 without permission, 200 with permission
- [ ] For sub-resources: test CRUD + auth in the same describe block
- [ ] Clean up sub-resource tables with `WHERE productId IN (SELECT id FROM prd_products WHERE name LIKE 'test-%')`

