habitica/test/api
2015-05-07 21:50:22 -05:00
..
api-helper.coffee Add readme. Adjust api-helper.coffee 2015-05-07 21:33:59 -05:00
challenges.coffee Adjust namespace of api tests 2015-05-07 21:22:30 -05:00
groups.coffee Adjust namespace of api tests 2015-05-07 21:22:30 -05:00
README.md Clarify matter in readme 2015-05-07 21:50:22 -05:00
status.coffee Adjust namespace of api tests 2015-05-07 21:22:30 -05:00
subscriptions.coffee Adjust namespace of api tests 2015-05-07 21:22:30 -05:00
todos.coffee Adjust namespace of api tests 2015-05-07 21:22:30 -05:00

API Tests

Our API tests are written in coffeescript using the Mocha testing framework. You can run a file individually by running mocha test/api/name_of_test.coffee, all the api tests by running mocha test/api, or run them as part of the whole test suite with npm test.

Modules

Some modules are declared in the api-helper.coffee file for use in any of the api tests:

  • moment - time manipulation
  • async - run async processes, good for before blocks
  • lodash (_) - many utilities
  • shared - generate uuids
  • expect - making assertions
  • User - look up a User in the db

Helper Methods

There are helper methods declared in the api-helper.coffee file. Some useful methods contained there:

  • registerNewUser(callback, main) - Theres a global user variable that gets overwritten with the new user whenever you call registerNewUser unless you pass false in as the second argument.
  • registerManyUsers(number, callback) - Good for testing things that require many users. The callback function returns new users as and array in the second argument.