Skip to content

fix(spy): copy over static properties from the function#7780

Merged
sheremet-va merged 12 commits intovitest-dev:mainfrom
sheremet-va:fix/update-tyinspy
Jun 2, 2025
Merged

fix(spy): copy over static properties from the function#7780
sheremet-va merged 12 commits intovitest-dev:mainfrom
sheremet-va:fix/update-tyinspy

Conversation

@sheremet-va
Copy link
Copy Markdown
Member

@sheremet-va sheremet-va commented Apr 1, 2025

Description

Fixes #6765
Fixes #7804
Fixes #7801

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.

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 1, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit 227ba6a
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/683af1a25fdc0c00087390ca
😎 Deploy Preview https://deploy-preview-7780--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
Copy link
Copy Markdown
Member Author

Tinyspy now always restores the original method correctly. The getOriginal returns the proper value even if the spy was applied multiple times.

hi-ogawa
hi-ogawa previously approved these changes Apr 4, 2025
AriPerkkio
AriPerkkio previously approved these changes Apr 4, 2025
@sheremet-va sheremet-va dismissed stale reviews from AriPerkkio and hi-ogawa via dc047c0 April 17, 2025 10:23
@sheremet-va sheremet-va moved this to P2 - 5 in Team Board Apr 17, 2025
@sheremet-va sheremet-va added the p2-to-be-discussed Enhancement under consideration (priority) label Apr 17, 2025
@sheremet-va sheremet-va moved this from P2 - 5 to Has plan in Team Board May 1, 2025
expect(obj.property).toBe(true)
})

it('respyin on a spy resets the counter', () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As long as this is working, it follows the expectation raised by #7348 (comment), so it looks safe to me. I cannot think of use cases where "spyOn multiple times" below causing issues.

@sheremet-va sheremet-va merged commit 9b9f09b into vitest-dev:main Jun 2, 2025
13 checks passed
@sheremet-va sheremet-va deleted the fix/update-tyinspy branch June 2, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2-to-be-discussed Enhancement under consideration (priority)

Projects

Archived in project

3 participants