Skip to content
Gravity Logo / Docs Gravity home
Browse documentation
Documentation/Gravity Server

Testing

Gravity comes with a full suite of integration tests included to ensure your application functions as it should before releasing it.

Warning

Please set the SUPPORT_EMAIL variable in your environment before running tests as this email is used for testing.

# From server/
gravity test

# or
npm test

The testing suite uses mocha and chai, boilerplate tests are in the /test folder.

How Tests Work

A test calls the API endpoint and passes a data object. The response is then tested to ensure the correct status is returned and the returned data matches a specific format.

The suite’s entry point is test/run.mjs. It registers Chai HTTP and exposes its request helper as global.request. In a test module, use global.request.execute(server) to make requests. See test/account.js for a complete example. Register additional test modules in test/run.mjs before cleanup.

Info

Tests are designed to work with email.user_verification enabled. If you modify the config, some tests may fail and need to be adjusted for your own requirements.