test(harness): run deepl invocations against the tree's build, not a global install - #105
Merged
Merged
Conversation
…a global install 23 suites shell out to the bare `deepl` command, which resolved from PATH: absent a global install they all failed with "command not found", and present one they silently tested the installed version instead of the working tree. A jest globalSetup now prepends a shim directory to PATH that execs dist/cli/index.js — globalSetup runs in the main process before workers spawn, so every CLI subprocess inherits it; a setupFilesAfterEnv hook cannot do this because test code sees a copied process.env that child processes never inherit. CI's now-redundant `npm link` step is removed, and a unit suite pins that `deepl` resolves to the shim and reports the tree's version. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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
23 integration/e2e suites (392 tests) shell out to the bare
deeplcommand, resolved from PATH. With no global install they all fail with/bin/sh: deepl: command not found; with one installed they silently test the installed version instead of the working tree. This makes those suites hermetic.Changes Made
tests/hermetic-deepl.ts— creates a temp shim directory containing adeeplscript that execsnode dist/cli/index.js "$@", and prepends it to PATHtests/global-setup.ts+ jestglobalSetupwiring — the shim must be installed in the main jest process before workers spawn; asetupFilesAfterEnvhook cannot do this because test code sees a copiedprocess.envthat child processes spawned without an explicitenvnever inherit (verified empirically — helper-based suites worked from a setup hook, bareexecSync('deepl …')calls did not)tests/unit/hermetic-deepl.test.ts— pins thatdeeplresolves to the shim ahead of any global install and reports the tree's package.json versionnpm linkstep fromci.yml— the link only existed to satisfy these suites; removing it makes CI prove hermeticity instead of masking the dependencyTest Coverage
Full suite green with no global
deeplinstalled: 254 suites, 5,702 tests (was 23 suites / 392 tests failing). Lint and type-check pass.Backward Compatibility
✅ No production code touched. Local
npm linkfor manual CLI use (CONTRIBUTING.md) is unaffected — tests simply no longer depend on it.Size: Small ✓
One new 27-line helper, globalSetup wiring, one pinning suite, one CI line removed.
🤖 Generated with Claude Code