Chapter 11. Testing in Vue

To this point, we have learned about developing a complete Vue application from scratch with different Vue APIs. Our application is now ready for deployment, but before we do that, we need to make sure that our application is bug-free and ready for production. This is where testing comes in.

Testing is crucial to any application development, as it helps to increase code confidence and quality before releasing it to production. In this chapter, we will learn about the different types of testing and how to use them in Vue applications. We will also explore the various tools, such as Vitest and Vue Test Utils, for unit testing and PlaywrightJS for end-to-end (E2E) testing.

Introduction to Unit Testing and E2E Testing

Software development has both manual and automated testing practices and techniques to ensure your application works as expected. While manual testing requires a tester to interact with the software manually and can be expensive, automated testing is mainly about executing a predefined test script containing a set of tests in an automated manner. The collection of automated tests can validate simple to more complex application scenarios, from a single function to a combination of different parts.

Automated testing is more reliable and scalable than manual testing, assuming we write the tests correctly, and performs the following testing processes:

Unit testing

The most common and lowest level of testing in software development. We use unit ...

Get Learning Vue now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.