Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing Infastructure #93

Merged
merged 3 commits into from
Feb 28, 2022
Merged

Testing Infastructure #93

merged 3 commits into from
Feb 28, 2022

Conversation

sumants-dev
Copy link
Collaborator

@sumants-dev sumants-dev commented Feb 27, 2022

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.

  1. New developers can develop without a installation of mongodb
  2. Unit testing is far more rapid.
  3. CI Pipelines can incorporate DB unit/integration tests

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
image

A factory constructor for the database is used to allow for unit testing.
@sumants-dev sumants-dev self-assigned this Feb 27, 2022
@sumants-dev sumants-dev linked an issue Feb 27, 2022 that may be closed by this pull request
2 tasks
markwhiting
markwhiting previously approved these changes Feb 28, 2022
Copy link
Member

@markwhiting markwhiting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woot this looks great.

@sumants-dev
Copy link
Collaborator Author

Removed mongo-mock package doesn't change any particular thing to review, so overriding with admin privledges.

@sumants-dev sumants-dev merged commit 42beba9 into main Feb 28, 2022
@sumants-dev sumants-dev deleted the testing-infastructure branch February 28, 2022 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set up testing infastructure
2 participants