Skip to content

Handling promise resolution #83

Closed
Closed
@skray

Description

@skray

Sorry if this should go in the forums or chat, but I was a little confused about this section in the docs: https://vue-test-utils.vuejs.org/en/guides/getting-started.html#what-about-nexttick

It states

To simplify usage, vue-test-utils applies all updates synchronously so you don't need to use Vue.nextTick in your tests.

This is true if you are only doing DOM manipulation, but as soon as you are waiting for Promise resolution, I do not believe the statement holds.

I have what I think is a pretty common pattern in a component that I am trying to test, where it loads data from an API when it is created, and presents it in a list. Simply calling wrapper.update(), as far as I can tell, only re-renders the DOM, but does not push forward the event loop like Vue.$nextTick() does.

Explicitly calling wrapper.vm.$nextTick() does still push the event loop forward, and I get my data rendered in the DOM.

Is that the expected way to handle things in vue-test-utils? If so, I think it might be helpful to amend the What about nextTick section to clarify that nextTick is still needed for things like resolving asynchronous data retrieval.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions