Giter Site home page Giter Site logo

hantuzun / jetman Goto Github PK

View Code? Open in Web Editor NEW
26.0 7.0 1.0 73 KB

A better tool for testing APIs

Home Page: https://npmjs.com/package/jetman

License: MIT License

JavaScript 100.00%
postman postman-collection jetman-test api-testing api-test npm javascript-library rest-api

jetman's Introduction

Jetman

A better tool for testing APIs

NPM Version Build Status Dependencies JavaScript Standard Style Gitter License


Why?

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.

How to Use Jetman?

  • 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:

index.js
jetman = require('jetman');
var test = require('./test.js');

jetman.execute([test]);

How to Write Jetman Tests?

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:

test.js
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);
}

Example Project

An example API test project using Jetman is at: github.com/hantuzun/jetman-example.

Documentation

Jetman can execute tests with options and callback. It can also save your tests as Postman collections.

For full documentation refer to docs.

Development

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!

Testing

Run npm test. This command runs unit tests and tests the project for JavaScript Standard Style compatibility.

License

MIT

forthebadge

Analytics

jetman's People

Contributors

erolstt avatar hantuzun avatar marcbachmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

tnypxl

jetman's Issues

Expand functions inside testFunctions

testFunction bodies are sent directly to Postman for execution. However Postman doesn't support using custom functions or libraries out of these testFunction bodies scopes.

We may expand these functions in testFunctions. This concept is coming from lisp macros.

For example the test below should print 3 when given to jetman.execute method:

function helperA(){
    x = 1;
}

function helperB(){
    helperA();
    y = 2;
}

function testFunction(){
    helperB();
    z = x + y;
    console.log(z);
}

request =  {
    'name': 'Root endpoint works'
    'url': 'localhost:9090'
}

exports.run = function() {
    jetman.send(request, testFunction);
}

This could be achieved if the called functions in testFunction are expanded recursively beforehand. Then we can pass the following body to Postman after expansion:

    {
        {
            x = 1;
        }
        y = 2;
    }
    z = x + y;
    console.log(z);

This feature could be applied to external JS libraries too. Interest for such a feature is already expressed here: postmanlabs/newman#153

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.