Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As we expand surveyor, it will be key to have testing of our service to be reliable and simple.
To achieve this, we first change our test database from either a local instance of mongodb or nedb to that of in memory mongo db that is created on the fly. This has several benefits.
Secondly, we rewrite the server startup and app creation into an application factory. This allows us to decouple the creation of the app and all its configurations from starting of the server, which is a crucial step in allowing us to unit test.
Finally, we add unit testing with Jest and Supertest. This framework was chosen as it fairly minimal, and can be used with express and two major frontend frameworks (Angular and React), if we ever wish to migrate. An example test case of rendering of CRT survey was added.
More test cases will be added in coming weeks, but this is to add infrastructure to begin.
This is what one looks like, when running

npm run jest