test: resolve tsx CLI via createRequire for vitest module runner#728
Open
Dmatut7 wants to merge 1 commit into
Open
test: resolve tsx CLI via createRequire for vitest module runner#728Dmatut7 wants to merge 1 commit into
Dmatut7 wants to merge 1 commit into
Conversation
`import.meta.resolve` is not supported inside Vitest's module runner, so
`packages/oauth/test/oauth-manager-multi-process.test.ts` failed to load
and the unhandled-rejection crash test in
`packages/telemetry/test/telemetry.test.ts` threw before spawning the
worker. Both only needed the on-disk path to the `tsx` CLI.
Resolve it with `createRequire(import.meta.url).resolve('tsx/package.json')`
instead, which uses Node's native resolver and works in both Node and the
Vitest module runner. Drops the now-unused `fileURLToPath` import.
Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Related Issue
No existing issue — test-infra fix, problem explained below.
Problem
Two tests fail to run under the current Vitest because they resolve the
tsxCLI path withimport.meta.resolve(...), which is not supported inside Vitest's module runner:packages/oauth/test/oauth-manager-multi-process.test.tsfails to load, and the unhandled-rejection crash test inpackages/telemetry/test/telemetry.test.tsthrows before spawning its worker.What changed
Resolve the
tsxCLI withcreateRequire(import.meta.url).resolve('tsx/package.json'), which uses Node's native resolver and works in both Node and the Vitest module runner. No production code changes.Checklist