Skip to content

Conversation

ytoshiki
Copy link
Contributor

@ytoshiki ytoshiki commented Sep 6, 2025

πŸ”— Linked issue

resolves #1404

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Currently, vm in mountSuspended() does not automatically unwrap refs, which is inconsistent with vue/test-utils:

// Current behavior (inconsistent)
const component = await mountSuspended(SomeComponent)
console.log(component.vm.someRef) // Returns ref object, not the value
console.log(component.vm.someRef.value) // Need to manually access .value

// Expected behavior (vue/test-utils)
const wrapper = mount(SomeComponent)
console.log(wrapper.vm.someRef) // Returns unwrapped value

Expected Behavior

wrapper.vm should automatically unwrap refs to match vue/test-utils:

const component = await mountSuspended(SomeComponent)
expect(component.vm.someRef).toBe('thing') // Should work directly
component.vm.someRef = 'new thing' // Should update ref.value
expect(component.vm.someRef).toBe('new thing') // Should reflect changes

@ytoshiki ytoshiki requested a review from danielroe as a code owner September 6, 2025 19:30
Copy link

pkg-pr-new bot commented Sep 6, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/test-utils@1405

commit: 5f8e95d

Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

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

thank you ❀️

@danielroe danielroe merged commit 749b484 into nuxt:main Sep 6, 2025
6 checks passed
@github-actions github-actions bot mentioned this pull request Sep 6, 2025
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.

vm should automatically unwrap refs to match vue/test-utils behavior
2 participants