nuxt / test-utils

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

No data on Option API component returned by mountSuspended #735

Open kingyue737 opened 10 months ago

kingyue737 commented 10 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 9 months ago

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

georiv commented 7 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 4 months ago

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