Chapter 6. Unit Testing OpenWhisk Applications
For most newcomers, one of the biggest challenges when it comes to developing in a serverless environment is learning how to test and debug. Since you deploy your code continuously in the cloud, it’s usually not possible to debug your code step by step. While a debugger can in some cases be useful, most developers split their applications into small pieces and test locally before sending the code to the cloud.
Once the application is tested in small pieces, it can be assembled and deployed as a whole. Then tests can be run against the final result, generally simulating user interaction, to ensure the pieces are working together correctly.
Note
Testing in small parts is called unit testing, while simulating the interaction with the assembled application is called integration testing. In this chapter, we focus on how to do unit testing in OpenWhisk applications.
Luckily, there are plenty of unit testing tools available. You can use them to run small pieces of code on your local machine, then deploy only when the application is tested. Let’s see how this works in practice.
In this chapter, we cover unit testing for the Node.js runtime. Unit testing for Python is covered in “Testing Python Actions”, and unit testing for Go is covered in “Testing Go Actions”.
Tip
The source code for this chapter’s examples is available in the GitHub repository.
Using the Jest Test Runner
OpenWhisk applications generally run in the cloud. You write your ...
Get Learning Apache OpenWhisk now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.