-
Notifications
You must be signed in to change notification settings - Fork 2
Testing
Due to its dynamically typed nature and sensitive subject matter, CryptX focuses on Test-Driven Development (TDD), ensuring that its suite of tests passes before a new build is uploaded to the server.
The main test runner library in CryptX is mocha with the expected object states being conveniently described by chai.
Because we perform black box testing on the controllers and their method output, chai-http is also added and used extensively within the test suite.
Apart from requiring things like mocha
and chai
themselves, if the test is integration-focused (controller or database interaction), app variables and configuration must be require
'd, (the current suite has this). If writing a test against the database, resolve the app.dbPromise
exported promise before starting DB operations, otherwise race conditions are likely to occur, which sometimes means correct tests don't pass. This promise begins initiating an SQL driver connection to our database and performs the required migrations once a connection has been established. Because the app cannot work without a functioning database link, if the connection fails, this exists the server process with the error code 2
.