Unit tests for Vue application

First, let's check on some particularities of unit testing our Vue application and its components. In order to be able to write tests for the component instance, first of all, it should be instantiated! Quite logical, right? The thing is, how do we instantiate the Vue component so that its methods become accessible and easily testable? To test basic assertions of the initial state of the component, you must just import them and assert their properties. If you want to test dynamic properties—things that change once the component is bound to DOM—you must do just the following three things:

  1. Import a component.
  2. Instantiate it by passing it to the Vue function.
  3. Mount it.

Tip

When the instance is bound to the physical DOM, ...

Get Learning Vue.js 2 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.