Skip to content

OpenClaw Testing — Unit, E2E, and Live Test Suites

OpenClaw has three test suites, each with increasing realism (and cost). Most days you’ll run the fast unit tests. When debugging real provider issues, you’ll reach for live tests.


Terminal window
# Full gate (expected before push)
pnpm lint && pnpm build && pnpm test
# With coverage
pnpm test:coverage
# E2E suite (gateway networking)
pnpm test:e2e
# Live suite (real providers, real costs)
pnpm test:live

Terminal window
pnpm test
  • Files: src/**/*.test.ts
  • Scope: Pure unit tests, in-process integration, deterministic regressions
  • Runs in CI: Yes
  • Keys required: No
  • Speed: Fast ⚡
Terminal window
pnpm test:e2e
  • Files: src/**/*.e2e.test.ts
  • Scope: Multi-instance gateway, WebSocket, HTTP surfaces, node pairing
  • Runs in CI: Yes (when enabled)
  • Keys required: No
  • Speed: Slower
Terminal window
pnpm test:live
  • Files: src/**/*.live.test.ts
  • Scope: Real API calls to real providers
  • Runs in CI: No (not CI-stable by design)
  • Keys required: Yes
  • Speed: Depends on provider latency
  • Cost: Real money / rate limits

ScenarioSuite
Editing logic/testspnpm test
Gateway networking changesAdd pnpm test:e2e
”My bot is down” / provider issuesNarrowed pnpm test:live

Live tests have two layers:

Test: src/agents/models.profiles.live.test.ts

Tests providers directly without the gateway. Useful for isolating “is the API broken?” from “is my pipeline broken?”

Terminal window
OPENCLAW_LIVE_MODELS="openai/gpt-5.2" pnpm test:live src/agents/models.profiles.live.test.ts

Test: src/gateway/gateway-models.profiles.live.test.ts

Full pipeline: gateway → agent → model → tools.

Terminal window
OPENCLAW_LIVE_GATEWAY_MODELS="openai/gpt-5.2" pnpm test:live src/gateway/gateway-models.profiles.live.test.ts

Probes included:

  • Read probe: Writes a nonce file, asks agent to read it back
  • Exec+read probe: Asks agent to write then read a file
  • Image probe: Sends an image, expects model to OCR the content

Always use allowlists to avoid running everything:

Terminal window
# Single model, direct
OPENCLAW_LIVE_MODELS="openai/gpt-5.2" pnpm test:live src/agents/models.profiles.live.test.ts
# Single model, gateway
OPENCLAW_LIVE_GATEWAY_MODELS="openai/gpt-5.2" pnpm test:live src/gateway/gateway-models.profiles.live.test.ts
# Multiple providers
OPENCLAW_LIVE_GATEWAY_MODELS="openai/gpt-5.2,anthropic/claude-opus-4-5,google/gemini-3-flash-preview" pnpm test:live

Live tests find credentials the same way the CLI does:

  1. Profile store: ~/.openclaw/credentials/
  2. Config: ~/.openclaw/openclaw.json
  3. Environment variables
Terminal window
# Force profile-only keys
OPENCLAW_LIVE_REQUIRE_PROFILE_KEYS=1 pnpm test:live

Run tests inside Docker for Linux validation:

Terminal window
pnpm test:docker:live-models # Direct models
pnpm test:docker:live-gateway # Gateway + agent
pnpm test:docker:onboard # Onboarding wizard
pnpm test:docker:gateway-network # Two-container networking
pnpm test:docker:plugins # Plugin loading
VariableDefaultDescription
OPENCLAW_CONFIG_DIR~/.openclawMounted to /home/node/.openclaw
OPENCLAW_WORKSPACE_DIR~/.openclaw/workspaceMounted to /home/node/.openclaw/workspace
OPENCLAW_PROFILE_FILE~/.profileSourced before running tests
OPENCLAW_LIVE_GATEWAY_MODELS—Narrow model selection
OPENCLAW_LIVE_MODELS—Narrow model selection (direct)
OPENCLAW_LIVE_REQUIRE_PROFILE_KEYS0Force profile-only credentials
CommandScriptPurpose
test:docker:live-modelsscripts/test-live-models-docker.shDirect model completion
test:docker:live-gatewayscripts/test-live-gateway-models-docker.shGateway + dev agent
test:docker:onboardscripts/e2e/onboard-docker.shTTY onboarding wizard
test:docker:gateway-networkscripts/e2e/gateway-network-docker.shTwo-container WS auth
test:docker:pluginsscripts/e2e/plugins-docker.shCustom extension loading

When you fix a provider/model issue:

  1. CI-safe first: Mock/stub the provider if possible
  2. Live-only if necessary: Keep it narrow and env-gated
  3. Target the right layer:
    • Provider bug → models.profiles.live.test.ts
    • Pipeline bug → gateway-models.profiles.live.test.ts

Narrow, explicit allowlists are fastest and least flaky:

Terminal window
# Single model, direct (no gateway)
OPENCLAW_LIVE_MODELS="openai/gpt-5.2" pnpm test:live src/agents/models.profiles.live.test.ts
# Single model, gateway smoke
OPENCLAW_LIVE_GATEWAY_MODELS="openai/gpt-5.2" pnpm test:live src/gateway/gateway-models.profiles.live.test.ts
# Tool calling across several providers
OPENCLAW_LIVE_GATEWAY_MODELS="openai/gpt-5.2,anthropic/claude-opus-4-5,google/gemini-3-flash-preview,zai/glm-4.7,minimax/minimax-m2.1" pnpm test:live src/gateway/gateway-models.profiles.live.test.ts
# Google focus (Gemini API key + Antigravity)
OPENCLAW_LIVE_GATEWAY_MODELS="google/gemini-3-flash-preview" pnpm test:live src/gateway/gateway-models.profiles.live.test.ts
OPENCLAW_LIVE_GATEWAY_MODELS="google-antigravity/claude-opus-4-5-thinking" pnpm test:live src/gateway/gateway-models.profiles.live.test.ts

Test: src/agents/anthropic.setup-token.live.test.ts

Verify Claude Code CLI setup-token can complete an Anthropic prompt.

Terminal window
# Enable
OPENCLAW_LIVE_SETUP_TOKEN=1 pnpm test:live src/agents/anthropic.setup-token.live.test.ts
# With profile
OPENCLAW_LIVE_SETUP_TOKEN_PROFILE=anthropic:setup-token-test pnpm test:live
# With raw token
OPENCLAW_LIVE_SETUP_TOKEN_VALUE=sk-ant-oat01-... pnpm test:live

Setup:

Terminal window
openclaw models auth paste-token --provider anthropic --profile-id anthropic:setup-token-test

Test: src/gateway/gateway-cli-backend.live.test.ts

Validate the Gateway + agent pipeline using a local CLI backend (like Claude Code CLI).

Terminal window
# Basic
OPENCLAW_LIVE_CLI_BACKEND=1 pnpm test:live src/gateway/gateway-cli-backend.live.test.ts
# With model override
OPENCLAW_LIVE_CLI_BACKEND=1 \
OPENCLAW_LIVE_CLI_BACKEND_MODEL="claude-cli/claude-sonnet-4-5" \
pnpm test:live src/gateway/gateway-cli-backend.live.test.ts

Environment Variables:

VariableDefaultDescription
OPENCLAW_LIVE_CLI_BACKEND_MODELclaude-cli/claude-sonnet-4-5Model to use
OPENCLAW_LIVE_CLI_BACKEND_COMMANDclaudeCLI command path
OPENCLAW_LIVE_CLI_BACKEND_ARGS["-p","--output-format","json","--dangerously-skip-permissions"]CLI args
OPENCLAW_LIVE_CLI_BACKEND_IMAGE_PROBE0Enable image attachment test
OPENCLAW_LIVE_CLI_BACKEND_RESUME_PROBE0Enable multi-turn test

ProviderModel
OpenAIopenai/gpt-5.2
OpenAI Codexopenai-codex/gpt-5.2
Anthropicanthropic/claude-opus-4-5
Google (API)google/gemini-3-flash-preview
Google (Antigravity)google-antigravity/claude-opus-4-5-thinking
Z.AIzai/glm-4.7
MiniMaxminimax/minimax-m2.1
Terminal window
OPENCLAW_LIVE_GATEWAY_MODELS="openai/gpt-5.2,openai-codex/gpt-5.2,anthropic/claude-opus-4-5,google/gemini-3-flash-preview,zai/glm-4.7,minimax/minimax-m2.1" pnpm test:live src/gateway/gateway-models.profiles.live.test.ts
Terminal window
openclaw models list
openclaw models list --json

Test: src/media-understanding/providers/deepgram/audio.live.test.ts

Terminal window
DEEPGRAM_API_KEY=... DEEPGRAM_LIVE_TEST=1 pnpm test:live src/media-understanding/providers/deepgram/audio.live.test.ts

Run docs checks after doc edits:

Terminal window
pnpm docs:list

These run in CI without real providers:

TestDescription
gateway.tool-calling.mock-openai.test.tsGateway tool calling with mock OpenAI
gateway.wizard.e2e.test.tsWizard WebSocket + config writes

Current coverage:

  • Mock tool-calling through real gateway + agent loop
  • End-to-end wizard flows with session wiring

What’s planned:

  • Decisioning: Does agent pick the right skill?
  • Compliance: Does agent follow skill instructions?
  • Workflow contracts: Multi-turn tool order assertions

Still stuck? Our AI Setup Assistant can help with test issues.



Need help? Join the OpenClaw Discord or check the GitHub Issues.

OpenClaw

OpenClaw Expert

Still stuck?

If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.