一键导入
local-testing
Local testing setup - start dev server with mock Claude and run tests (unit tests, CLI E2E)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Local testing setup - start dev server with mock Claude and run tests (unit tests, CLI E2E)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Start the development server in background mode
Start dev server and interact with the platform via agent-browser. Use when user asks to browse, test, or demo the platform UI, connect services, or perform any browser-based interaction with the local dev environment.
Reset turbo environment (clean node_modules, reinstall, sync DB)
Check if a PR, commit, or tag has been deployed to production
Query, investigate, and manage Sentry issues for debugging and incident response
Create or update a PR and hand it off to a coding agent worker via load balancing. Removes pending label if present, then assigns a worker.
| name | local-testing |
| description | Local testing setup - start dev server with mock Claude and run tests (unit tests, CLI E2E) |
| context | fork |
This skill documents how to properly set up a local development environment for testing, including running unit tests and CLI E2E tests with mock Claude.
# 1. Install dependencies
cd turbo && pnpm install
# 2. Run unit tests
cd turbo && pnpm vitest run
# 1. Start dev server with tunnel (required for webhooks)
/dev-server:start
# 2. Wait for server to be ready, then authenticate CLI
/dev-server:auth
# 3. Deploy runner (needed for vm0 run, takes several minutes)
/dev-server:runner
# 4. Run CLI E2E tests
VM0_API_URL=http://localhost:3000 USE_MOCK_CLAUDE=true BATS_TEST_TIMEOUT=60 \
./e2e/test/libs/bats/bin/bats -T ./e2e/tests/01-serial/*.bats
Ensure the following are set in turbo/apps/web/.env.local:
| Variable | Purpose | Required |
|---|---|---|
USE_MOCK_CLAUDE | Enable mock Claude for testing (set to true) | Yes for E2E |
CONCURRENT_RUN_LIMIT_CAP | Set to 0 to disable run limits during testing | Yes for E2E |
SECRETS_ENCRYPTION_KEY | Encryption key for secrets | Yes |
CLERK_SECRET_KEY | Clerk authentication | Yes |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY | Clerk authentication | Yes |
If environment variables are missing, ask the user to run the sync script:
scripts/sync-env.sh
Note:
sync-env.shrequires 1Password authentication and can only be executed by the user directly. If you encounter missing environment variable errors, request the user to run this script.
# Add to turbo/apps/web/.env.local
echo "USE_MOCK_CLAUDE=true" >> turbo/apps/web/.env.local
echo "CONCURRENT_RUN_LIMIT_CAP=0" >> turbo/apps/web/.env.local
/dev-server:start
This will:
VM0_API_URL to the tunnel URLcd turbo && pnpm dev
Check for these indicators in the logs (/dev-server:logs):
[tunnel] Tunnel URL: https://xxx.trycloudflare.comReady in XXXms for each appImportant: The tunnel URL changes each time you restart. Sandbox webhooks use this URL to send events back to your local server.
Before running unit tests, ensure dependencies are installed:
cd turbo && pnpm install
cd turbo && pnpm vitest run
Expected output:
Test Files 173 passed (173)
Tests 2348 passed (2348)
cd turbo && pnpm vitest
cd turbo && pnpm vitest run apps/web/src/lib/__tests__/my-test.test.ts
cd turbo && pnpm vitest run --project @vm0/cli
cd turbo && pnpm vitest run --project web
e2e/tests/
├── 01-serial/ # Tests that MUST run serially (scope setup)
└── 03-runner/ # All parallel tests (runs on runner)
| Variable | Value | Purpose |
|---|---|---|
VM0_API_URL | http://localhost:3000 | API endpoint |
USE_MOCK_CLAUDE | true | Use mock Claude instead of real API |
BATS_TEST_TIMEOUT | 30 (serial) / 60 (parallel) | Per-test timeout in seconds |
VM0_API_URL=http://localhost:3000 \
USE_MOCK_CLAUDE=true \
BATS_TEST_TIMEOUT=30 \
./e2e/test/libs/bats/bin/bats -T ./e2e/tests/01-serial/*.bats
VM0_API_URL=http://localhost:3000 \
USE_MOCK_CLAUDE=true \
BATS_TEST_TIMEOUT=60 \
./e2e/test/libs/bats/bin/bats -T -j 10 --no-parallelize-within-files ./e2e/tests/03-runner/*.bats
VM0_API_URL=http://localhost:3000 \
USE_MOCK_CLAUDE=true \
BATS_TEST_TIMEOUT=60 \
./e2e/test/libs/bats/bin/bats -T ./e2e/tests/03-runner/t17-vm0-simplified-compose.bats
VM0_API_URL=http://localhost:3000 \
USE_MOCK_CLAUDE=true \
BATS_TEST_TIMEOUT=60 \
./e2e/test/libs/bats/bin/bats -T ./e2e/tests/03-runner/t17-vm0-simplified-compose.bats \
--filter "vm0 compose with both instructions and skills"
When USE_MOCK_CLAUDE=true:
run-agent.ts checks for USE_MOCK_CLAUDEclaude CLI, it runs the mock Claude scriptCause: Dependencies not installed or out of sync
Solution:
cd turbo && pnpm install
Solution:
cd turbo && pnpm install
cd turbo && pnpm vitest run
Cause: Sandbox cannot reach the tunnel URL (webhooks fail)
Solution:
/dev-server:logs tunnelcurl -v https://<tunnel-url>/api/webhooks/agent/events
/dev-server:stop
/dev-server:start
Cause: CONCURRENT_RUN_LIMIT_CAP not set or not 0
Solution:
echo "CONCURRENT_RUN_LIMIT_CAP=0" >> turbo/apps/web/.env.local
# Then restart dev server
Cause: vm0 run takes ~15-30 seconds per execution
Solution:
BATS_TEST_TIMEOUT is set appropriately (60s for parallel tests)/dev-server:logs error/dev-server:logs sandboxCause: Environment variables not synced from 1Password
Solution: Ask the user to run the sync script (requires 1Password authentication):
scripts/sync-env.sh
Note: This script can only be executed by the user directly as it requires interactive 1Password authentication.
Cause: CF_DNS_AND_TUNNEL_API_TOKEN not set. Caddy needs this to provision Let's Encrypt certificates via DNS-01 challenge.
Solution:
scripts/sync-env.sh
Cause: GNU Parallel not installed
Solution:
sudo apt-get install -y parallel
Solution:
# Kill processes on dev ports
fuser -k 3000/tcp 3001/tcp 3002/tcp 3003/tcp
# Or use dev-stop
/dev-server:stop
Cause: High concurrency causing request body truncation (local dev environment limitation)
Solution:
-j 4 instead of -j 10| Aspect | CI | Local |
|---|---|---|
| Server | Vercel Preview | localhost + tunnel |
| Tunnel | Not needed | Cloudflare tunnel required |
| Concurrency | High | May have issues with -j 10 |
| Timeouts | 8 min total | No global limit |
# Check dev server status
/dev-server:logs
# Filter logs by pattern
/dev-server:logs error
/dev-server:logs tunnel
/dev-server:logs sandbox
# Stop dev server
/dev-server:stop
# Authenticate CLI with local server
/dev-server:auth
# Check CLI auth status
vm0 auth status
# Manual test of vm0 run with mock Claude
vm0 run <agent-name> --artifact-name <artifact> "echo hello"
.claude/skills/cli-e2e-testing/skill.md.claude/skills/dev-server/skill.mdturbo/apps/web/src/lib/run/executors/runner-executor.ts