Skip to content

feat(runtime-utils): add spy option to mount + render helpers - #1762

Merged
danielroe merged 2 commits into
nuxt:mainfrom
yamachi4416:feat-add-spy-option-to-mount-render-helpers
Aug 3, 2026
Merged

feat(runtime-utils): add spy option to mount + render helpers#1762
danielroe merged 2 commits into
nuxt:mainfrom
yamachi4416:feat-add-spy-option-to-mount-render-helpers

Conversation

@yamachi4416

@yamachi4416 yamachi4416 commented Aug 1, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

resolves #763

📚 Description

Added spy option to mount and render helpers to allow mocking component methods.

@pkg-pr-new

pkg-pr-new Bot commented Aug 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/test-utils@1762
npm i https://pkg.pr.new/vitest-environment-nuxt@1762

commit: d68b0af

@yamachi4416
yamachi4416 marked this pull request as ready for review August 1, 2026 17:29
@yamachi4416
yamachi4416 requested a review from danielroe as a code owner August 1, 2026 17:29
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Added an opt-in spy option to suspended mounting utilities. Object-valued setup results are wrapped with vi.mockObject before exposure through wrapper.setupState. Added CustomRandom components with setup and exposed methods. Added browser and Nuxt tests for spying, mocked random values, button actions, and reactive input updates.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The implementation adds spy support and tests component-method mocking, satisfying the linked issue [#763].
Out of Scope Changes check ✅ Passed All changes support the spy option, including implementation, examples, and tests; no unrelated code is present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely describes the addition of a spy option to the mount and render helpers.
Description check ✅ Passed The description directly explains that the spy option enables mocking component methods.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/runtime-utils/utils/suspended.ts`:
- Line 26: Correct the JSDoc default annotation near the suspended utility’s
documented option by removing the extra trailing quote, so the default is
documented as '/'.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 61641af9-ecc7-49e7-be06-4842af0d3ca2

📥 Commits

Reviewing files that changed from the base of the PR and between d32cec1 and 207b2c8.

📒 Files selected for processing (6)
  • examples/app-vitest-browser/components/CustomRandom.vue
  • examples/app-vitest-browser/test/mount-suspended.spec.ts
  • examples/app-vitest-full/components/CustomRandom.vue
  • examples/app-vitest-full/tests/nuxt/mount-suspended.spec.ts
  • examples/app-vitest-full/tests/nuxt/render-suspended.spec.ts
  • src/runtime-utils/utils/suspended.ts

Comment thread src/runtime-utils/utils/suspended.ts Outdated
@danielroe danielroe changed the title feat(runime-utils): add spy option to mount + render helpers feat(runtime-utils): add spy option to mount + render helpers Aug 3, 2026
@danielroe
danielroe merged commit 13472d6 into nuxt:main Aug 3, 2026
10 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 3, 2026
@yamachi4416
yamachi4416 deleted the feat-add-spy-option-to-mount-render-helpers branch August 3, 2026 14:07
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.

Unable to use vitest spy within nuxt 3 component methods.

2 participants