Skip to content

chore: improve spyOn ESM namespace error guidance#9505

Open
brightcat1 wants to merge 5 commits intovitest-dev:mainfrom
brightcat1:fix/spyOn-esm-namespace-message
Open

chore: improve spyOn ESM namespace error guidance#9505
brightcat1 wants to merge 5 commits intovitest-dev:mainfrom
brightcat1:fix/spyOn-esm-namespace-message

Conversation

@brightcat1
Copy link

Description

Resolves #9467

Improve vi.spyOn error guidance when spying on native ESM module namespace exports (non-configurable).
In Browser Mode, the message now points to the Browser "Spying on Module Exports" limitations section.
In Node/SSR, it instead suggests inlining dependencies via "test.server.deps.inline" and using module mocking docs.
Also updated docs/guide/migration.md with a short v4 migration note for this case.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.
    • Updated docs/guide/migration.md (v4 migration note for vi.spyOn on native ESM namespace exports).

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link

netlify bot commented Jan 22, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 669b2ec
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69765d5d6cb59e000828750d
😎 Deploy Preview https://deploy-preview-9505--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

Misleading error messages relating to spyOn modules. - "Cannot spy on export "[X]". Module namespace is not configurable in ESM"

1 participant