Book Image

Learning Node.js for .NET Developers

Book Image

Learning Node.js for .NET Developers

Overview of this book

Node.js is an open source, cross-platform runtime environment that allows you to use JavaScript to develop server-side web applications. This short guide will help you develop applications using JavaScript and Node.js, leverage your existing programming skills from .NET or Java, and make the most of these other platforms through understanding the Node.js programming model. You will learn how to build web applications and APIs in Node, discover packages in the Node.js ecosystem, test and deploy your Node.js code, and more. Finally, you will discover how to integrate Node.js and .NET code.
Table of Contents (21 chapters)
Learning Node.js for .NET Developers
About the Author
About the Reviewer

Chapter 6. Testing Node.js Applications

So far, we have only been testing our code by exercising it manually. This isn't a very sustainable approach as our application becomes larger. Ideally, we should regularly exercise all the functionality of our application to check for regressions. This would quickly become prohibitively time-consuming if we continued to use only manual testing. It is much more effective to maintain a suite of automated tests. These also bring many other benefits, for example, acting as documentation of our code for other developers.

In this chapter, we will cover the following topics:

  • Writing automated unit tests for our application

  • Introducing new libraries to help us write more descriptive tests

  • Seeing how to create and use test doubles in JavaScript

  • Exercising our application's web interface using HTTP client tests

  • Adding full-stack integration tests using browser automation

  • Establishing a structure for writing further tests as we expand our codebase