molecule-mcp-claude-channel/bunfig.toml
devops-engineer 1a988eba1a
All checks were successful
Test / bun test (pull_request) Successful in 21s
fix(test): preload env-mock so server.ts can be imported in tests (closes #3 phase 2)
server.ts:92 has a required-config guard that calls process.exit(1)
when MOLECULE_PLATFORM_URL / MOLECULE_WORKSPACE_IDS /
MOLECULE_WORKSPACE_TOKENS are unset. Test files import pure helpers
from server.ts (formatRemovedWorkspaceError + others), and the mere
act of importing executes server.ts top-level — including that guard —
which kills the test runner before any test runs.

Fix: add tests/setup.ts that sets fake values via ??= (only when unset,
so a dev running 'bun test' with a populated .env locally isn't
overridden), and bunfig.toml [test].preload that runs setup.ts before
any test file imports.

Verified locally: 13 pass / 0 fail. The server.ts boot path still runs
during tests (watchers spin up, fail to connect to localhost:18080,
log a warning) but doesnt affect the pure-helper tests.

Phase 2 of mcp-claude-channel#3 — Phase 1 was the bun-version pin
in PR #4 (one CI hop earlier; setup-bun is no longer the failure
point). This PR addresses the *test setup* failure that became
visible once setup-bun stopped masking it.
2026-05-07 05:02:40 -07:00

7 lines
248 B
TOML

# bunfig.toml — preload the test env-mock setup so server.ts's
# required-config guard doesn't call process.exit(1) when test files
# import pure helpers from it. See tests/setup.ts for the full
# rationale.
[test]
preload = ["./tests/setup.ts"]