Different styles of unit testing
We've discovered and used Jasmine in the previous recipes. In this recipe, we will explore and compare different styles of unit testing. This is particularly relevant because Vue templates come with Mocha and Chai preinstalled. Chai enables you to write your tests in three different styles.
Getting ready
This recipe doesn't require any particular previous knowledge, but I highly suggest that you complete the Using Jasmine for testing Vue recipe.
How to do it...
For this recipe to work, you will need two dependencies: Mocha and Chai. You will find them in no time with Google; just remember that Mocha comes in two different files: mocha.js
and mocha.css
. You will have to add them both if you want it to display nicely.
If you are using JSFiddle, continue as usual; otherwise, just make sure to have Vue as well in the dependencies.
Our HTML layout will look like this:
<div id="app"> <p>{{greeting}}</p> </div> <div id="mocha"> </div...