Chakram
is an API testing framework that is designed to perform end to end testing of JSON REST endpoints.
The library offers a BDD testing style and fully exploits javascript promises – the resulting tests are simple, clear and expressive. Chakram is built on node.js, mocha and chai.
Features
Chakram
offers a depth of features. Some of them are :
- HTTP specific assertions. Allows testing of:
- Status codes
- Cookie presence and value
- Header presence and value
- JSON values
- JSON structure (using the JSON schema specification)
- Compression
- Response times
- BDD formatting and hooks (e.g. beforeEach, afterEach)
- Promise based
- Plugin support
- Custom assertions
- Exports results in a variety of formats
- Debugging support
Installation
Chakram
comes as an npm
module so it is very easy to install. However, since it requires both node.js
and npm
, please make sure to have both of these installed before installing Chakram
.
Once you have both these dependencies, it is easy to install Chakram
as
npm install chakram --save-dev
This will install Chakram
in your project and if you have a package.json
file in your project, it will automatically be added to the dependencies.
In the next section, we’ll see how we can make simple GET
or POST
requests using Chakram
.