Writing an integration test
Our first unit test, which we created in the previous section, relied on a mocked instance of the repository to guarantee that our controller was working. That test adds great value when it comes to detecting bugs in MuseumController
, but it isn't worth much in terms of understanding if the controller works well with the repository.
That's the purpose of integration tests: they test how multiple components integrate with each other.
In this section, we'll write the integration test that tests MuseumController
and MuseumRepository
. These are the tests that will closely mimic what happens when the application runs and will help us later in terms of detecting any problems between these two classes.
Let's get started:
- Create the file for this module's integration tests inside
src/museums
, calledmuseums.test.ts
, and add the first test case there.It should test whether it is possible to get all the museums, this time...