Skip to content

fix(mocker)!: deserialize automock as automock#10192

Merged
sheremet-va merged 1 commit intovitest-dev:mainfrom
nami8824:fix/mocker-automocked-fromjson
Apr 25, 2026
Merged

fix(mocker)!: deserialize automock as automock#10192
sheremet-va merged 1 commit intovitest-dev:mainfrom
nami8824:fix/mocker-automocked-fromjson

Conversation

@nami8824
Copy link
Copy Markdown
Contributor

@nami8824 nami8824 commented Apr 25, 2026

Description

Resolves #9706

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

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 25, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit a67b35b
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69ec3d2bf11dd900073881a9
😎 Deploy Preview https://deploy-preview-10192--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.

import { calculate } from './test'

mocker.customMock(import('./test'))
mocker.customMock(import('./test'), { spy: true })
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This fix caused the "autospy works correctly" test case in test/cli/test/public-mocker.test.ts to fail, because the automock was no longer being deserialized as a spy. To fix it, I added { spy: true } to the mocker.customMock() call in the autospy fixture. I think passing { spy: true } explicitly is the correct behavior here.

@sheremet-va sheremet-va changed the title fix(mocker): deserialize automock as automock fix(mocker)!: deserialize automock as automock Apr 25, 2026
@sheremet-va sheremet-va merged commit 2f89271 into vitest-dev:main Apr 25, 2026
22 of 24 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.

vi.mock() does not replace the modules implementation in browser mode

2 participants