A Manning book by Lucas da Costa
➡ Available at Manning.com
Testing JavaScript Applications will help you write high-quality software in less time, with more confidence.
In the last five years, I have been deeply involved in the JavaScript testing scene. I am a core-maintainer of both Chai.js and Sinon.js, two of the most popular testing libraries in JavaScript, and I closely follow projects like Jest and Mocha. In this book, I expect to teach you what I've learned during those years in which I've been involved in vetting and implementing features, defining best-practices, and designing the libraries that thousands of people use every day.
Throughout this book's pages, you will learn how to write effective tests through various diagrams and practical examples we'll build together. Because I believe the best way to learn something is by doing it yourself, I've put in this repository all of the book's examples, so that you can experiment with them on your own and compare your solutions to the ones which I've implemented.
Besides covering specific tools, like Jest, and techniques, like TDD, it will teach you how to think about tests from a business perspective. You will learn what to take into account when designing tests, and how to make optimal decisions for your specific context.
I've written Testing JavaScript Applications thinking mostly about Junior Developers. They are the ones who will benefit the most from this book's approach to tests, which covers both the "hows" and the "whys" of writing automated tests.
Even though Junior Developers will be the ones who will benefit the most from this book, it also contains topics which cater to senior and mid-level developers. It includes my thoughts on how tests impact a business, how they structure relationships within teams, and other aspects involved in building what I'd call "a culture of quality".
To get the most out of "Testing JavaScript Applications", you must have a basic understanding of JavaScript. You should know how to use objects, functions, callbacks, and, especially, Promises. Basic knowledge of CSS and HTML is also required for the chapters in which we'll test a front-end application.
Because I've tried to make the examples in this book as close to reality as possible, there will be chapters in which we'll test a Node.js back-end application, and others in which we'll test a React application. Therefore, it will be necessary to have elementary knowledge about these tools. Reading their "getting started" guides should take you approximately 15 minutes each, and will be enough for you to follow along with the testing examples.
If you have any questions, comments, or suggestions, I'd love to hear them. With your invaluable feedback, we'll build a better book together.
I wish you all a productive, pleasant, and exciting journey.
— Lucas da Costa
This repository contains all of the examples in the book Testing JavaScript Applications.
I have organised examples in a separate folder for each chapter and, within a chapter, I've separated them by section. Sometimes, even within sections, you will find sub-divisions with the multiple stages of an exercise or with different approaches to solving the same problem.
I've built these examples using Node.js v12 and NPM v6.
Before executing any of these examples, cd
into the folder you want to try and run npm install
to install its dependencies.
Most of the examples have an NPM script named test
. Which means that you can execute tests for that example by using npm test
.
Together, we can build better content.
If you happen to find any problems in any of these examples, feel free to submit a Pull Request explaining what the problem was and how you solved it.
In case you have a better solution for any of the exercises, I'd love to see it. In that case, explain in your PR why you think that the proposed solution is better. Even though I might not agree, I will treat everyone with the respect they deserve, and will carefully read through their thoughts and comments.
I'd love to hear your thoughts on the book and keep in touch with you.
Send me a tweet @thewizardlucas and let's have a chat!
- lucasfcosta.com - My Personal Website
- @thewizardlucas on Twitter
- @lucasfcosta on GitHub
- Manning Books' Website
For discussing any topics related to this book, you can email me at [email protected].