Skip to content

refactor: remove update and make watchers sync #474

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

Merged
merged 5 commits into from
Mar 17, 2018

Conversation

eddyerburgh
Copy link
Member

@eddyerburgh eddyerburgh commented Mar 16, 2018

  • Remove update
  • Set all watchers to sync when instance is created by default
  • Add optional sync option, which stops watchers being set to sync when false

closes #283

function setDepsSync (dep) {
dep.subs.forEach((watcher) => {
watcher.sync = true
if (watcher.sync === true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? How does it work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, this should be moved. We need a return statement so the code doesn't get stuck on circular deps, but this isn't the best place for it!

@38elements
Copy link
Contributor

I think it is necessary to remove the link for update() on the below pages.

https://github.com/vuejs/vue-test-utils/blob/dev/docs/en/README.md
https://github.com/vuejs/vue-test-utils/blob/dev/docs/en/SUMMARY.md
https://github.com/vuejs/vue-test-utils/blob/dev/docs/en/api/README.md

@eddyerburgh eddyerburgh merged commit 1da0c6e into vuejs:dev Mar 17, 2018
@eddyerburgh eddyerburgh deleted the run-watchers-synchronously branch March 17, 2018 20:48
eddyerburgh pushed a commit that referenced this pull request Mar 30, 2018
@radudalbea
Copy link

Hello,

I don't understand what you mean by: remove update and make watchers sync

I have a set of tests that use the setMethods function and now they don't work. I keep getting this error message: update has been removed from vue-test-utils. All updates are now synchronous by default

Could you update the documentation please?

For example a test like this doesn't work right now:

const wrapper = mount(Foo);
const clickMethodStub = jest.fn();
wrapper.setMethods({ clickMethod: clickMethodStub })
wrapper.find('button').trigger('click')
expect(clickMethodStub).toHaveBeenCalledTimes(1);

Thanks.

@eddyerburgh
Copy link
Member Author

eddyerburgh commented Apr 4, 2018

Hi @radudalbea. The Vue reactivity system is asynchrnous by default, this update changes all watchers (which are part of the reactivity system) to run synchrnously.

Can you create an issue with a reproduction of the issue you're having?

@radudalbea
Copy link

radudalbea commented Apr 4, 2018 via email

@eddyerburgh
Copy link
Member Author

Please create an issue. The issue tracker helps me keep track of problems that need to be fixed. I won't be able to investigate this for a few days and I might forget that you posted here.

maoberlehner pushed a commit to maoberlehner/vuex-map-fields that referenced this pull request Apr 24, 2018
- Change Babel config file to being a JavaScript file instead of JSON.
  See: babel/babel#7784
- Remove vue-test-utils `update()` calls because they are not necessary
  anymore. See: vuejs/vue-test-utils#474
@Yawenina
Copy link
Contributor

Yawenina commented Jun 7, 2018

I can reproduce it at https://codesandbox.io/s/xpm8ml4lrp

and I found it had been solved at pr#622

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

Successfully merging this pull request may close these issues.

Should update run all watchers?
5 participants