Skip to content

test(harness): run deepl invocations against the tree's build, not a global install - #105

Merged
sjsyrek merged 1 commit into
mainfrom
test/hermetic-deepl-shim
Jul 29, 2026
Merged

sjsyrek merged 1 commit into
mainfrom
test/hermetic-deepl-shim

Conversation

@sjsyrek

@sjsyrek sjsyrek commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

23 integration/e2e suites (392 tests) shell out to the bare deepl command, 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

  • Added tests/hermetic-deepl.ts — creates a temp shim directory containing a deepl script that execs node dist/cli/index.js "$@", and prepends it to PATH
  • Added tests/global-setup.ts + jest globalSetup wiring — the shim must be installed in the main jest process before workers spawn; a setupFilesAfterEnv hook cannot do this because test code sees a copied process.env that child processes spawned without an explicit env never inherit (verified empirically — helper-based suites worked from a setup hook, bare execSync('deepl …') calls did not)
  • Added tests/unit/hermetic-deepl.test.ts — pins that deepl resolves to the shim ahead of any global install and reports the tree's package.json version
  • Removed the npm link step from ci.yml — the link only existed to satisfy these suites; removing it makes CI prove hermeticity instead of masking the dependency

Test Coverage

Full suite green with no global deepl installed: 254 suites, 5,702 tests (was 23 suites / 392 tests failing). Lint and type-check pass.

Backward Compatibility

✅ No production code touched. Local npm link for 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

…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>
@sjsyrek
sjsyrek enabled auto-merge (squash) July 29, 2026 14:04
@sjsyrek
sjsyrek merged commit 8cdb1f3 into main Jul 29, 2026
5 checks passed
@sjsyrek
sjsyrek deleted the test/hermetic-deepl-shim branch July 29, 2026 14:07
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