mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 11:59:29 +00:00
DO_DROPLET_SIZE default documented as s-2vcpu-4gb ($24/mo) but code and manifest both use s-2vcpu-2gb ($18/mo). Also fixes stale getUserHome() source reference in testing rules (shared/paths.ts, not shared/ui.ts). Agent: code-health Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1.3 KiB
1.3 KiB
Testing
- NEVER use vitest — use Bun's built-in test runner (
bun:test) exclusively - Test files go in
packages/cli/src/__tests__/ - Run tests with
bun test - Use
import { describe, it, expect, beforeEach, afterEach, mock, spyOn } from "bun:test" - All tests must be pure unit tests with mocked fetch/prompts — no subprocess spawning (
execSync,spawnSync,Bun.spawn) - Test fixtures (API response snapshots) go in
fixtures/{cloud}/
Filesystem Isolation — MANDATORY
Tests MUST NEVER touch real user files. The test preload (__tests__/preload.ts) provides a sandbox:
process.env.HOME→/tmp/spawn-test-home-XXXX/(isolated temp dir)process.env.SPAWN_HOME→$HOME/.spawn(inside sandbox)process.env.XDG_CACHE_HOME→$HOME/.cache(inside sandbox)
Rules for test files:
- NEVER import
homedirfromnode:os— Bun'shomedir()ignoresprocess.env.HOMEand returns the real home. Useprocess.env.HOME ?? ""instead. - NEVER hardcode home directory paths like
/home/user/...or~/... - If you override
SPAWN_HOMEinbeforeEach, save and restore the original inafterEach(the preload sets a safe default) - Use
getUserHome()in production code (fromshared/paths.ts) — it readsprocess.env.HOMEfirst - The
fs-sandbox.test.tsguardrail test verifies the sandbox is active