Full-Stack Web Development with Vue.js and Node

(singke) #1

9


Testing an MEVN Application


Let's do a quick recap of what we have done so far in previous chapters:


We created different Vue components for different pages
We implemented Vuex—centralized state management for Vue.js applications,
and defined state, getters, mutations, and actions for the components
We created controllers and models to interact with the Node.js backend

In this chapter, we will discuss how to write test code to make sure that everything in the


application works well. Writing test code is an integral part of any application. It helps to
ensure that the functionalities that we have written do not break, and maintains the quality


of the code we write.


Different practices can be followed while writing tests. It's always a good practice to write


test code first, before writing the actual code. Writing tests ensures that our application will


not break and everything will work as expected.


This helps us to write better code and also helps to reveal the potential problems before


they arise.


Benefits of writing tests


Writing test code when developing an application has a lot of benefits. Some of them are as


follows:


Ensures code works as expected: It helps to ensure that each piece of
functionality that we have written in our application works exactly as expected.
Improves the quality of code: It improves the quality of code. Since writing
test code helps to pre-empt defects that may arise, before we write actual code, it
improves the quality of the code.
Free download pdf