npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

justifier

v1.1.3

Published

Justifier is a developer friendly javascript framework to automate REST API endpoints.

Downloads

25

Readme

Justifier

Justifier is a developer friendly javascript framework to automate REST API endpoints.

It pulls together stable, mature existing libraries and builds a simple, light weight wrapper around it to make api automation easier

Features

  • Allows making Http get, post requests
  • Inbuild support for multipart post request
  • Global parameters support
  • Debugging support
  • BDD style test design with before, after hooks support

Getting Started

Getting started guide will help you through setting up of simple justifier project to automate api end pioints

Installation

  1. Writing tests in Justifier require NodeJs environment. If node environment is not already set up then ollow these steps. Open the terminal and just type brew install node . Alternatively you can download package from official NodJs website and install. Check your installation by running below commands
node -v
npm -v

Project Set up

  1. Create a sample folder, lets say api_tests, run command npm init inside the folder. This will ask you bunch of questions either you can just keep entering or give proper names. After that it will create a package.json file for you

  2. Run below commands

npm install --save justifier

npm install --save mocha

npm install --save chai
  1. Now create a configuration file config.js under root folder and add the below peice of code and then modify the configuration as per your project needs.
module.exports = {
    baseUrl : 'http://xxx.visenze.com',
    queryParams : {'app_key' : 'xxx'},
    debug : 'true',

    // basic authentication
    authentication : {
        type : 'basic',
        username : 'access_key',
        password : 'secure_key'
    }
};
NOTE 
parameters defined in config.js file are appended to every request. Make sure to remove the params if not necessary
    
  1. Create a folder specs which holds the test cases your write
  2. Create a data folder, which holds the test data
  3. Additionally, you can create a validator folder where you can hold common response validator logic
  4. This is how your folder structure should look like now.

├── specs           <- contains tests
├── data            <- holds test data.
├── validator       <- Custom Response validators
├── config.js       <- global config file
├── package.json    <- npm package manager, dependency management

Examples

making get request

var justifier = require('justifier');
var assert = require('chai').assert;
var get = justifier.get;

describe('Justifier GET Request', function () {
   it('Should make a HTTP GET request', function () {
       var params = {
           im_name : 'XXXX'

       };
       return get('/search',params).then(function (response) {
           assert.equal(response.status,'OK','response is ok')
       })
   })
});

making post request

var justifier = require('justifier');
var assert = require('chai').assert;
var post = justifier.post;

it('Should make a HTTP Post request', function () {
        var params = {
            im_url : 'XXXXXX'

        };
        return post('/uploadsearch',params).then(function (response) {
            assert.equal(response.status,'OK','response is not OK');
        })
    });

data driven

var justifier = require('justifier');
var assert = require('chai').assert;
var get = justifier.get;
var given = justifier.given;

describe('Justifier data driven tests', function () {

    given([{im_name:XXX},{im_name:XX}],function (input) {
        it ('Should perform search by image name', function () {
            return get('/search',input).then(function (response) {
                assert.equal(response.status,'OK','response is ok')
            })
        })
    })

});

chained requests


var justifier = require('justifier');
var assert = require('chai').assert;
var get = justifier.get;
var post = justifier.post;

describe('chained request', function () {
    it('should support chained requests', function () {
        var params = {
            im_url: "XXXX"
        };
        return post('/uploadsearch',params).then(function (response) {
            return get('/search',{im_name:response.result[0].im_name});
        }).then(function (response) {
            assert(response.result.length > 0, "empty result");
        })
    })
});