If you are already using ESModules in your node application, natively without babel, then this is how you can setup your jest tests to use ESModules in the same way. The official docs for this can be found here: https://jestjs.io/docs/ecmascript-modules Note: For this to work you will need to be […]
Daily Archives: April 1, 2021
In a previous article, we tested an express api that created a user. We only tested the http interface though, we never actually got to testing the database because we didn’t know about dependency injection yet. Now that we know how to inject the database, we can learn about mocking. […]
There are a few benefits to using dependency injection, but the best, most useful benefit and biggest reason to use dependency injection is to make your code more testable. In this article we’re going to take a look at what dependency injection is by using an example of an express […]
In this article, we’re going to look at how to use TDD to test an express API using the supertest and jest frameworks. Jest is a javascript test runner for running automated tests, and supertest provides a high-level abstraction for testing HTTP. The app that we will be testing will […]