Skip to content

Conversation

@sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Jul 30, 2025

Description

Fixes #8319
Fixes #8307
Fixes #6948
Fixes #8331
Fixes #8134
Fixes #8345

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jul 30, 2025

@vitest/browser

npm i https://pkg.pr.new/@vitest/browser@8363

@vitest/coverage-istanbul

npm i https://pkg.pr.new/@vitest/coverage-istanbul@8363

@vitest/coverage-v8

npm i https://pkg.pr.new/@vitest/coverage-v8@8363

@vitest/expect

npm i https://pkg.pr.new/@vitest/expect@8363

@vitest/mocker

npm i https://pkg.pr.new/@vitest/mocker@8363

@vitest/pretty-format

npm i https://pkg.pr.new/@vitest/pretty-format@8363

@vitest/runner

npm i https://pkg.pr.new/@vitest/runner@8363

@vitest/snapshot

npm i https://pkg.pr.new/@vitest/snapshot@8363

@vitest/spy

npm i https://pkg.pr.new/@vitest/spy@8363

@vitest/ui

npm i https://pkg.pr.new/@vitest/ui@8363

@vitest/utils

npm i https://pkg.pr.new/@vitest/utils@8363

vite-node

npm i https://pkg.pr.new/vite-node@8363

vitest

npm i https://pkg.pr.new/vitest@8363

@vitest/web-worker

npm i https://pkg.pr.new/@vitest/web-worker@8363

@vitest/ws-client

npm i https://pkg.pr.new/@vitest/ws-client@8363

commit: 4f48ca9

@netlify
Copy link

netlify bot commented Jul 30, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit 4f48ca9
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/688cc6fd94ac540009eb3a1a
😎 Deploy Preview https://deploy-preview-8363--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.

@sheremet-va sheremet-va requested a review from Copilot July 31, 2025 17:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a significant rewrite of the spying/mocking implementation to make module mocking more logical and address multiple long-standing issues. The changes focus on creating a custom mock implementation to replace the reliance on tinyspy, improving consistency between different execution environments, and providing better module mocking behavior.

Key changes include:

  • Complete rewrite of the spy implementation with a custom mock system
  • Improved module mocking behavior with better instance/prototype state management
  • Enhanced constructor support and class mocking capabilities

Reviewed Changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/spy/src/index.ts Complete rewrite implementing custom mock system replacing tinyspy
packages/spy/src/types.ts New type definitions for the mock system
packages/spy/package.json Removed tinyspy dependency
packages/mocker/src/automocker.ts Updated to use new createMockInstance API
packages/vitest/src/integrations/vi.ts Updated to use new mock clearing/resetting functions
test/core/test/spy.test.ts Added test for ignoring nodejs promisify symbol
docs/guide/module-mocking.md New comprehensive module mocking guide
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@sheremet-va sheremet-va marked this pull request as ready for review August 1, 2025 12:34
@sheremet-va sheremet-va changed the title fix!: rewrite spying implementation to make module mocking more logical fix!: rewrite spying implementation to make module mocking more intuitive Aug 1, 2025
@sheremet-va sheremet-va merged commit 9e412de into vitest-dev:main Aug 1, 2025
14 of 15 checks passed
@sheremet-va sheremet-va deleted the fix/mocking-rewrite branch August 1, 2025 14:13
@sheremet-va sheremet-va changed the title fix!: rewrite spying implementation to make module mocking more intuitive fix!: rewrite spying implementation to make mocking more intuitive Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment