testing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTesting
测试
Complete testing setup with Neon database branching, Playwright browser tests, integration tests, and unit tests. Isolated branches with automatic TTL cleanup.
基于Neon数据库分支、Playwright浏览器测试、集成测试和单元测试的完整测试环境搭建,支持带自动TTL清理的隔离分支。
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使用Zod并结合类Drizzle的Schema API实现类型安全的环境变量验证。支持服务端/公开字段、功能标志、二选一约束以及客户端保护。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/config-schema-setupNeon + Drizzle Setup
Neon + Drizzle 配置
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通过Drizzle ORM将Next.js应用连接到Neon Postgres,针对Vercel无服务器函数优化连接池。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/neon-drizzle-setupCookbook - Complete These Recipes in Order
配置指南 - 按顺序完成以下内容
Neon Test Branches
Neon 测试分支
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为测试创建隔离的Neon数据库分支。仅包含Schema的分支,通过TTL自动清理,支持测试服务器编排和环境变量管理。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/neon-test-branchesUnit Tests with Bun
基于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使用Bun内置的测试运行器配置单元测试。具备快速、兼容Jest的语法,支持测试文件同目录放置和模拟功能。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/unit-testsIntegration 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通过直接导入处理器,使用Bun测试运行器测试API路由。无需HTTP开销,实现快速、可靠的测试。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/integration-testsBrowser Tests with Playwright
基于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使用Playwright实现端到端浏览器测试。通过全浏览器自动化测试用户交互、表单验证、导航和视觉反馈。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/playwright-testsWorking 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测试策略与工作流。测试套件并行运行,每个套件使用隔离数据。优先使用Playwright进行UI测试,集成测试用于API,单元测试用于逻辑验证。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/using-tests