Chakram is a REST API testing framework
offering a BDD testing style and fully exploiting promises

Simple API Testing

Chakram allows you to write clear and comprehensive tests,
ensuring JSON REST endpoints work correctly as you develop and in the future

HTTP Assertions

Chakram extends Chai.js, adding HTTP specific assertions. It allows simple verification of returned status codes, the compression used, cookies, headers, returned JSON objects and the schema of the JSON response (using the JSON schema specification).
describe("HTTP assertions", function () {
  it("should make HTTP assertions easy", function () {
    var response = chakram.get("");
    expect(response).to.have.header("content-type", "application/json");
      args: { test: "chakram" }
    return chakram.wait();


API testing is naturally asynchronous, which can make tests complex and unwieldy. Chakram fully exploits javascript promises, resulting in clear asynchronous tests.
describe("Promises", function () {
  it("should support asserting Biggie's best track", function () {
    var artist = "Notorious B.I.G.";
    return chakram.get(""+artist+"&type=artist")
    .then(function (searchResponse) {
      var bigID = searchResponse.body.artists.items[0].id;
      return chakram.get(""+bigID+"/top-tracks?country=GB");
    .then(function (topTrackResponse) {
      var topTrack = topTrackResponse.body.tracks[0];
      expect("Old Thing Back");

BDD + Hooks

Using BDD formatting and hooks, complex tests can be constructed with the necessary setup and tear down operations, all described in natural language for improved clarity and maintenance.
describe("BDD + Hooks", function () {
  var thingName;
  before("post dweet", function () {
    thingName = "chakramtest" + Math.floor(Math.random()*2000);
    return""+thingName, {
      testing: "your API"
  it("should support getting latest dweet", function () {
    var postedData = chakram.get(""+thingName);
    return expect(postedData).to.have.json('with[0].content', {
      testing: "your API"
  after("update dweet with result", function () {
    return""+thingName, {
      testing: "passed"


Chakram allows new assertions to be added to the framework. This is ideal for adding edge case HTTP assertions or project specific assertions. The end result is less duplication and clearer tests.
describe("Extensibility", function () {
  before("define teapot", function () {
    chakram.addProperty("teapot", function (respObj) {
      var statusCode = respObj.response.statusCode;
      this.assert(statusCode === 418,
        'expected status code ' + statusCode + ' to equal 418',
        'expected ' + statusCode + ' to not be equal to 418');

  it("should be able to detect teapots", function () {
    var notATeapot = chakram.get("");
    var aTeapot = chakram.get("");
    return chakram.wait();

Getting Started

Chakram runs on node.js and is distributed via NPM. To begin testing, a node.js application should be created to contain the API tests and Chakram added as a development dependency:
npm install --save-dev chakram
The Mocha test runner is used to run Chakram tests – this can be installed globally or as a development dependency. The following command installs Mocha globally:
npm install -g mocha
To run tests, simply call the Mocha command line tool. By default, this will run the tests located in the 'test' directory. Mocha can export the test results in many different formats, satisfying the majority of continuous integration platforms.

Examples, tests and documentation are available to introduce Chakram's capabilities.