Skip to content
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

Computed property is not reactive in tests when returning a nestedValue of an object prop #996

Closed
M3psipax opened this issue Oct 11, 2018 · 2 comments

Comments

@M3psipax
Copy link

Version

1.0.0-beta.25

Reproduction link

https://codesandbox.io/s/j7jlr6q08y?previewwindow=tests

Steps to reproduce

Just run the test.

What is expected?

The second test should pass. The computed property should reevaluate.

The vue component receives an object as prop. It has a computed property that returns a nested value from that object prop.
When changing this nested value, the computed property is not reevaluated in the test's wrapper vm. However, this does work in normal vue runtime.

What is actually happening?

The computed property does not reevaluate.

@eddyerburgh
Copy link
Member

There is an ongoing issue with our implementation of synchronous updates that will be resolved when Vue 2.5.18 is released.

For now there are two solutions, to set props you can use setProps:

wrapper.setProps({
  obj: {
    nestedValue: "def"
  }
});
expect(wrapper.vm.cObjNestedValue).toEqual("def");

Or you can use a setTimeout to wait for Vue to perform an update:

wrapper.vm.$props.obj = { nestedValue: "def" };
await new Promise(resolve => setTimeout(resolve));
expect(wrapper.vm.cObjNestedValue).toEqual("def");

@eddyerburgh
Copy link
Member

Closing in favor of #676

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants