Skip to content

test: resolve tsx CLI via createRequire for vitest module runner#728

Open
Dmatut7 wants to merge 1 commit into
MoonshotAI:mainfrom
Dmatut7:fix/vitest-import-meta-resolve
Open

test: resolve tsx CLI via createRequire for vitest module runner#728
Dmatut7 wants to merge 1 commit into
MoonshotAI:mainfrom
Dmatut7:fix/vitest-import-meta-resolve

Conversation

@Dmatut7

@Dmatut7 Dmatut7 commented Jun 13, 2026

Copy link
Copy Markdown

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 tsx CLI path with import.meta.resolve(...), which is not supported inside Vitest's module runner: packages/oauth/test/oauth-manager-multi-process.test.ts fails to load, and the unhandled-rejection crash test in packages/telemetry/test/telemetry.test.ts throws before spawning its worker.

What changed

Resolve the tsx CLI with createRequire(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

  • I have read the CONTRIBUTING document.
  • I have explained the problem above.
  • I have added tests that prove the fix works (these two suites now run).
  • This PR needs no changeset (test-only).
  • This PR needs no doc update.

`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>
@changeset-bot

changeset-bot Bot commented Jun 13, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4a16306

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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