nuxt / test-utils

🧪 Test utilities for Nuxt
http://nuxt.com/docs/getting-started/testing
MIT License
313 stars 81 forks source link

No data on Option API component returned by mountSuspended #735

Open kingyue737 opened 8 months ago

kingyue737 commented 8 months ago

Environment


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

sei-jdshimkoski commented 6 months ago

I see the same issue, however, my component is written with the composition API.

georiv commented 5 months ago

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

Vesely commented 2 months ago

I'm having the same issue with mountSuspended, but it works when I use mount from @vue/test-utils.