Skip to content

fix: updates test to mock the getPackageManager call#3745

Open
andguy95 wants to merge 2 commits intomainfrom
an-fix-upgrade-test-pnpm-global-context
Open

fix: updates test to mock the getPackageManager call#3745
andguy95 wants to merge 2 commits intomainfrom
an-fix-upgrade-test-pnpm-global-context

Conversation

@andguy95
Copy link
Copy Markdown
Collaborator

WHY are these changes introduced?

Two tests in upgrade.test.ts (should allow --version=next in tests and CI environments and should complete full upgrade flow with --version=next) fail in CLI because getPackageManager shells out to npm prefix, which is rejected now with "npm is no longer supported in a global context."

Screenshot 2026-04-22 at 1 27 33 PM

WHAT is this pull request doing?

Mocks getPackageManager from @shopify/cli-kit/node/node-package-manager in the upgrade test file. This prevents the test from spawning a real npm subprocess during displayUpgradeSummary. The mock uses vi.importActual to preserve all other real exports (like the PackageJson type) while only replacing the one function that shells out.

No production code is changed — the fix is test-only.

HOW to test your changes?

pnpm --filter @shopify/cli-hydrogen run test -- upgrade.test.ts

All 71 tests should pass, including the two that previously failed:

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or functional changes. Test changes or internal-only config changes do not require a changeset.
  • I've added tests to cover my changes
  • I've added or updated the documentation

@shopify
Copy link
Copy Markdown
Contributor

shopify Bot commented Apr 22, 2026

Oxygen deployed a preview of your an-fix-upgrade-test-pnpm-global-context branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment April 24, 2026 3:23 PM

Learn more about Hydrogen's GitHub integration.

@andguy95 andguy95 requested a review from kdaviduik April 22, 2026 20:40
@andguy95 andguy95 marked this pull request as ready for review April 22, 2026 20:40
@andguy95 andguy95 requested a review from a team as a code owner April 22, 2026 20:40
@github-actions
Copy link
Copy Markdown
Contributor

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset.
If the changes are user-facing and should cause a version bump, run pnpm run changeset add to track your changes and include them in the next release CHANGELOG.
If you are making simple updates to examples or documentation, you do not need to add a changeset.

Copy link
Copy Markdown
Contributor

@fredericoo fredericoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for the fix

one nit below

Comment thread packages/cli/src/commands/hydrogen/upgrade.test.ts Outdated
Co-authored-by: ✦ freddie <45042736+fredericoo@users.noreply.github.com>
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.

ci: upgrade.test.ts tests fail after npm blocked in dev environments

2 participants