Create a NodeJS API with Koa and TypeScript - #11 - Bringing It All Together - Part 1

8K views Feb 14, 2023

Back inside src/routes/codereviewvideos.ts, we can now start using a function that implements the IStorage interface. We have one such implementation - redisStorage. How's this going to fit into our testing setup? In the previous video we said we aren't going to explicitly test the redisStorage functions. Does that mean we are going to test the redisStorage, but "indirectly" through the /codereviewvideos endpoint? Alas, no. We are going to mock our storage implementation for the purposes of testing. Again, it's not true test driven development when you first write code and then write some tests. That's code driven development with tests :) But when starting out with stuff like mocking in Jest, it can be really tricky to figure out how the heck all of this works when you have nothing working... seems like catch-22. So, for me, pragmatism wins the day.

#Internet Software
#Scripting Languages