Skip to content

Remove test flakiness via dependency injection#8

Merged
KeKs0r merged 1 commit intomainfrom
marc/fix-verify-test-flakiness
Feb 26, 2026
Merged

Remove test flakiness via dependency injection#8
KeKs0r merged 1 commit intomainfrom
marc/fix-verify-test-flakiness

Conversation

@KeKs0r
Copy link
Contributor

@KeKs0r KeKs0r commented Feb 26, 2026

Summary

Eliminate test flakiness by making unit tests pure and deterministic. Replace global state mutation (process.env save/restore, process.stdout.isTTY manipulation) with dependency injection parameters.

Changes:

  • Add optional env parameter to resolveConnectionConfig() (defaults to process.env)
  • Add optional isTTY parameter to resolveFormat() (defaults to process.stdout.isTTY)
  • Refactor client.test.ts to pass env objects directly instead of mutating process.env
  • Refactor format.test.ts to pass boolean flags instead of mutating process.stdout with Object.defineProperty

Tests are now fully deterministic with zero global state pollution. Existing call sites remain backward-compatible.

🤖 Generated with Claude Code

Replace process.env mutation in client.test.ts and process.stdout.isTTY mutation in format.test.ts with pure dependency injection. Add optional env parameter to resolveConnectionConfig and isTTY parameter to resolveFormat, both defaulting to their original runtime behavior. Eliminates beforeEach/afterEach save/restore overhead and Object.defineProperty hacks, making tests deterministic with zero global state pollution.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@KeKs0r KeKs0r merged commit 03799a9 into main Feb 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant