-
Notifications
You must be signed in to change notification settings - Fork 667
Within 'setData' method computed variables are re-calculated, even if are not used in template #377
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
That's not how Vue works. This computed property will be re-evaluated independent of the usage in the render function. This is not a bug in the test-utils, it's how Vue is designed to work. |
@LinusBorg Both tests pass. In second one, when |
Can't take a look right now but reopened for someone else to check |
Edit: Quickly checked this with a fiddle: https://jsfiddle.net/tohdxapr/1/ Seems OP is right, sorry :/ |
No problem. @LinusBorg I turned off cache for computed property in fiddle: https://jsfiddle.net/tohdxapr/2/ With cache it doesn't prove anything :) |
This issue seems to be related with watchers which are launched in vue-test-utils/src/wrappers/vue-wrapper.js Lines 15 to 17 in c095221
I noticed that watcher on computed property is run here, not sure where this watcher is initialized |
Version
1.0.0-beta.10
Reproduction link
https://github.com/lusarz/vue-test-utils/commit/51cf7b5c10cd2010c26a21d7e9f2cca400faacd1
Steps to reproduce
Use
wrapper.setData(...)
methodWhat is expected?
Computed properties that are not truly used in template shouldn't be re-calculated.
By 'truly used' I mean variables that are not filtered out by v-if directive.
What is actually happening?
All computed properties are calculated. In some situations it cause
Cannot read property ${property} of null
kind of errors.The text was updated successfully, but these errors were encountered: