Joe has been a web developer for the last 13 of his 16+ years as a professional developer. He has specialized in front end and middle tier development . Although his greatest love is writing code, he also enjoys teaching and speaking about code.
Introduction Hello. I'm Joe Eames and welcome to Pluralsight's course, Unit Testing with Node. js. I have long been a proponent of testing and have spent more than a decade teaching testing, unit testing, and test driven development in many different languages and platforms. This is one of my favorite subjects and something I'm extremely passionate about. I'm absolutely convinced that every project can benefit from effective unit testing and I hope that through this course, you will come to learn not only how to unit test in Node, but also why, and I'm grateful that you have chosen to spend this time with me. I'm sure you will find it to be well worth the effort. This course is a how-to guide on unit testing with Node. We will cover all of the basics of unit testing in Node, including the tools and techniques, the whys and wherefores, and the tips and tricks as well. We'll talk about how to unit test all of the typical pieces of Node, how to use unit tests to give you confidence in your code, and we'll also see how to write effective and easily maintained unit tests. We start out with this introductory module, which will cover some basics and theory about unit testing, then we'll talk about the tools that are used when unit testing Node, then we will get into the meat of this course, which is actually writing unit tests for your code that will include business logic, I/O promises, and lots more. This course is meant for Node developers who have anywhere from no experience with unit testing and want to learn from the ground up, to those who have quite a bit of unit testing experience, but want to round out their skillset. If unit testing in Node is an interest of yours, then this course is for you.
Unit Testing Your Code Hello! In this module, we're going to be working on unit testing our code. That means we'll actually be writing tests against existing code. I'm going to use preexisting code that I've already written, but the code that I'm writing is far less important than understanding the lessons about writing unit tests for your code. In this module, we're going to cover the following topics. We'll start off with talking about how to test business logic and how to write good tests and make sure that your business logic itself is testable. Then we'll talk about how to test exceptions. There can certainly be places in your code where you will throw exceptions, and you need to be able to test that logic. Normally when you throw an exception, that fails a test. But with Mocha, we can manage that and are able to test code that throws exceptions. We'll also talk about finding edge cases and using our tests to find problems in our code and then using the tests to guide us into writing fixes for our code. After that, we'll talk about IO and Async operations. IO is typically an asynchronous operation in Node. And there are other asynchronous operations in Node that aren't directly IO related. We'll talk about how to test those with Mocha. After that, we'll talk about mocking our code. Mocking is very important to enable us to isolate the one unit of code that we want to work with. Sometimes this unit is a single class. Sometimes it might be two or three classes. But we need to make sure that we're only testing the code we want to test. And mocks enable that so that we don't test other code that we don't want running in our tests. Then we'll talk about testing promises, which has a few unique capabilities in Mocha. And, finally, we talk about test coverage, which gives us the ability to see what code we have tested and what code we haven't.