Skip to content

Conversation

@nazarhussain
Copy link
Contributor

Description

Fixes the different parsing logic for the bun runtime that is affecting the mocking.

Resolves #9031

Here is stack trace for the NodeJS runtime.

'Error: $$stack trace error',
'    at createSimpleStackTrace (file:///my-project/node_modules/@vitest/utils/dist/helpers.js:43:14)',
'    at getImporter (file:///my-project/node_modules/vitest/dist/chunks/vi.BZvkKVkM.js:3769:21)',
'    at Object.mock (file:///my-project/node_modules/vitest/dist/chunks/vi.BZvkKVkM.js:3655:21)',
'    at /my-project/packages/beacon-node/test/unit/api/impl/events/events.test.ts:2:26',
'    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)'

Here is stack trace for the Bun runtime for same scenario.

'Error: $$stack trace error',
'    at createSimpleStackTrace (/my-project/node_modules/@vitest/utils/dist/helpers.js:43:18)',
'    at getImporter (/my-project//node_modules/vitest/dist/chunks/vi.BZvkKVkM.js:3754:21)',
'    at mock (/my-project/node_modules/vitest/dist/chunks/vi.BZvkKVkM.js:3655:21)',
'    at <anonymous> (/my-project/packages/beacon-node/test/unit/api/impl/events/events.test.ts:2:30)',
'    at runInlinedModule (/my-project/node_modules/vitest/dist/module-evaluator.js:136:118)',
'    at directRequest (/my-project/node_modules/vitest/node_modules/vite/dist/node/module-runner.js:1112:80)',
'    at cachedRequest (/my-project/node_modules/vitest/node_modules/vite/dist/node/module-runner.js:1030:79)',
'    at processTicksAndRejections (native)'

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.

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:.

@sheremet-va sheremet-va merged commit f3ec6fc into vitest-dev:main Nov 17, 2025
12 of 14 checks passed
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.

Vitest module mocking does not work with the Bun runtime

2 participants