How it works...

The official documentation states the following: 

Vue performs DOM updates asynchronously. Whenever a data change is observed, it will open a queue and buffer all the data changes that happen in the same event loop.

For this reason, many tests require the $nextTick helper. There is, however, an ongoing effort to create better tools to deal with testing and synchronicity so, while this recipe illustrates the problem, it might not be the most up-to-date method to deal with the test.

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.