Wrapping up

Congratulations on finishing the Mirage tutorial!

As an exercise, there are two more API endpoints left to implement to restore the full functionality of the Reminders app:

  • POST to /api/lists. This endpoint should create a List using the request attrs. It should look very similar to the Reminder POST route.
  • DELETE to /api/lists/:id. This should look similar to the Reminder's delete endpoint, but you can use the Lists's Reminders relationship to destroy the associated Reminders, so no orphan records are left behind.

Once you implement the rest of the API, you can also practice writing more tests to improve the coverage of this suite. Testing is all about making sure you're confident in your code, so much so that you'd be willing to automatically deploy it after doing something like upgrading a dependency.

Here are some things our app can do that we didn't write tests for yet:

  • The All screen shows all Reminders, along with tags showing which List they belong to
  • A List only shows Reminders that belong to that List
  • The user can delete a Reminder
  • The user can create a List
  • The user can delete a List

Writing the rest of these tests will help you get comfortable with important testing practices like keeping your test data minimal and focused, making sure you only assert against things that have changed in your test, and making sure your tests aren't brittle and break due to unrelated changes.

If you'd like to see the solution for both the final server and final test, check out lib/server-final.js and lib/app-test-final.js.

Further reading

If you want to keep learning, you should now have enough context to understand all the content in the Main concepts section of the docs.

Getting help

If you get stuck or have any questions, join us in the Mirage JS Discord or ask a question on Stack Overflow with the "miragejs" tag.

Happy mocking!