🤖 refactor: eliminate TEST_INTEGRATION env var and per-file boilerplate #2392
+201
−580
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
Eliminate the
TEST_INTEGRATIONenv var andshouldRunIntegrationTests()per-file boilerplate from 72 files. Phase 3 of the integration test restructuring (Phase 1: #2370, Phase 2: #2389).Background
Every integration test file repeated the same pattern:
This conflated "integration test" with "needs real AI API keys" — two different concerns. Tests in
tests/are integration tests by definition; whether they need API keys should be expressed differently.Implementation
Infrastructure (4 files)
tests/testUtils.tsshouldRunIntegrationTests(). SimplifiedvalidateApiKeys()/getApiKey()to not depend on env var.tests/ipc/setup.tscreateTestEnvironment({ seedDummyKeys?: boolean })— explicit parameter replaces env var check. Defaulttrueseeds dummy keys for UI tests;setupProviders()overwrites for real-key tests.tests/setup.tspreloadTestModules()in their ownbeforeAll.jest.config.jsTEST_INTEGRATIONternary). AI tests setjest.setTimeout(600_000)individually.Test files (65 files)
shouldRunIntegrationTestsimport +describeIntegrationwrapper → baredescribe()jest.setTimeout(600_000).anthropicCacheStrategy,ollama,system1BashCompactionnow check only key/service availability (notTEST_INTEGRATION)src/node/services/streamManager.test.ts: Replaced env var check with key-availability gate (describeWithApi)tests/run/smoke.integration.test.ts: Same pattern removal +jest.setTimeouttests/testUtils.js+.js.mapartifacts// Skip all tests if TEST_INTEGRATION is not setcomments and Docker skip messagesDeveloper documentation & CI (3 files)
.mux/skills/tests/SKILL.mdTEST_INTEGRATION=1/shouldRunIntegrationTests()guidance. Added guidance onjest.setTimeout(600_000)andvalidateApiKeys()for AI tests. Updated example test paths..github/workflows/pr.ymlTEST_INTEGRATION=1prefixes from CI jest invocations (4 occurrences) andTEST_INTEGRATIONenv var from Windows smoke test job.MakefileTEST_INTEGRATION=1fromtest-integrationtarget.Net impact: -379 lines across 72 files
Validation
make typecheckcleanmake lintcleanmake fmt-checkcleanTEST_INTEGRATION=1validateApiKeys()fails fast when keys missingRisks
jest.config.jstimeout raised from 10s → 120s for all tests. This is safe because unit tests insrc/run underbun test(not jest), and integration tests intests/universally need >10s for service container setup.tests/runtime/files retain their own localshouldRunIntegrationTests()andTEST_INTEGRATIONcheck — these are self-contained, Docker-gated tests with separate infrastructure. Out of scope for this change.src/files that checkTEST_INTEGRATIONfor telemetry suppression or network-calling unit test gating are unrelated concerns and left untouched.Generated with
mux• Model:anthropic:claude-opus-4-6• Thinking:xhigh• Cost:$25.47