Full-Stack Web Development with Vue.js and Node

(singke) #1
Testing an MEVN Application Chapter 9

Identifies bugs beforehand: It helps to identify bugs in the early stages. Since
test code is written for every functionality, bugs and issues can be identified
early.
Serves as documentation for new developers: Test code is like documentation. If
we need new developers to start work on the same application, test code helps
them to understand how the application works instead of going through all the
application code.
Application development is faster with test code: If we write code without the
test code, we will code faster. However, if we skip the process, we will later
spending most of our time later fixing the bugs that will start to crawl in, which
could have been identified earlier with the test code.
Application doesn't need to be run: Writing test code and running it doesn't
require the application to be up and running. It also doesn't require the
application to be built either. This reduces the development time significantly.

So, in this chapter, we will discuss the following topics:


Learn why and how to write unit tests and end-to-end tests
Learn about the technologies for writing test code for a Vue.js and Node.js
application
Modify our application's structure to implement unit and end-to-end code
Write test code for Vue components

Introduction to unit tests


Unit testing is a software development process in which the smallest functionality of the


application is tested and examined to check whether it works as expected or not. A unit is
the smallest part of any application. Every test code written for a unit of an application is


independent of each other. The goal of unit testing itself is to perform an individual tests
and make sure that each piece is correct.

Free download pdf