Testing our APIλ︎
We used the
clojure-test option when we created the project, so we will use this built in library.
Writing tests is just the same as other Clojure applications.
Using helper functionsλ︎
It is good practice to create helper functions to extract out common code into its onw function. This saves on duplication, reduces maintenance and should improve the readability of your tests.
Here is an example of a helper function that reads data in the form of JSON and creates a Clojure map for us to work with.
Including test libraries in the namespaceλ︎
Including the testing libraries is standard
A library to help you mock parts of your server-side application. This works just as well for APIs as web applications.