Added support for functional testing against a live database, cleaned up existing tests, and added some additional user controller tests to serve as examples for testing the API.
I decided not to make any differentiation in file names for unit tests and integration/functional tests, since I don't think there's any particular use for us to break them up (we'll always want to run them all together as far as I can tell). We can always break them up later if we decide we'd like to run them separately.
This iteration of the server tests requires PostgreSQL to be running. In the future I think we'll also want to test against a live instance of Elasticsearch, but I put it off for now until we start diving into writing more comprehensive API tests. It should be pretty easy though to create a test index and use that for functional tests.
Note: I temporarily disabled client tests in the gulp 'test' task, so that npm test will work properly. I was getting a missing package error when trying to run gulp test:client, so it seems like it will require some extra effort to get client tests working.
GitHub Issues
358
Changes
Removed outdated e2e tests.
Added test-request module to simplify API testing.
Added test-util module with helpers for common tasks.
Added shell scripts to create and drop test database (named statengine_test). These are run automatically at the start and end of the server tests.
Updated logger to prevent noisy output during tests. To add logs in tests you should use Log.test(). Other than that, only warning and error logs will show up during tests.
Updated mocha.
Added tough-cookie and axios-cookiejar-support libraries to allow axios sessions in tests.
Cleaned up and fixed existing tests, and added a few new ones to use as examples.
Updated readme with server testing instructions.
Temporarily removed 'test:client' task from 'test' gulp task.
Steps to Test
Make sure you have PostgreSQL running.
Run gulp test:server (or gulp test:server:coverage).
Overview
Added support for functional testing against a live database, cleaned up existing tests, and added some additional user controller tests to serve as examples for testing the API.
I decided not to make any differentiation in file names for unit tests and integration/functional tests, since I don't think there's any particular use for us to break them up (we'll always want to run them all together as far as I can tell). We can always break them up later if we decide we'd like to run them separately.
This iteration of the server tests requires PostgreSQL to be running. In the future I think we'll also want to test against a live instance of Elasticsearch, but I put it off for now until we start diving into writing more comprehensive API tests. It should be pretty easy though to create a test index and use that for functional tests.
Note: I temporarily disabled client tests in the gulp 'test' task, so that
npm test
will work properly. I was getting a missing package error when trying to rungulp test:client
, so it seems like it will require some extra effort to get client tests working.GitHub Issues
358
Changes
test-request
module to simplify API testing.test-util
module with helpers for common tasks.statengine_test
). These are run automatically at the start and end of the server tests.Log.test()
. Other than that, only warning and error logs will show up during tests.mocha
.tough-cookie
andaxios-cookiejar-support
libraries to allow axios sessions in tests.Steps to Test
gulp test:server
(orgulp test:server:coverage
).