Skip to content

Chakram is REST API test framework. This is a docker image that eases setup.

Notifications You must be signed in to change notification settings

shouldbee/docker-chakram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-chakram

Chakram is REST API test framework. This is a docker image that eases setup.

About Chakram

Chakram is an API testing framework designed to perform end to end tests on JSON REST endpoints. The library offers a BDD testing style and fully exploits javascript promises - the resulting tests are simple, clear and expressive. The library is built on node.js, mocha and chai.

From: dareid/chakram

Install

This docker image is available as an automated build on the docker registry hub, so using it is as simple as running:

$ docker run shouldbee/chakram

To further ease running, it's recommended to set up a much shorter function so that you can easily execute it as just chakram:

$ chakram () {
  sudo docker run -it --rm --net host -v `pwd`:/wd -w /wd shouldbee/chakram "$@"
}

This will create a temporary function. In order to make it persist reboots, you can append this exact line to your ~/.bashrc (or similar) like this:

$ declare -f chakram >> ~/.bashrc

Usage

$ mkdir test
$ $EDITOR test/test.js

var chakram = require('chakram'),
    expect = chakram.expect;

describe("HTTP assertions", function () {
  it("should make HTTP assertions easy", function () {
    var response = chakram.get("http://httpbin.org/get?test=chakram");
    expect(response).to.have.status(200);
    expect(response).to.have.header("content-type", "application/json");
    expect(response).not.to.be.encoded.with.gzip;
    expect(response).to.comprise.of.json({
      args: { test: "chakram" }
    });
    return chakram.wait();
  });
});

$ chakram

  HTTP assertions
    ✓ should make HTTP assertions easy (563ms)


  1 passing (570ms)

See official site for more information.

Write tests in CoffeeScript

CoffeeScript has DSL friendly syntax. You probably want to write some tests in CoffeeScript. You can do this as this docker image contains CoffeeScript!

$ mkdir test
$ $EDITOR test/test.coffee

chakram = require('chakram')
expect = chakram.expect
describe 'HTTP assertions', ->
  it 'should make HTTP assertions easy', ->
    response = chakram.get('http://httpbin.org/get?test=chakram')
    expect(response).to.have.status 200
    expect(response).to.have.header 'content-type', 'application/json'
    expect(response).not.to.be.encoded.with.gzip
    expect(response).to.comprise.of.json args: test: 'chakram'
    chakram.wait()

$ chakram

  HTTP assertions
    ✓ should make HTTP assertions easy (563ms)


  1 passing (570ms)

About

Chakram is REST API test framework. This is a docker image that eases setup.

Resources

Stars

Watchers

Forks

Packages

No packages published