External Service Testing external-service-testing
Build, register, and verify stateful network-boundary emulators for external APIs and services: audit outbound calls, choose vibestack/emulate or vercel-labs/emulate, emulate voice/LLM/image/map services deterministically, verify shapes against real APIs with mandatory secret redaction, and keep tests and CI offline.
- Our test
- —
- not tested yet
- GitHub stars
- 20k
- elizaos/eliza
- Added by
- 0
- members
- Updated
- Dec 6
- commit e932464
- Content
- 1 file
- no scripts · 11 KB
- License
- MIT
- free to use
What our test found
Not tested yet. Our model tries every skill on a realistic request and scores the result, the most popular skills first. Until then, the safety checks on the right still apply.
name: external-service-testing description: "Build, register, and verify stateful network-boundary emulators for external APIs and services: audit outbound calls, choose vibestack/emulate or vercel-labs/emulate, emulate voice/LLM/image/map services deterministically, verify shapes against real APIs with mandatory secret redaction, and keep tests and CI offline."
External service testing
Run this skill whenever a new external service is added, an outbound API integration changes, or an existing integration lacks a stateful emulator. Read in full once per session.
Real local services (in-process DBs, local workerd, local servers, queues, filesystems) run directly. Fake only services that cost money, cannot be undone, or cannot be run and reset locally — and fake them once at the network boundary, shared by every test (). Never mock your own application code, and never ship emulator code in production bundles.
1. Audit outbound external services
Run the built-in codebase auditor first:
pnpm exec vibestack emulate audit --json(In this repository, node vibestack/spec.ts emulate audit --json runs the same audit directly from source.)
The auditor scans src/ for outbound https:// and wss:// URLs, *_API_KEY / *_BASE_URL environment bindings, and known external SDK imports (openai, @anthropic-ai/sdk, stripe, @slack/web-api, cartesia, Google Maps, and similar), then cross-references them against emulators/manifest.json (honoring optional ignoreHosts and ignoreDirs allowlists) to flag uncovered services.
Resolve every uncovered external service before running story QA ().
2. Choose the right emulation tier
Pick the lightest tier that models the real wire protocol and stateful behavior:
| Tier | Tooling | Use when | Avoid when | |---|---|---|---| | Tier 0 (default, zero-dep) | vibestack/emulate (createEmulatorServer, SseHub, RequestLog, FaultArmory, /__control/*, namespace isolation) | Custom REST/JSON/SSE/WS APIs, domain backends, LLM/voice/image/map emulators, or when zero extra dependencies and sub-second CI startup matter | A maintained Tier 1 emulator already implements the full SaaS API surface you need | | Tier 1 (standard SaaS & AI) | vercel-labs/emulate (emulate, @emulators/ai, defineEmulator) wrapped via wrapEmulateService from vibestack/emulate | Standard Apache-2.0 built-ins already exist (OpenAI, Anthropic, Gemini, ElevenLabs, Stripe, GitHub, Google, Slack, Resend, Twilio, AWS, Clerk, Linear, Vercel) | The service is bespoke or only 1–2 endpoints are called (prefer Tier 0 over adding a 10+ MB dependency) |
Why `crvouga/mockingbird` is not a default dependency: its runtime plus SQLite WASM base weighs ~31 MB and carries solo-maintainer bus factor. Vibestack adopts its two best ideas natively inside vibestack/emulate instead: per-request namespace isolation (x-vibestack-namespace header or vibestack-ns cookie) and canonicalized differential live-parity shape verification (diffShapes). Reach for an individual Mockingbird service package only as an explicit, isolated escape hatch when no Tier 0 or Tier 1 option fits.
Core vibestack/emulate primitives
- `createEmulatorServer<S>(config)` — stateful Node 26 HTTP + SSE server with per-namespace state (
getState(ns?),setState(next, ns?),reset(ns?)), atomic0o600JSON persistence, CORS/OPTIONS preflight, and safeparseRequest(1 MB cap, prototype-pollution guard),bearerToken,verifyPkceS256,paginateSlice,sendJson,sendHtml,sendRedirect, andsendBytes. - Built-in control plane —
POST /__control/reset,GET /__control/requests,GET /__control/state,POST /__control/fault, andDELETE /__control/fault(extensible viaonControl). - `SseHub` — server-sent event fan-out with event filtering, replay,
broadcast,closeWhere, andcloseAll. - `RequestLog` — bounded ring buffer (
record,list(filter?),clear) backingGET /__control/requestsand QA evidence collection. - `FaultArmory` — deterministic fault injection (
arm,consume,list,clear) supporting HTTP method, path glob, status (429,500,503),retryAfter, custombody,remainingcount,delayMs, andstall.
3. Specialized service patterns
Voice (STT, TTS, and Realtime WebSocket)
- Tier A — default for CI (<10ms, 0 MB, 100% deterministic):
- Use
createWavFixture,pcm16Tone, andcreateVoiceTranscriptMapfromvibestack/emulate(or@emulators/aiaudio routes for OpenAI/ElevenLabs). - Serve valid RIFF/WAVE PCM16 buffers over HTTP or local WebSockets so tests verify audio framing, sample rate, VAD/turn-commit protocol, barge-in cancellation, and deterministic transcript/audio roundtrips without shipping heavy acoustic models.
- Tier B — opt-in local acoustic testing only (never required in default CI):
- Use
sherpa-onnx(Node-API native addon, local STT and TTS without Python) only when human-listening or speaker-to-mic acoustic pipeline testing is explicitly needed locally. Never gatepnpm checkor CI on downloading ONNX weights.
LLM, Image, and Map services
- LLM: Use
createCannedMatcher({ rules, strict: true })fromvibestack/emulate(or@emulators/ai) keyed directly tospec/**/*.mdstory and QA queries (match,textContains,model,tool,path, plus statefulturn/callCount). Keepstrict: truein QA so unmatched prompts fail loudly instead of silently returning filler. Model stateful conversation/response IDs, SSE token streaming (SseHub), tool-call loops, structured JSON outputs, and429/503/stall faults viaFaultArmory. - Image: Return valid binary PNGs via
createPngFixture({ width, height, rgba })(CRC32 + zlib-deflated PNG) or@emulators/aiimage routes, and model async polling APIs with explicit job progression (queued->running->completed/failed). - Maps, Geocoding, Places, and Routing: Serve valid PNG tiles via
createPngFixture, schema-valid GeoJSON/Places/Directions fixtures keyed to canonical QA queries, and stateful error/quota triggers (ZERO_RESULTS,OVER_QUERY_LIMIT,REQUEST_DENIED).
4. Author doc-first, then capture and verify against the real API
Never block offline development on live credentials, and never pretend an unverified emulator matches production.
- Draft from official documentation: Read the provider's official API docs, OpenAPI specification, or SDK schemas first (). Implement a complete stateful emulator and register it in
emulators/manifest.jsonwith: service,kind("http" | "ws" | "llm" | "voice" | "image" | "maps" | "custom"),provider("emulate-builtin" | "vibestack-custom" | "local-model" | "canned-fixture"),baseUrlEnv,docsUrl,files,status: "unverified",contractHash, and optionalverifiedEndpoints,capturesDir, andnotes.- Surface verification status loudly: Offline tests work immediately with
status: "unverified", andpnpm exec vibestack emulate status(or--json) warns explicitly about everyunverifiedorstaleemulator. Pass--strict-verifiedonly when gating a release or local verification pass on 100% verified contracts. - Capture real HTTP exchanges locally (never in CI PRs): Whenever sandbox or dev credentials are available on your machine, record real exchanges: ``
bash pnpm exec vibestack emulate capture --service <name> --url <url> [--method GET] [--header K:V] [--body JSON] [--out <file>] [--json]`captureExchangeenforces mandatory secret redaction (redactHeaders,redactUrl,redactPayload,assertNoSecrets) **before anything is written to disk**: it scrubs auth headers, cookies, secret query params, sensitive JSON keys (secret,token,key,password,credential,auth), JWTs, and provider key prefixes (sk_`, `ghp_,xox`, `AIza`), and throws if any unredacted secret matches. - Verify canonicalized shape parity: Run the captured exchange against your local emulator: ``
bash pnpm exec vibestack emulate verify --service <name> --capture <file> --emulator-url <url> [--json]`verifyEmulatorParity/diffShapesstrips volatile fields (UUIDs, ISO dates, timestamps, request IDs, nonces, signatures) and compares HTTP status,content-type`, required JSON keys, value types, nullability, array item shapes, and error envelopes. - Fix drift and stamp `verified`: Fix every status, header, envelope, or field-type mismatch in the emulator until
verifypasses. Passingverifystampsstatus: "verified",contractHash, andverifiedAtinemulators/manifest.json. - Automatic staleness on edit:
computeContractHashhashes every file listed infiles. Editing an emulator or fixture changes its hash and automatically flips its resolved status inresolveManifestStatus/emulate statusto"stale"until re-verified.
5. Wire into shell, tests, workerd, and CI
- Inject at the service boundary: Read each external service's base URL from a single typed config/env binding (
*_BASE_URL) in the VibeLang shell (). Point Vitest, Playwright, and localworkerd(pnpm dev:cf,pnpm test:deploy) at loopback127.0.0.1:<port>emulator origins via env bindings — testing real HTTP serialization, headers, status handling, and retries without touching application code. - Keep production bundles clean: Never import
vibestack/emulate,emulate, or emulator fixtures from production app or Worker entrypoints (). - Isolate parallel tests: Pass a per-test
x-vibestack-namespaceheader (orvibestack-nscookie) or callPOST /__control/resetbetween journeys so concurrent tests never collide. - Verify offline in CI: Confirm
pnpm test,pnpm check, andpnpm test:deploy(when applicable) pass with zero external API keys set.
Report
Summarize concisely when done:
- Services audited: external services found by
pnpm exec vibestack emulate audit --jsonand any uncovered integrations closed. - Emulators added or updated: tier chosen (
vibestack/emulatevsvercel-labs/emulate), files touched, andbaseUrlEnvbindings wired. - Verification status: exact
pnpm exec vibestack emulate status --jsonsummary, explicitly flagging everyunverifiedorstaleemulator (and noting any live captures verified). - Offline checks: test, deploy-test, and
pnpm checkresults with no live external credentials.