home / skills / andrelandgraf / fullstackrecipes / testing

testing skill

/skills/testing

This skill helps you implement a complete testing setup with Neon branches, Playwright browser tests, and unit/integration tests for robust fullstack apps.

npx playbooks add skill andrelandgraf/fullstackrecipes --skill testing

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.4 KB
---
name: testing
description: Complete testing setup with Neon database branching, Playwright browser tests, integration tests, and unit tests. Isolated branches with automatic TTL cleanup.
---

# Testing

Complete testing setup with Neon database branching, Playwright browser tests, integration tests, and unit tests. Isolated branches with automatic TTL cleanup.

## Prerequisites

Complete these recipes first (in order):

### Type-Safe Environment Configuration

Type-safe environment variable validation using Zod with a Drizzle-like schema API. Supports server/public fields, feature flags, either-or constraints, and client-side protection.

```bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/config-schema-setup
```

### Neon + Drizzle Setup

Connect a Next.js app to Neon Postgres using Drizzle ORM with optimized connection pooling for Vercel serverless functions.

```bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/neon-drizzle-setup
```

## Cookbook - Complete These Recipes in Order

### Neon Test Branches

Create isolated Neon database branches for testing. Schema-only branches with auto-cleanup via TTL, test server orchestration, and environment variable management.

```bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/neon-test-branches
```

### Unit Tests with Bun

Configure unit testing with Bun's built-in test runner. Fast, Jest-compatible syntax, co-located test files, and mocking support.

```bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/unit-tests
```

### Integration Tests

Test API routes by importing handlers directly with Bun's test runner. Fast, reliable tests without HTTP overhead.

```bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/integration-tests
```

### Browser Tests with Playwright

End-to-end browser testing with Playwright. Test user interactions, form validation, navigation, and visual feedback with full browser automation.

```bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/playwright-tests
```

### 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.

```bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/using-tests
```

Overview

This skill provides a complete testing setup for TypeScript full-stack apps using Neon database branching, Playwright browser tests, integration tests, and unit tests. It creates isolated Neon branches with automatic TTL cleanup and ties testing workflows together for reliable, repeatable CI and local runs. The setup favors fast feedback and safe parallel execution across suites.

How this skill works

The setup provisions schema-only Neon test branches on demand, automatically expires them via TTL, and injects branch connection details into test environments. Unit tests run with Bun’s fast test runner, integration tests call API handlers directly to avoid HTTP overhead, and Playwright performs end-to-end browser automation. Tests run in parallel with isolated data per suite to prevent cross-test interference.

When to use it

  • When you need reliable, isolated database-backed tests for CI and local development
  • When you want fast unit/integration feedback using Bun’s runner
  • When end-to-end user flows must be validated with Playwright browser automation
  • When parallel test execution and automatic test database lifecycle are required
  • When you want deterministic API tests without spinning up HTTP servers

Best practices

  • Use Neon schema-only branches for each test run to isolate state and enable safe parallel CI jobs
  • Keep unit tests focused on pure logic and use Bun for fast execution
  • Import API route handlers directly in integration tests to avoid network flakiness
  • Reserve Playwright for user-facing flows, form validation, and navigation scenarios
  • Tear down or rely on TTL for test branches rather than manual cleanup to reduce flakiness

Example use cases

  • CI pipeline that creates a Neon test branch per job, runs unit/integration/Playwright suites, then lets TTL expire the branch
  • Local development workflow where feature branches get temporary Neon branches for manual QA and Playwright checks
  • Integration tests that import Next.js API handlers and assert business logic with mocked external services
  • Playwright suites that verify form flows, authentication, and visual feedback in a real browser environment
  • Unit test collection for complex utility functions and business rules executed quickly via Bun

FAQ

How are Neon test branches cleaned up?

Branches are created as schema-only with a TTL policy so they automatically expire and free resources without manual intervention.

Why use Bun for tests instead of Jest or Vitest?

Bun provides a very fast built-in test runner with Jest-compatible syntax and co-located tests, reducing feedback loop time while remaining familiar.