Properties

In this lesson, we will be testing Component Properties.

Properties are custom attributes passed from parent to child components.

Custom events solve just the opposite; they send data out to the direct parent via an event.

Combined, they are the wires of interaction and communication in Vue.js components.

There are different ways to test properties, events and custom events.

In Unit Testing, testing ins and outs (properties and custom events) means testing how a component behaves when it receives and sends data in isolation.

Testing Component Properties

When we are testing component properties, we can test how the components behave when we pass them certain properties. But before proceeding, there is an important note:

To pass properties to components, use propsData, and not props. The latter is used to define properties, not to pass the data.

First, create a Message.test.js file and add the following code:

Get hands-on with 1200+ tech skills courses.