Writing Good Tests
for Vue Applications

This book is for Vue developers who want to up their testing game and write good tests for Vue applications. Maybe, like me, you already wrote your fair share of bad tests and wonder how to reach the promised land of fast feedback loops, rapid release cycles, and refactoring with confidence testing advocates keep talking about. In this book, we'll explore how!

Writing Good Tests for Vue Applications Book Cover

What Readers Say

  • As a Vue developer with 6 years of experience in testing, I find this book to be the most comprehensive testing strategy I've encountered. It covers all test types, modernizes the traditional testing pyramid, and provides an excellent guide to TDD. The book is filled with practical tips and is an essential read for Vue developers looking to improve their testing practices.
    Alex Opalic
    Full Stack Developer
  • Writing Good Tests for Vue Applications is a fantastic book and helped me and my co-workers establishing a nice test suite. I can really recommend reading it as it really shows you spot on how you should test your app.
    Tino
    Developer

What's in the Book

If your primary goal is to learn just the basics of using tools like vue-test-utils and Jest to write Unit Tests for Vue components, this is not the perfect book for you. Yet, if you want to learn how to build better applications faster, look no further!

Breakdown of Testing Approaches

We will explore different testing approaches, from manual testing to automated End-to-End (E2E) System, Application, Component, and Unit Tests. Each technique has unique advantages and limitations, and understanding their nuances will enable us to select the most suitable methods for our specific project requirements.

Planning Our Testing Strategy

After analyzing the various testing approaches, it's crucial to emphasize that different tests come with varying costs. Therefore, we must adapt and balance expensive (manual and E2E System Tests) and more affordable tests (Application, Component, and Unit Tests) to optimize our testing strategy.

The Three Principles for Writing Good Tests

The more flexible our code is, the easier and quicker we can react to new requirements. So, especially in projects we maintain and grow over many years (sometimes even decades), it is essential to improve the code and adapt it to new realities continuously. To do this, we need to write tests that adhere to The Three Principles for Writing Good Tests.

Setting Up the Perfect Test Environment

At this point, we have the necessary theoretical knowledge to start writing good tests. Now, it's time for practice! However, before we can start writing tests, we need to sharpen our tools. So this chapter is about how to put together our perfect test setup.

Designing Effective Application Tests (integration testing)

We'll discuss the fundamentals of Application Testing (aka integration testing), for example, why it is important to test every new feature and where we draw the line between what qualifies to be part of our application and what is not. We'll then delve into Domain-specific Languages (DSL), exploring how a custom DSL can make our tests more resilient and readable. By the end of this chapter, you'll have a solid understanding of how to design effective Application Tests that are robust, efficient, and aligned with the requirements of your business domain.

Mastering Component Testing

In this chapter, we will explore Component Testing in depth. We'll take a closer look at the role of TypeScript in ensuring the correctness of our application, how we can craft high-quality Component Tests, and when it is even appropriate to write Component Tests in addition to Application Tests. These insights will help you leverage the power of Component Tests to create a more robust and maintainable application, ensuring that your components work as intended and interact seamlessly.

Unit Testing Fundamentals

Unit tests are the perfect place for testing edge cases and multiple variations as well as complicated operations. For example, suppose we have a function for formatting prices. We might test what happens if we need to round the price to the next cent. Or that we add commas and decimal points correctly. We don't want to test all possible formatting variations in dedicated acceptance tests, but we can easily do this in a unit test.

Testing in the Agile World

Many teams I talk to see automated testing as an additional step applied at the end of the process. As a result, those teams do not benefit from the numerous advantages of automated testing. On the contrary, seeing testing as a separate step, detached from the rest of the software development workflow, leads to a workflow where testing slows us down, diminishing any benefits automated testing might offer.

Deep Dive into Test-Driven Development (TDD)

By embracing TDD, we become part of an elite group of developers prioritizing a software project's code quality, maintainability, and long-term success. TDD empowers us to create robust applications that stand the test of time. This chapter will walk you through writing code using the Test-Driven Development (TDD) approach.


Buy the Ebook

Level up your Vue testing skills and build better applications faster!