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

Cannot trigger method updated Vue lifecycle #455

Closed
ghost opened this issue Mar 6, 2018 · 8 comments
Closed

Cannot trigger method updated Vue lifecycle #455

ghost opened this issue Mar 6, 2018 · 8 comments

Comments

@ghost
Copy link

ghost commented Mar 6, 2018

Version

1.0.0-beta.11

Reproduction link

https://github.com/dungla4/vue-test-utils-vuex-router

Steps to reproduce

  • Clone repo then run: npm install or yarn install
  • Run command: npm test or yarn test

What is expected?

Should call updated Vue lifecycle method and print in log

What is actually happening?

Not trigger updated method, just trigger mounted method


Normally, updated is triggered when template is changed. I tried to change data by wrapper.setData, or set data directly via wrapper.vm.msg = .. but no luck. This function works well if you run project by command yarn start and click some link at the bottom of page

@38elements
Copy link
Contributor

@eddyerburgh
In real Vue, When vm._watcher.sync is true, updated hook is not called.
Do you think when vm._watcher.sync is true, updated hook should be called in Vue Test Utils?

@eddyerburgh
Copy link
Member

No, I think the solution is to either make a change to Vue core, or reimplement update. Changing the render watcher to sync has caused bugs that can't be fixed without changes to Vue core, or hacky code.

@38elements
Copy link
Contributor

38elements commented May 18, 2018

Thank you for reply.
I think in order to solve this problem which updated hook is not executed when sync mounting option is true,
it is necessary to let Vue instance to do different behavior from the real Vue instance.

If you are not resolving this issue currently,
I think I try to resolve this issue.

@38elements
Copy link
Contributor

Even if the behavior is different,
I think it is better to call updated hook synchronously when vm._watcher.sync is true.

@eddyerburgh
Copy link
Member

Ok, that would be great if you could investigate. I'd be interested to see a solution. I'm going to investigate changing Vue core to add a sync option this weekend so we can compare solutions 👍

@38elements
Copy link
Contributor

38elements commented May 18, 2018

I am sorry.
Since I have work to do on this Saturday and Sunday,
I may not be able to make deliverable.
I will make deliverable within 8 days.

@eddyerburgh
Copy link
Member

That's fine, this issue might take a while to solve.

Another bug caused by setting the watcher to sync is that a listeners warning is thrown. I described the problem here, and I'm not sure there's a fix apart from setting Vue to silent while the render watcher runs, which would swallow errors.

@38elements 38elements mentioned this issue May 26, 2018
38elements added a commit to 38elements/vue-test-utils that referenced this issue May 31, 2018
38elements added a commit to 38elements/vue-test-utils that referenced this issue Jun 1, 2018
@38elements
Copy link
Contributor

This issue was resolved at #675.

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