Now that all of our Todo routes are set up and tested, in this final section we're going to be exploring how to create a separate Test database for our application. That means when we run the test suite we're not going to be deleting all of the data inside of our TodoApp
database. We will have a separate database alongside of Test
and TodoApp
, used for the testing DB.
Now, in order to set all that up we need a way to differentiate between running our app locally and running our test suite locally, and that's exactly where we're going to start. This whole issue stems from the fact that in our mongoose.js
file we either use the MONGODB_URI
environment variable or we use the URL string. This string is used for both testing and for development, and when I say testing I mean when we run our test
script, and when I say development I mean when we run our app locally so we can use it inside of tools like Postman. What we really need is a way to set environment variables locally...