Test Nuxt 3 / Nitro applications - both API handlers (real PostgreSQL, transaction rollback) and frontend components (@nuxt/test-utils, mountSuspended).
View on GitHubgallop-systems/claude-skills
all
skills/nitro-testing/SKILL.md
January 20, 2026
Select agents to install to:
npx add-skill https://github.com/gallop-systems/claude-skills/blob/main/skills/nitro-testing/SKILL.md -a claude-code --skill nitro-testingInstallation paths:
.claude/skills/nitro-testing/# Nuxt / Nitro Testing Patterns
Test Nuxt 3 applications end-to-end: API handlers with real PostgreSQL using transaction rollback isolation, and frontend components with @nuxt/test-utils.
## When to Use This Skill
Use this skill when:
- Testing Nuxt 3 / Nitro API handlers
- Testing Vue components, pages, or composables in Nuxt
- Using Kysely or another query builder with PostgreSQL
- Need real database testing (not mocks)
- Want fast, isolated tests without truncation
## Reference Files
**Backend (API Handlers):**
- [transaction-rollback.md](./transaction-rollback.md) - Core isolation pattern with Vitest fixtures
- [test-utils.md](./test-utils.md) - Mock events, stubs, and assertion helpers
- [factories.md](./factories.md) - Transaction-bound factory pattern
- [vitest-config.md](./vitest-config.md) - Vitest configuration for Nitro
- [ci-setup.md](./ci-setup.md) - GitHub Actions with PostgreSQL service
- [async-testing.md](./async-testing.md) - Testing background tasks and automations
**Frontend (Components/Pages):**
- [frontend-testing.md](./frontend-testing.md) - Component testing with @nuxt/test-utils
## Example Files
- [test-utils-index.ts](./examples/test-utils-index.ts) - Complete test utilities module
- [global-setup.ts](./examples/global-setup.ts) - Database reset and migration
- [setup.ts](./examples/setup.ts) - Per-file setup with stubs
- [handler.test.ts](./examples/handler.test.ts) - Example API handler test
- [vitest.config.ts](./examples/vitest.config.ts) - Vitest configuration
## Core Concept: Transaction Rollback
Instead of truncating tables between tests, each test runs inside a database transaction that rolls back at the end:
```typescript
// Each test gets isolated factories and db access
test("creates user", async ({ factories, db }) => {
const user = await factories.user({ email: "test@example.com" });
// Test your handler
const event = mockPost({}, { name: "New Item" });
const result = await handler(event);
// Verify in da