English
Test fakes and the two e2e servers
Generated from docs/standards/test-fakes.md · npm run docs:gen
Fake programs
Status: alpha. This format can still change before its 1.0; a change follows the versioning rules of the project and is announced in the changelog.
tests/fakes/openclaw/openclaw dispatches to tests/fakes/openclaw/commands/<command>.mjs (one file per command, loaded by name; a lot adds its own file). Provided: agent.mjs (reply FAKE_OPENCLAW_REPLY, else "<agent> heard you (<n> characters)."), config.mjs (get, set, unset, --dry-run, SecretRef builder; FAKE_OPENCLAW_CONFIG), skills.mjs (list, install; FAKE_OPENCLAW_SKILLS), models.mjs, channels.mjs (list, add, login, remove; FAKE_OPENCLAW_CHANNELS, FAKE_OPENCLAW_GUIDED), secrets.mjs (store set|list|rm; keeps the size of a value, never the value; FAKE_OPENCLAW_SECRETS_ECHO prints it back), cron.mjs (list, enable, disable, run; FAKE_OPENCLAW_CRON), nodes.mjs (status; FAKE_OPENCLAW_PERMISSIONS, FAKE_OPENCLAW_NODES), pairing.mjs (list, approve; FAKE_OPENCLAW_PAIRING), agents.mjs (list, set-identity; FAKE_OPENCLAW_AGENT_NAME), update.mjs (status only), memory.mjs (search, which needs --agent as on a Mac with several agents; FAKE_OPENCLAW_MEMORY). A fake that changes state keeps it in $WORLD_HOME/.fake-openclaw-*.json, in the shapes OpenClaw 2026.12.2 prints. tests/fakes/bin/ holds claude, brew, git, python3.13 and a link to the fake openclaw, all through fake-bin.mjs.
The sign-in fakes (state in $WORLD_HOME/.fake-<program>-login, never a real account):
claude auth login: with$BROWSERset (the page flow ofsignin.cli) it plays Claude Code 2.1: "Opening browser to sign in…", an OSC 8 link tohttps://claude.ai/oauth/authorize?…, then "Paste code here if prompted > ".good-code#fake-statesigns in ("Login successful.", exit 0); a line without#prints "That doesn't look like the full code" and waits again; any other code prints "Couldn't log in: Invalid authorization code" (exit 1)..fake-claude-link-hostreplaces the link's host (a link to a host the step does not allow). Without$BROWSER(a Terminal window) it signs in at once, or not at all with.fake-claude-login-skip.codex login --device-auth: the linkhttps://auth.openai.com/codex/deviceand the codeABCD-12345in colours, then signs in afterFAKE_CODEX_DEVICE_MS(.fake-codex-device-deny: refused).codex login --with-api-keyreads a key on stdin (sk-fake-good…signs in).gh(tests/fakes/bin/gh):auth status,auth login --with-token(gho_fake_good…), andauth login --web, which prints the one-time codeWXYZ-1234andhttps://github.com/login/deviceas gh does without a TTY, then signs in afterFAKE_GH_DEVICE_MS.alta-signin-practice(thepracticetool, the docs' example pack): every flow (login --link|--device|--email|--token|--browser,status);PRACTICE-OKandpractice-tokensign in;FAKE_PRACTICE_WAIT_MSis how long the device and e-mail flows wait.
Every call is appended to FAKE_LOG (default $WORLD_HOME/calls.jsonl) as { bin, argv, stdinBytes }: never the content of stdin. Delays and failures: FAKE_<BIN>_DELAY_MS, FAKE_<BIN>_<COMMAND>_DELAY_MS, FAKE_<BIN>_FAIL (BIN in capitals, - and . as _).
Servers
tests/helpers/server.ts (vitest): sandboxEnv(home), startServer(args, env) on a free port, calls(home).
playwright.config.ts: two servers, each with its own temporary home and WORLD_SANDBOX=1, one worker:
| Project | Port | Flags | Specs |
|---|---|---|---|
| demo | 8799 | --demo (read only) | *.spec.ts |
| write | 8798 | --demo --allow-ask --allow-install --allow-setup --allow-forge, fake programs | *.write.spec.ts |
The write server's game is content/branches.json with the quests of tests/fixtures/do-it/lab.quests.json and of examples/signin/practice.fragment.json added (WORLD_BRANCHES).
tests/e2e/fixtures.ts: SERVERS, headers(s), openGame(page, s, query) (returns page and console errors), W(page, expr) (evaluates with w = window.__world), api(request, s, method, path, data?), resetSave(request, s), readCalls() (the write server's journal). The quest panel (<alta-quest-rail>, #rail): rail(page), railNow(page) (its step to do now), railStep(page, id), openInRail(page, uid) (the journal, the quest's card, then "Do it in the quest panel"), tickInRail(page) (the primary control of the step to do now), stepState(page, id), and playGuide(page) (the first-session guide played to its end).