A better tool for testing APIs
Jetman aspires to be the best tool for testing APIs.
Postman, Runscope or SoapUI are nice tools for testing APIs; however, their tests can only be created from their graphical user interfaces. Writing and maintaining tests on these GUIs is a pain compared to text editors. Moreover, these tests cannot be secured and shared under version control systems or cannot be debugged easily.
With Jetman you can write your API tests in JavaScripts files and solve all these problems. Jetman can also execute your tests or save them as Postman collections.
- Create a node project for testing your API and require Jetman:
jetman = require('jetman');
- Write your test modules in JavaScript files.
- Call
jetman.execute(tests)
with your test modules.
Here is a simple application for running one Jetman test:
jetman = require('jetman');
var test = require('./test.js');
jetman.execute([test]);
Jetman tests are JavaScript files on your test project. They must expose a run()
function and inside that they should call jetman.send(request, testFunction)
method to use Postman.
In this function request
is a Postman request object and testFunction
is an optional test function.
Below is an example test module:
var request = {
'name': 'Root endpoint works',
'method': 'GET',
'url': 'localhost:9090'
}
function test() {
tests['Status code is 200'] = responseCode.code === 200;
tests['Response time is less than 500ms'] = responseTime < 500;
}
exports.run = function () {
jetman.send(request, test);
}
An example API test project using Jetman is at: github.com/hantuzun/jetman-example.
Jetman can execute tests with options and callback. It can also save your tests as Postman collections.
For full documentation refer to docs.
Clone the repo and install dependencies with npm install
.
It's recommended to use Jetman from another module with tests.
Write to us on our Jetman Gitter Chat Room!
Run npm test
. This command runs unit tests and tests the project for JavaScript Standard Style compatibility.