habitica/test/api
Blade Barringer cdcc085530 Adjust test
2015-07-10 23:21:23 -05:00
..
anonymized.coffee Correct test syntax 2015-05-24 22:13:51 -05:00
api-helper.coffee Add expectation that push notification gets called when sending gems 2015-05-11 17:27:58 -05:00
challenges.coffee Adjust NotGonnaGitUs's PR 2015-05-24 21:22:40 -05:00
chat.coffee Adjust test 2015-07-10 23:21:23 -05:00
coupons.coffee Use chai expect instead of expect.js 2015-05-11 08:13:23 -05:00
groups.coffee Wrie and refactor guild tests 2015-06-10 23:39:46 -05:00
inAppPurchases.coffee improve error reporting for iOS IAP 2015-06-15 13:09:22 +02:00
party.coffee Adjust party tests 2015-06-09 22:36:37 -05:00
pushNotifications.coffee Fix push notifications test 2015-06-14 17:00:13 -05:00
README.md Change format of testing commands in readme 2015-05-07 21:52:56 -05:00
score.coffee Move score tests to separate file 2015-06-19 23:51:37 -05:00
status.coffee Use chai expect instead of expect.js 2015-05-11 08:13:23 -05:00
subscriptions.coffee Use chai expect instead of expect.js 2015-05-11 08:13:23 -05:00
todos.coffee Move score tests to separate file 2015-06-19 23:51:37 -05:00

API Tests

Our API tests are written in coffeescript using the Mocha testing framework.

There's a variety of ways to run the tests:

# Individually
mocha test/api/name_of_test.coffee
# The entire collection of api tests
mocha test/api
# As part of the whole test suite
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.