local-testing

6
0
Source

Local testing setup - start dev server with mock Claude and run tests (unit tests, CLI E2E)

Install

mkdir -p .claude/skills/local-testing && curl -L -o skill.zip "https://mcp.directory/api/skills/download/2419" && unzip -o skill.zip -d .claude/skills/local-testing && rm skill.zip

Installs to .claude/skills/local-testing

About this skill

Local Testing Skill

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.

Quick Start

Unit Tests Only

# 1. Install dependencies
cd turbo && pnpm install

# 2. Run unit tests
cd turbo && pnpm vitest run

CLI E2E Tests

# 1. Start dev server with tunnel (required for webhooks)
/dev-start

# 2. Wait for server to be ready, then authenticate CLI
/dev-auth

# 3. Deploy runner (needed for vm0 run, takes several minutes)
/dev-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

Prerequisites

1. Environment Variables

Ensure the following are set in turbo/apps/web/.env.local:

VariablePurposeRequired
USE_MOCK_CLAUDEEnable mock Claude for testing (set to true)Yes for E2E
CONCURRENT_RUN_LIMIT_CAPSet to 0 to disable run limits during testingYes for E2E
SECRETS_ENCRYPTION_KEYEncryption key for secretsYes
CLERK_SECRET_KEYClerk authenticationYes
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYClerk authenticationYes

If environment variables are missing, ask the user to run the sync script:

scripts/sync-env.sh

Note: sync-env.sh requires 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.

2. Add Mock Claude Configuration

# 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

Starting the Dev Server

Using the Skill

/dev-start

This will:

  • Start the Turbo dev server in background
  • Automatically start a Cloudflare tunnel for the web app
  • Set VM0_API_URL to the tunnel URL
  • Enable webhooks to reach your local server

Manual Start

cd turbo && pnpm dev

Verify Server is Ready

Check for these indicators in the logs (/dev-logs):

  • [tunnel] Tunnel URL: https://xxx.trycloudflare.com
  • Ready in XXXms for each app
  • No fatal errors

Important: The tunnel URL changes each time you restart. Sandbox webhooks use this URL to send events back to your local server.


Running Unit Tests

Prerequisites

Before running unit tests, ensure dependencies are installed:

cd turbo && pnpm install

Run All Tests

cd turbo && pnpm vitest run

Expected output:

Test Files  173 passed (173)
Tests       2348 passed (2348)

Run Tests in Watch Mode

cd turbo && pnpm vitest

Run Specific Test File

cd turbo && pnpm vitest run apps/web/src/lib/__tests__/my-test.test.ts

Run Tests for a Specific Package

cd turbo && pnpm vitest run --project @vm0/cli
cd turbo && pnpm vitest run --project web

Running CLI E2E Tests

Test Structure

e2e/tests/
├── 01-serial/              # Tests that MUST run serially (scope setup)
└── 03-experimental-runner/ # All parallel tests (runs on runner)

Environment Variables for E2E

VariableValuePurpose
VM0_API_URLhttp://localhost:3000API endpoint
USE_MOCK_CLAUDEtrueUse mock Claude instead of real API
BATS_TEST_TIMEOUT30 (serial) / 60 (parallel)Per-test timeout in seconds

Running Serial Tests

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

Running Parallel Tests

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-experimental-runner/*.bats

Running a Single Test File

VM0_API_URL=http://localhost:3000 \
USE_MOCK_CLAUDE=true \
BATS_TEST_TIMEOUT=60 \
./e2e/test/libs/bats/bin/bats -T ./e2e/tests/03-experimental-runner/t17-vm0-simplified-compose.bats

Running a Specific Test by Name

VM0_API_URL=http://localhost:3000 \
USE_MOCK_CLAUDE=true \
BATS_TEST_TIMEOUT=60 \
./e2e/test/libs/bats/bin/bats -T ./e2e/tests/03-experimental-runner/t17-vm0-simplified-compose.bats \
  --filter "vm0 compose with both instructions and skills"

How Mock Claude Works

When USE_MOCK_CLAUDE=true:

  1. The web server passes this to the sandbox via environment variable
  2. Inside sandbox, run-agent.ts checks for USE_MOCK_CLAUDE
  3. Instead of running real claude CLI, it runs the mock Claude script
  4. Mock Claude executes the prompt as a bash command and outputs Claude-compatible JSONL

Troubleshooting

Unit Test Issues

Problem: "@radix-ui/react-select could not be resolved" or Missing Dependencies

Cause: Dependencies not installed or out of sync

Solution:

cd turbo && pnpm install

Problem: Tests Fail After Pulling New Changes

Solution:

cd turbo && pnpm install
cd turbo && pnpm vitest run

CLI E2E Test Issues

Problem: "Failed to fetch events" or Run Hangs

Cause: Sandbox cannot reach the tunnel URL (webhooks fail)

Solution:

  1. Check if tunnel is active: /dev-logs tunnel
  2. Test tunnel connectivity:
    curl -v https://<tunnel-url>/api/webhooks/agent/events
    
  3. If SSL errors occur, restart dev server to get a fresh tunnel:
    /dev-stop
    /dev-start
    

Problem: "Concurrent agent run limit" Error

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

Problem: Tests Timeout

Cause: vm0 run takes ~15-30 seconds per execution

Solution:

  • Ensure BATS_TEST_TIMEOUT is set appropriately (60s for parallel tests)
  • Check server logs for errors: /dev-logs error
  • Verify sandbox is starting: /dev-logs sandbox

Problem: "SECRETS_ENCRYPTION_KEY" Missing or Other Environment Variables Missing

Cause: 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.

Problem: SSL Certificate Errors (e.g., "app.vm7.ai.pem - MISSING")

Cause: SSL certificates not generated for local development

Solution:

scripts/generate-certs.sh

Problem: "parallel: command not found" When Running Parallel E2E Tests

Cause: GNU Parallel not installed

Solution:

sudo apt-get install -y parallel

Problem: Port Already in Use

Solution:

# Kill processes on dev ports
fuser -k 3000/tcp 3001/tcp 3002/tcp 3003/tcp

# Or use dev-stop
/dev-stop

Problem: "SyntaxError: Unexpected end of JSON input" During Parallel Tests

Cause: High concurrency causing request body truncation (local dev environment limitation)

Solution:

  • This is a transient issue in local dev, CI environment doesn't have this problem
  • Run fewer parallel jobs: -j 4 instead of -j 10
  • Or run tests individually to verify they pass

CI vs Local Differences

AspectCILocal
ServerVercel Previewlocalhost + tunnel
TunnelNot neededCloudflare tunnel required
ConcurrencyHighMay have issues with -j 10
Timeouts8 min totalNo global limit

Useful Commands

# Check dev server status
/dev-logs

# Filter logs by pattern
/dev-logs error
/dev-logs tunnel
/dev-logs sandbox

# Stop dev server
/dev-stop

# Authenticate CLI with local server
/dev-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"

Reference

  • CLI E2E Testing Patterns: .claude/skills/cli-e2e-testing/skill.md
  • Dev Server Management: .claude/skills/dev-server/skill.md
  • Runner Executor: turbo/apps/web/src/lib/run/executors/runner-executor.ts

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

297790

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

220415

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

215297

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

224234

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

175201

rust-coding-skill

UtakataKyosui

Guides Claude in writing idiomatic, efficient, well-structured Rust code using proper data modeling, traits, impl organization, macros, and build-speed best practices.

167173

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.