

Discover more from Good Tests for Vue Applications
Writing Good Test for Vue Applications
Over the many years of my career, I have written plenty of bad tests. This book is about all the things I learned on my long journey to writing better tests.
Preface
Over the past few years of my career, I spent countless hours dealing with testing. I wrote a lot of tests and thought a lot about how to write good tests. But unfortunately, I also wrote a lot of bad tests and made many mistakes typical for people new to the art of testing.
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. Over the next couple of chapters, I'll teach you how.
You're reading a live book. Over the next couple of weeks (or months), I'll continuously publish new chapters of the book as soon as they're finished.
Most of the chapters will be issued to paid subscribers only! Every subscriber will get the ebook for free as soon as it is finished.
But if your primary goal is to learn just the basics of how to use vue-test-utils
and Jest to write unit tests for Vue components, this is not the perfect book for you. Whereas if, instead, you want to know the secrets of how to write tests that enable rapid feature development and refactoring with confidence while introducing as few bugs as possible, look no further!
The book on your screen is not mainly about learning to use specific frameworks and libraries. Quite the opposite! There is a separate chapter on decoupling tests from a particular test framework. Instead of going into the details of how to use this or that tool, this book is about principles and best practices that enable us to write highly valuable and maintainable tests. That said, we will also examine the pros and cons of popular frameworks and which to choose. And, spoiler alert, we will settle on Vitest and Playwright as test frameworks. In addition, we will use the Testing Library to decouple tests from implementation details and the Mock Service Worker library to mock API requests.
Although this book primarily aims at Vue developers (we use Vue.js in all examples of components and application code), the basic principles apply to all kinds of web applications, no matter what framework we use or if it's a multi-page application (MPA) or single-page application (SPA). So the knowledge in this book is a solid foundation for your future software developer career, even if your path leads you to a different technology stack.
While I'm confident that the tips and principles in this book will help you avoid the mistakes I've made in the past, there's always room for improvement, and what works for me might not work for you. Additionally, new tools open up new opportunities and challenge established best practices. Over time, new insights can radically change how and what we test. Still, I am certain: after reading this book, you will write better tests and, by extension, better code!
Testing can only prove the presence of bugs, not their absence.
— Edsger W. Dijkstra
Writing Good Test for Vue Applications
How do I access the table of contents?