fix(bridge): mock config.env in config tests to avoid local env leaks#28
Merged
Conversation
loadConfig reads ~/.tlive/config.env which can contain TL_PORT etc., causing the "uses defaults" test to fail on machines with a local config. Mock readFileSync to throw ENOENT for config.env so tests use pure defaults regardless of the developer's local setup.
Xiaofuziod
approved these changes
Apr 6, 2026
Xiaofuziod
left a comment
Contributor
There was a problem hiding this comment.
LGTM — verified locally.
Ran into the exact same failure on macOS with a local ~/.tlive/config.env containing TL_RUNTIME=codex. The vi.mock approach correctly intercepts readFileSync and the bare catch in loadEnvFile handles it cleanly.
Confirmed:
- 443/443 tests pass with the fix
- The mock scope is correct (module-level, config.env paths only, other reads pass through)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
loadConfig()reads~/.tlive/config.envat runtime. When a developer has a local config withTL_PORT=7849(or any non-default value), the "uses defaults when no env vars set" test fails because the env file value overrides the expected default of 8080.Fix: mock
readFileSyncto throwENOENTforconfig.envpaths, so tests run with pure defaults regardless of the developer's local setup.Test plan
config.test.ts7/7 pass on machine with local~/.tlive/config.env