上QQ阅读APP看书,第一时间看更新
Testing GET /todos
With our GET /todos route now in place, it is time to add a test case for it. Now, before we can actually write the test case, we have to deal with a different problem. The first thing we do inside of our server.test file is delete all the Todos, and this happens before every single test. The GET /todos route pretty much lives off the fact that there are Todos it can return. It will handle Node Todos, but for our test case, we want some data in that database.
In order to add this data, what we're going to do is modify beforeEach, adding some seed data. This means that our database is still going to be predictable; it's always going to look exactly the same when it starts, but it will have some items in it.