{"id":22735475,"url":"https://github.com/francomelandri/intesta","last_synced_at":"2026-04-30T10:39:32.394Z","repository":{"id":24037028,"uuid":"27422133","full_name":"FrancoMelandri/intesta","owner":"FrancoMelandri","description":"Integration test api","archived":false,"fork":false,"pushed_at":"2021-05-11T09:08:35.000Z","size":1745,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-17T22:59:21.496Z","etag":null,"topics":["functional-programming","integration-tests","javascript","node-js"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FrancoMelandri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-02T08:13:10.000Z","updated_at":"2021-05-11T09:08:37.000Z","dependencies_parsed_at":"2022-08-22T02:40:09.604Z","dependency_job_id":null,"html_url":"https://github.com/FrancoMelandri/intesta","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrancoMelandri%2Fintesta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrancoMelandri%2Fintesta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrancoMelandri%2Fintesta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrancoMelandri%2Fintesta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FrancoMelandri","download_url":"https://codeload.github.com/FrancoMelandri/intesta/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246267719,"owners_count":20749999,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["functional-programming","integration-tests","javascript","node-js"],"created_at":"2024-12-10T21:10:47.177Z","updated_at":"2026-04-30T10:39:32.125Z","avatar_url":"https://github.com/FrancoMelandri.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# intesta\n\n------\n\n\n\n**INTE**gration te**ST** **A**pi\n\n[![Build Status](https://travis-ci.org/FrancoMelandri/intesta.svg?branch=master)](https://travis-ci.org/FrancoMelandri/intesta) [![NPM version](https://img.shields.io/npm/v/@francomelandri/intesta.svg?style=flat)](https://www.npmjs.com/package/@francomelandri/intesta) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n### Input parameters\n\n| Parameter        | Description                                 |\n| :--------------- | :------------------------------------------ |\n| **descriptorFile** | file descriptor of the api resources schema |\n| **sessionFile**    | file containing the session of the test     |\n| **onSuccess** | callback function in case of assertions are right |\n| **onFail** | callback function in case of failed assertion |\n| **onFail** | callback function called by intesta in some particular cases. Allows you to add you custom log to the application |\n\n\n\n\n\n---\n\n\n\n### How to\n\n\n\nExample about using **intesta**\n\n\n```javascript\nconst intesta = require('@francomelandri/intesta'),\n    path = require('path')\n\nconst onSuccess = operation =\u003e {\n    console.log(operation.name + ' OK')\n}\n\nconst onFail = (operation, assertion) =\u003e {\n    console.log(operation.name + ' FAIL')\n}\n\nconst onLog = (type, message) =\u003e {\n    console.log(type + ' ' + JSON.stringify(message))\n}\n\nconst descriptorFile = path.join(__dirname, './descriptor.json')\nconst sessionFile = path.join(__dirname, './session.json')\n\nintesta(descriptorFile, sessionFile, onSuccess, onFail, onLog)\n```\n\n\n\nExample of API descriptor file. This file define the schema of the resource API **intesta** is able to know.\n\n```json\n{\n\t\"apis\": [\n        {\n            \"name\": \"keepAlive\",\n            \"path\": \"/keepalive\",\n            \"verb\": \"GET\",\n            \"params\": {\n              \"query\": [\"param1\", \"param2\"]\n            },\n            \"headers\": [\"User-Agent\", \"Accept\"]\n        },\n        {\n            \"name\": \"whoAmI\",\n            \"path\": \"/whoami\",\n            \"verb\": \"GET\",\n            \"params\": {\n              \"query\": [\"name\", \"surname\"]\n            },\n            \"headers\": [\"User-Agent\", \"Accept\", \"X-Auth\"]\n        },\n        {\n            \"name\": \"AreYou\",\n            \"path\": \"/areyou\",\n            \"verb\": \"POST\",\n            \"params\": {\n              \"body\": [\"name\", \"surname\"]\n            },\n            \"headers\": [\"User-Agent\", \"Content-Type\", \"Accept\", \"X-Auth\"]\n        }\n    ]\n}\n```\n\n\n\n| field            | description                                                  |\n| ---------------- | ------------------------------------------------------------ |\n| name             | a unique name of the api resource used by session operation  |\n| path             | the relative path of the resource                            |\n| 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 |\n| params **query** | contain the list of all possible parameter for query string  |\n| params **body**  | contain the list of all possible parameter for body          |\n| headers          | list of headers needed to use the resource                   |\n\n\n\nExample of API session file. \nThis file contains the description of the flow for the test **intesta** should perform\n\n```json\n{ \n   \"settings\":{ \n      \"environment\":\"PROD\",\n      \"urls\":{ \n         \"test\":\"http://q7vv6.mocklab.io\"\n      },\n      \"userAgent\":\"Chrome\"\n   },\n   \"operations\":[ \n      { \n         \"name\":\"keepAlive_1\",\n         \"operation\":\"keepAlive\",\n         \"url\":\"test\",\n         \"params\":{ \n            \"query\":{ \n               \"param1\":\"value1\",\n               \"param2\":\"value2\"\n            }\n         },\n         \"headers\":{ \n            \"User-Agent\":\"{{{settings.userAgent}}}\",\n            \"Accept\":\"application/json\"\n         }\n      },\n      { \n         \"name\":\"WhoAmI_1\",\n         \"operation\":\"whoAmI\",\n         \"url\":\"test\",\n         \"params\":{ \n            \"query\":{ \n               \"name\":\"{{{keepAlive_1.name}}}\",\n               \"surname\":\"Melandri\"\n            }\n         },\n         \"headers\":{ \n            \"User-Agent\":\"{{{settings.userAgent}}}\",\n            \"Accept\":\"application/json\",\n            \"X-Auth\":\"{{{keepAlive_1.Auth}}}\"\n         },\n         \"assertions\":[ \n            { \n               \"field\":\"{{{WhoAmI_1.message}}}\",\n               \"comparison\":\"eq\",\n               \"value\":\"Hello World\"\n            }\n         ]\n      },\n      { \n         \"name\":\"AreYou_1\",\n         \"operation\":\"AreYou\",\n         \"url\":\"test\",\n         \"params\":{ \n            \"body\":{ \n               \"name\":\"{{{keepAlive_1.name}}}\",\n               \"surname\":\"Melandri\"\n            }\n         },\n         \"headers\":{ \n            \"User-Agent\":\"{{{settings.userAgent}}}\",\n            \"Content-Type\":\"application/json\",\n            \"Accept\":\"application/json\",\n            \"X-Auth\":\"{{{keepAlive_1.Auth}}}\"\n         },\n         \"assertions\":[ \n            { \n               \"field\":\"{{{AreYou_1.message}}}\",\n               \"comparison\":\"eq\",\n               \"value\":\"Yes you are\"\n            }\n         ]\n      }\n   ]\n}\n```\n\n\n\n| field      | description                                                  |\n| ---------- | ------------------------------------------------------------ |\n| name       | a unique name for the operation. It can be used by other operation to retrieve field value using the mustache notation |\n| operation  | link to api resource description to validate the operation itself |\n| url        | the url the operation should use to issue the request. The list of url should be defined into the settings object. |\n| params     | list of parameters values for both **query** and **body** as you defined in the descriptor file; you can use mustache notation for dynamic values |\n| headers    | list of headers values; you can use mustache notation for dynamic values |\n| assertions | list of assertions description in order to check if the api resource response is valid or not. |\n|            | field: the response field value to check                     |\n|            | comparison: could be **eq** or **neq**                       |\n|            | value: the expected value                                    |\n\n\n\n### Mustache\n\nYou can refer to operation output in each session field value using the mustache annotation\n\nIn the previous session example you can see \n\n```json\n...\n\t\t\"assertions\":[\n\t\t\t\t{\n\t\t\t\t\t\"field\": \"{{{AreYou_1.message}}}\",\n\t\t\t\t\t\"comparison\": \"eq\",\n\t\t\t\t\t\"value\": \"Yes you are\"\n\t\t\t\t}\n\t\t\t]\n...\n```\n\n\n\nthat means the field is the evaluation of the response field message of the AreYou_1 operation.\n\nIn 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.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancomelandri%2Fintesta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancomelandri%2Fintesta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancomelandri%2Fintesta/lists"}