Skip to content

Conversation

@PankajSati-apl
Copy link
Contributor

Changes -

  1. SWC Plugin : Adds a Jest/Vitest snippet to detect whether mockreturnvalue || mockimplementation keys exist on the function object
    a. If they do, we can mark the hook as mocked because only testing libraries add these methods
  2. Runtime: Added isMocked to the onHookChange callback
    a. The key is only added when it is set to true

Why mockreturnvalue || mockimplementation ?

Copy link
Owner

@sidx1024 sidx1024 left a comment

Choose a reason for hiding this comment

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

Thanks for this PR, overall implementation looks good but there's a few suggestions:

  1. I see that the new changes adds check like isMocked: typeof useFieldValues === "function" && ("mockImplementation" in useFieldValues || "mockReturnValue" in useFieldValues) to every hook. In order to keep the generated files smaller, can we instead have h.m(useFieldValues)? I've left an example as a suggestion. The function m should be returned by useJitterScope and it will internally do the same check.

  2. Can we update the documentation for these changes?

  3. Please add a changeset (minor).

@sidx1024 sidx1024 merged commit 79806d0 into sidx1024:main Jan 21, 2026
2 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.

2 participants