You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flaky test: store.test.ts "returns undefined before any config is set" depends on file execution order under Bun #374
it('returns undefined before any config is set',()=>{assert.equal(getResolvedConfig(),undefined)})
The file's only cleanup hook is afterEach, which runs after each test. The first test therefore relies on the module's initial state (_config = undefined at module load time).
Under Node's built-in --test runner, each test file runs in an isolated worker, so the singleton state is always fresh.
Under Bun's runner, all test files share a single process and the same module instance. Whenever another test file (test/lib/cloud-client.test.ts, test/lib/es-client.test.ts, test/lib/kibana-client.test.ts, test/kb/kibana-client.test.ts, test/factory.test.ts) loads first and calls setResolvedConfig, its afterEach is supposed to reset state — but file ordering, parallelism, and missing before cleanup combine to expose a race where _config is non-undefined when the store test starts.
Small changes to other test files (adding/removing tests, renaming describes) can shift Bun's file-discovery order and trigger the failure. This makes it a latent CI hazard that surfaces on unrelated PRs.
Suggested fix
Add an explicit reset before the first test so it's order-independent:
Optionally rename the first test from "returns undefined before any config is set" → "returns undefined when the store has been reset" so the assertion matches what's actually being verified.
The same pattern (relying on initial singleton state) should be audited in other test files that import from src/config/store.ts to make sure none of them have a similar order-dependent first test.
Acceptance criteria
test/config/store.test.ts passes regardless of which test files run before it.
CI is green on both the Node and Bun runners after the fix is merged.
Documented in the PR description that the fix is for a Bun-specific cross-file isolation gap.
Activity
hjoncour commentedon Jul 23, 2026
Hey!
It looks like this has been addressed by @margaretjgu in #386
JoshMock commentedon Jul 24, 2026
So it does! 🖤