Create a NodeJS API with Koa and TypeScript - #10 - Optional - Testing Redis Storage

5K views Feb 14, 2023

This video is entirely optional. You may be asking if we should unit test the Redis storage implementation? This is your call. The problem with unit testing this redisStorage function is that it... relies on Redis. This means Redis needs to be available when your tests are run. Whilst that wouldn't be ideal in the long term, it can be useful to write some tests whilst playing around with redis, particularly if you're not familiar with the library. However, I am not going to keep the unit tests that we write in this video. I would instead look to test this functionality as part of integration testing. This would mean standing up the full API, with Redis, and then sending in real API requests. You may disagree with this point of view, and that's absolutely fine. In this video we will cover why writing these tests is such a pain, and how they are not true unit tests anyway. But the process can be an interesting discovery exercise, so I wanted to show it all the same.