All checks were successful
Test / bun test (pull_request) Successful in 21s
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.
16 lines
849 B
TypeScript
16 lines
849 B
TypeScript
// tests/setup.ts — preloaded by bunfig.toml's [test].preload before any
|
|
// test file is imported. Sets fake values for the three env vars
|
|
// server.ts requires at top-level (MOLECULE_PLATFORM_URL,
|
|
// MOLECULE_WORKSPACE_IDS, MOLECULE_WORKSPACE_TOKENS). Without this,
|
|
// importing server.ts (which the test files do, to pull
|
|
// formatRemovedWorkspaceError + other pure helpers) hits the
|
|
// required-config guard at server.ts:92 and calls process.exit(1) —
|
|
// killing the test runner before any test runs.
|
|
//
|
|
// `??=` only assigns when the var is unset, so a developer running
|
|
// `bun test` locally with a populated .env file isn't overridden.
|
|
|
|
process.env.MOLECULE_PLATFORM_URL ??= 'http://localhost:18080'
|
|
process.env.MOLECULE_WORKSPACE_IDS ??= 'ws-test-00000000-0000-0000-0000-000000000001'
|
|
process.env.MOLECULE_WORKSPACE_TOKENS ??= 'tok-test'
|