-
Notifications
You must be signed in to change notification settings - Fork 264
setData function with class components returns TypeError #572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A quick dive into this learn that with class components the Just doing this in the code works instead of using (wrapper.vm as any).hovered = true;
await (wrapper.vm as any).$nextTick(); It's not very nice and clean but for class components it seems that everything is just placed on the What you could do is check in |
Thanks for the issue report. There are a number of known problems with class component. Another one is mocks not working correctly, see here. The main problem is If we can get class component to work correctly using
Should Could we just have a check in if (this.isClassComp) {
this.vm[key] = value
await this.vm.$nextTick()
} else {
// usual stuff
} |
More or less dup: #1058 Going to merge all class component issues. |
Uh oh!
There was an error while loading. Please reload this page.
Hi there,
I got vue-jest to work so I continued to see if I could get unit tests working in my codebase. I stumbled upon the next issue, I saw this was also reported when using the Composition api but I get the same error with class components:
I'm doing this inside a test:
await wrapper.setData({ hovered: true });
Which results in this error:
TypeError: Cannot add property hovered, object is not extensible
Component looks like (simplified):
So
hovered
is equivalent to what in the Options API would be data. So I would expect this to work.Reproduce
You can reproduce this in the
vue-test-utils
codebase by adding these two lines:at the end of the
works with shallow mount and SFC
test inclassComponent.spec.ts
.The text was updated successfully, but these errors were encountered: