Zero network calls
All responses are generated in-process from a deterministic seed — no live APIs, no flaky tests.
Testing infrastructure
Deterministic, in-process fake HTTP APIs for testing agents and tools. Swap real network calls for canned responses — GitHub, Stripe, OpenAI, S3, Slack, and more — with recording, replay, eval scenarios, and chaos injection built in.
npm install stubfetchimport { GhostEnv, github, stripe } from "stubfetch";
const env = new GhostEnv({
seed: 42,
providers: [
github({ issues: [{ repo: "acme/api", title: "Bug" }] }),
stripe({ customers: [{ email: "[email protected]" }] }),
],
});
// Same shape as globalThis.fetch
const res = await env.fetch(
"https://api.github.com/repos/acme/api/issues"
);
console.log(await res.json()); // [{ title: "Bug", ... }]
// Inspect calls
console.log(env.wasCalled("github")); // truePresets
Issues, pull requests, repos — GitHub REST API shape
Customers, charges, subscriptions
Chat completions and messages API
db().query(), object storage, Web API
Capabilities
Zero network calls
All responses are generated in-process from a deterministic seed — no live APIs, no flaky tests.
Recording & replay
calls(), wasCalled(), exportRecordingJSON / Markdown / HAR. Replay canned fixtures in order.
Eval scenarios
defineScenario + runEval let you script and score agent behaviour across repeatable test runs.
Chaos injection
chaos: { minLatencyMs, failureRate } — inject latency and random failures to test resilience.