Why Test
Testing adds peace of mind and gives us proof that our code actually behaves exactly as expected, which can help us sleep well at night.
It's more than peace of mind, however, because it also serves as living documentation of how our code is intended to be used. We can look at the tests to visually see what the expected inputs and outputs are.
That also comes in handy when refactoring because we can change our code and rely on the tests we've written to ensure the change isn't breaking anything unintended.
What to Test
Now, we don't need to test everything under the blue moon; for example, we should trust framework and third-party library authors and shouldn't test their internals. Additionally, we don't need to test trivial bits of code like simple getters and setters.
This Series
Throughout this series, we'll introduce the Japa testing framework, which comes prepackaged with most AdonisJS starter kits. We'll understand how it integrates with AdonisJS, the CLI it provides, its assertion library, plugins, and more.
Before we begin, I want to note we won't be targeting 100% test coverage within this series, meaning every little bit is covered with a test. Instead, we'll be focusing on the things you'll need to know and be familiar with so that you end this series feeling confident taking over and writing tests for a project on your own.
Great, so we'll start in the next lesson by seeing how it's integrated with an AdonisJS project.