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

@francomelandri/intesta

v1.0.7

Published

INTEgration tetST Api

Downloads

12

Readme

intesta


INTEgration teST Api

Build Status NPM version License: MIT

Input parameters

| Parameter | Description | | :--------------- | :------------------------------------------ | | descriptorFile | file descriptor of the api resources schema | | sessionFile | file containing the session of the test | | onSuccess | callback function in case of assertions are right | | onFail | callback function in case of failed assertion |


How to

Example about using intesta

const intesta = require('@francomelandri/intesta'),
    path = require('path')

const onSuccess = operation => {
    console.log (operation.name + ' OK')
}

const onFail = (operation, assertion) => {
    console.log (operation.name + ' FAIL')
}

const descriptorFile = path.join(__dirname, './descriptor.json')
const sessionFile = path.join(__dirname, './session.json')

intesta(descriptorFile, sessionFile, onSuccess, onFail)

Example of API descriptor file. This file define the schema of the resource API intesta is able to know.

{
	"apis": [
        {
            "name": "keepAlive",
            "path": "/keepalive",
            "verb": "GET",
            "params": ["param1", "param2"],
            "headers": ["User-Agent", "Accept"]
        },
        {
            "name": "whoAmI",
            "path": "/whoami",
            "verb": "GET",
            "params": ["name", "surname"],
            "headers": ["User-Agent", "Accept", "X-Auth"]
        },
        {
            "name": "AreYou",
            "path": "/areyou",
            "verb": "POST",
            "params": ["name", "surname"],
            "headers": ["User-Agent", "Content-Type", "Accept", "X-Auth"]
        }
    ]
}

| field | description | | ------- | ------------------------------------------------------------ | | name | a unique name of the api resource used by session operation | | path | the relative path of the resource | | verb | the HTTP verb for the resource; at the moment the allowable verbs are: GET, POST, PUT, DELETE in order to let you bale to test a CRUD api | | params | list of possible parameters for the resource; query string or body | | headers | list of headers needed to use the resource |

Example of API session file. This file contains the description of the flow for the test intesta should perform

{
	"settings":{
		"environment" : "PROD",
		"url": "http://q7vv6.mocklab.io",
		"userAgent": "Chrome"
	},
	"operations" : [
		{
			"name" : "keepAlive_1",
			"operation": "keepAlive",
			"params": {
                "param1": "value1",
                "param2": "value2"
			},
			"headers": {
				"User-Agent": "{{{settings.userAgent}}}",
				"Accept": "application/json"
			}
        },
		{
			"name" : "WhoAmI_1",
			"operation": "whoAmI",
			"params": {
				"name": "{{{keepAlive_1.name}}}",
                "surname": "Melandri"
			},
			"headers": {
                "User-Agent": "{{{settings.userAgent}}}",
				"Accept": "application/json",
				"X-Auth": "{{{keepAlive_1.Auth}}}"
			},
			"assertions":[
				{
					"field": "{{{WhoAmI_1.message}}}",
					"comparison": "eq",
					"value": "Hello World"
				}
			]
        },
		{
			"name" : "AreYou_1",
			"operation": "AreYou",
			"params": {
				"name": "{{{keepAlive_1.name}}}",
                "surname": "Melandri"
			},
			"headers": {
                "User-Agent": "{{{settings.userAgent}}}",
				"Content-Type": "application/json",
				"Accept": "application/json",
				"X-Auth": "{{{keepAlive_1.Auth}}}"
			},
			"assertions":[
				{
					"field": "{{{AreYou_1.message}}}",
					"comparison": "eq",
					"value": "Yes you are"
				}
			]
        }
    ]
}

| field | description | | ---------- | ------------------------------------------------------------ | | name | a unique name for the operation. It can be used by other operation to retrieve field value using the mustache notation | | operation | link to api resource description to validate the operation itself | | params | list of parameters values; you can use mustache notation for dynamic values | | headers | list of headers values; you can use mustache notation for dynamic values | | assertions | list of assertions description in order to check if the api resource response is valid or not. | | | field: the response field value to check | | | comparison: could be eq or neq | | | value: the expected value |

Mustache

You can refer to operation output in each session field value using the mustache annotation

In the previous session example you can see

...
		"assertions":[
				{
					"field": "{{{AreYou_1.message}}}",
					"comparison": "eq",
					"value": "Yes you are"
				}
			]
...

that means the field is the evaluation of the response field message of the AreYou_1 operation.

In this way you can link output values of some operations to input value of another; it is very useful to concatenate a list of operations creating a flow.