Testing a Component
Explore how to set up Jest configuration and test Vue.js single file components. Understand the challenges of testing nested components and discover shallow rendering to isolate unit tests and prevent side effects from child components.
We'll cover the following...
We'll cover the following...
Jest Configuration
Let’s add the following Jest configuration in the package.json:
moduleFileExtensions will tell Jest which extensions to look for, whereas transform will tell it which preprocessor to use for a file extension.
Lastly, let’s add a test script to the package.json:
Single File Component
We will start our example by using single file components.
Step 1:
Let’s first create a MessageList.vue component under src/components:
Step 2:
Now update ...