Automated REST API testing with Chakram

Every business nowadays relies on integrations through REST APIs. It can actually be very costly to not realise when your integrations stop working due to an undetected API issue. Might those API be internally developed and maintained or external API totally out of your control (eg: a bespoke company facing knowledge sharing system, a special dashboard your executives require to monitor daily, your cloud ERP, CRM and accounting software etc.).

When building any software project and its integrations, it is essential to know that the various components of the application can safely rely on fully tested and working back-end APIs. This is especially true when the components might change and quickly evolve over time. The solution to this problem is pretty simple: you should make sure your API’s business logic has fully automated regression testing, so that you know what can break, before every new release.

Chakram
Chakram

Recently I came across a pretty nifty open source software called Chakram that can help tremendously with the task of automating your REST API testing. Chakram is written in Nodejs, on Mochajs testing framework, Request HTTP client and Chaijs assertions.

During the implementation of an API based custom extensions of SugarCRM, I indirectly leveraged Chakram to test the project, by using Thorn that is a SugarCRM specific Chakram’s wrapper.

While getting to know Chakram and Thorn, I put together this Docker container with all the necessary dependencies to get started quickly with the testing process, and to allow others to do so as well.

Finally I wanted to share my test scripts (mix of Chakram and Thorn combined depending on the use case) that can be used as a starting point to get up to speed. The tests have been built for the BulkImport upsert Sugar API project I have been working on, to facilitate integrations and initial data loads when the amount of data to transfer into a Sugar system is substantial, but you can easily adapt them to your specific needs and software.

All in all, the experience with Chakram to date has been great and I do encourage you to get started with your APIs testing as well, to help you make your software integrations and your business more reliable going forward.

Leave a Comment