No data on Option API component returned by mountSuspended
Environment
- Operating System: Linux
- Node Version: v18.18.0
- Nuxt Version: 3.9.3
- CLI Version: 3.10.0
- Nitro Version: 2.8.1
- Package Manager: [email protected]
- Builder: -
- User Config: devtools
- Runtime Modules: -
- Build Modules: -
Reproduction
https://stackblitz.com/edit/github-ddvycp
Describe the bug
const wrapper = await mountSuspended(OptionAPIComponent)
wrapper.vm.$data is empty
wrapper.setData({...data}) will result into error:
TypeError: Cannot add property, object is not extensible
Furthermore, I cannot call any method of the component instance:
TypeError: wrapper.vm.myMethod is not a function
Additional context
Component written in composition api doesn't have this issue. @vue/test-utils doesn't have this issue.
Logs
No response
I see the same issue, however, my component is written with the composition API.
I see the same issue, however, my component is written with the composition API.
Did you guys found a solution? i'm having the same issue in nuxt 3 app
I'm having the same issue with mountSuspended, but it works when I use mount from @vue/test-utils.
I can confirm setData leads to the above mentioned error message with mountSuspended. Just wanted to share my workaround:
const wrapper = await mountSuspended(MyComponent, options)
wrapper.setData = data => wrapper.findComponent({ name: 'MountSuspendedComponent' }).setData(data)
But I think this should be fixed in the library, as setData is currently not working.