{"id":16752423,"url":"https://github.com/whizsid/jsonapiunit","last_synced_at":"2026-05-17T12:08:33.726Z","repository":{"id":98598623,"uuid":"242385406","full_name":"whizsid/jsonapiunit","owner":"whizsid","description":"TypeScript like unit testing framework for JSON REST APIs","archived":false,"fork":false,"pushed_at":"2020-03-07T16:21:41.000Z","size":68,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T05:17:01.831Z","etag":null,"topics":["json-api","json-api-tester","jwt","pinned","type","typescript","unit-test"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/whizsid.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-22T17:48:56.000Z","updated_at":"2022-05-19T14:37:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"a790cafe-ed42-4a7c-ad74-ae8888584d7d","html_url":"https://github.com/whizsid/jsonapiunit","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/whizsid/jsonapiunit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whizsid%2Fjsonapiunit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whizsid%2Fjsonapiunit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whizsid%2Fjsonapiunit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whizsid%2Fjsonapiunit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whizsid","download_url":"https://codeload.github.com/whizsid/jsonapiunit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whizsid%2Fjsonapiunit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33137831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["json-api","json-api-tester","jwt","pinned","type","typescript","unit-test"],"created_at":"2024-10-13T02:46:58.583Z","updated_at":"2026-05-17T12:08:33.701Z","avatar_url":"https://github.com/whizsid.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSONAPIUnit\n\n---\n![AUR version](https://img.shields.io/aur/version/jsonapiunit)\n![GitHub](https://img.shields.io/github/license/whizsid/jsonapiunit)\n![Travis CI](https://travis-ci.org/whizsid/jsonapiunit.svg?branch=master)\n---\n\nA framework for unit testing your JSON REST APIs. Write test cases in typescript like language.\n\n## Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Configuration](#configuration)\n    - [Defining Default Request Behaviours](#defining-default-request-behaviours)\n    - [Base URL](#base-url)\n    - [Under Proxy](#under-proxy)\n    - [Select Test Cases](#select-test-cases)\n    - [Pre Variables](#pre-variables)\n- [Example](#example)\n    - [Example Test Case](#example-test-case)\n    - [Example Output](#example-output)\n    - [Example Project](#example-project)\n- [Request](#request)\n    - [User Inputs](#user-inputs)\n    - [Using Variables](#using-variables)\n- [Validating Response](#validating-response)\n    - [Type Checking](#type-checking)\n    - [Variable Declaration](#variable-declaration)\n    - [Compare With Previously Created Variables](#comparisons)\n    - [Array Validation](#array-validation)\n    - [Nested Objects Validation](#nested-object-validation)\n    - [Advanced Validations](#advanced-validations)\n- [Todo](#todo)\n- [Contributing](#contributing)\n\n## Installation\n\n### Ubuntu\n\nDownload the ubuntu build from [here](https://github.com/whizsid/jsonapiunit/releases/download/0.1.3/jsonapiunit_0.1.3_amd64.deb) and install it using below command.\n\n```\n$ sudo dpkg -i ./jsonapiunit_0.1.3_amd64.deb\n\n```\n\n### Arch Linux\n\nClone the AUR and install.\n\n```\ngit clone https://aur.archlinux.org/jsonapiunit.git\ncd jsonapiunit\nmakepkg -si\n\n```\n\n### Other Distros\n\nDownload pre-built binary from [here](https://github.com/whizsid/jsonapiunit/releases/download/0.1.3/jsonapiunit) and run it.\n\n## Usage\n\nDownload binaries or build the JSONAPIUnit on your PC and run `jsonapiunit` on your terminal.\n\n## Configuration\n\nJSONAPIUnit looks for a `jsonapiunit.jsonc` configuration file in the project root folder.\n\n### Defining Default Request Behaviours\n\nUsers can define default request headers or method by placing a property named `default` in their config file. This property is optional.\n\n```jsonc\n// jsonapiunit.jsonc\n{\n    // ...\n    \"default\":{\n        // Optional\n        \"method\":\"GET\",\n        // Optional\n        \"headers\": {\n            \"Accept\": \"application/json\"\n        }\n    }\n}\n\n\n```\n\n### Base URL\n\n`baseUrl` property allow users to define their base URL. After that users can define a relative URL in their test cases. This property is optional. JSONAPIUnit using [RFC3986](https://tools.ietf.org/html/rfc3986#section-5.2) standard to combine the URLs. \n\n```jsonc\n// jsonapiunit.jsonc\n{\n    // ...\n    \"baseUrl\":\"http://127.0.0.1:8000/api/\"\n}\n\n```\n\n\n```jsonc\n// In the test case\n{\n    // ...\n    \"url\":\"user/login\"\n}\n\n```\n\n### Under Proxy\n\nA proxy to use for outgoing https requests. Users can define their proxy settings by adding a new property named `proxy` to their config file.\n\n```jsonc\n// jsonapiunit.jsonc\n{\n    \"proxy\":{\n        // This property is required\n        \"uri\": \"proxy uri\",\n        // These properties are optional\n        \"username\": \"username to the proxy server\",\n        \"password\": \"proxy server password\"\n    }\n}\n\n```\n\n### Select test cases\n\nUsers can provide their own file path pattern for tracking test cases. By default JSONAPIUnit will tracking the `apiTest/*.jsonc` files.\n\n```jsonc\n// jsonapiunit.jsonc\n{\n    // ...\n    \"files\": \"tests/*.json\"\n}\n\n```\n\n### Pre Variables\n\nUsers can provide variables to use in test cases. These variables creating on initialization.\n\n```jsonc\n// jsonapiunit.jsonc\n{\n    // ...\n    \"preVariables\":{\n        \"username\":\"murali\"\n    }\n}\n\n```\n\n## Example\n\n### Example Test Case\n\nThis is a example test case for JSONAPIUnit. \n\n```jsonc\n{\n    \"url\":\"http://127.0.0.1:8000/api/user/login\",\n    // This property is optional if you \n    // provided a default request method \n    // in config file\n    \"method\":\"POST\",\n    \"request\":{\n        \"body\":{\n            \"username\":\"dev\",\n            // Prompt user to insert a password\n            // to send with the request\n            // and storing it in a new variable\n            // named `password`.\n            // You can access this variable in\n            // other test cases\n            \"password\":\"{{ \u003e password: string }}\"\n        },\n        // This property is optional if you \n        // provided a default request method \n        // in config file\n        \"headers\":{\n            \"Accept\": \"application/json\",\n            \"Content-Type\": \"application/json\"\n        }\n    },\n    \"response\": {\n        \"body\":{\n            // Creating a new variable named token and checking the type\n            \"token\":\"{{ token: string }}\",\n            // Checking the type without creating a new variable\n            \"mileage\": \"{{ number }}\",\n            \"limit\": \"{{ limit:number }}\",\n            // Save the value to a variable named anotherLimit and \n            // compare it with previously created variable\n            \"anotherLimit\": \"{{ anotherLimit:number \u0026\u0026 (anotherLimit \u003e= limit) }}\"\n        }\n    }\n}\n\n```\n\n### Example Output\n\n\nThis is a sample output of JSONAPIUnit.\n\n```\nSTARTED : apiTest/b_userDetails.jsonc\nPASSED : Assertion: HTTP_STATUS_200, Value: HTTP_STATUS_200\nFAILED : Assertion: \"{{ limit:number }}\", Value: Not Supplied\nPASSED : Assertion: \"{{string}}\", Value: \"Muththaiya Muralitharan\"\nPASSED : Assertion: true, Value: true\nFAILED : Assertion: \"{{usage: number \u0026\u0026 usage\u003c=limit}}\", Value: Not Supplied\nPASSED : Assertion: \"{{string}}\", Value: \"murali\"\nFAILED TEST CASE : Name: apiTest/b_userDetails.jsonc, Reason: \"Some assertion(s) failed.\", Assertions: 5, Fails: 2, TotAssertions: 13, TotFails: 2\n\n```\n\n### Example Project\n\nUsers can run working example by executing following commands.\n\n```bash\n$ cargo build --all\n$ cd example\n$ cargo run\n// Open an another terminal in current directory and run bellow command parallely.\n$ ../target/debug/json-api-tester\n\n```\n\n## Request\n\nJSONAPIUnit enable users to create dynamic requests based on previously requests.\n\nNormal request:-\n\n```jsonc\n{\n    // ...\n    \"request\":{\n        \"body\":{\n            \"username\":\"my-user\"\n        },\n        \"headers\":{\n            \"Accept\":\"application/json\"\n        }\n    }\n}\n\n```\n\n### User Inputs\n\nUsers can insert their inputs before sending the request.\n\n```jsonc\n// Test Case\n{\n    // ...\n    \"request\":{\n        // ...\n        \"body\":{\n            \"password\":\"{{\u003e password: string}}\"\n        }\n    }\n}\n\n```\n\n### Using Variables\n\nSending previously created variables in request body or request headers.\n\n```jsonc\n// Test Case\n{\n    \"request\":{\n        \"body\":{\n            // catId is a previously created variable\n            \"id\":\"{{catId}}\"\n        },\n        \"headers\":{\n            // token is also a previously created variable\n            \"Authorization\": \"Bearer {{token}}\"\n        }\n    }\n}\n\n```\n\n## Validating Responce\n\n### Type Checking\n\nCheck the exact type of response data. Available types are `string`,`number`,`null`,`any`,`array` and `object`.\n\nExample:-\n\n```jsonc\n// Test Case\n\n{\n    // ...\n    \"response\":{\n        // ...\n        \"body\":{\n            \"name\" : \"{{string}}\",\n            \"limit\" : \"{{number}}\",\n            \"nick_name\" : \"{{string|null}}\"\n        }\n    }\n}\n\n```\n\nJSONAPIUnit currently not supporting to use multiple conflicting types. Ex:- `number|string`, `object|array`\n\n### Variable Declaration\n\nAssign JSON value to a new variable. \n\n```jsonc\n// Test Case\n{\n    // ...\n    \"response\":{\n        // ...\n        \"body\":{\n            \"name\": \"{{name:string}}\",\n            \"limit\": \"{{ limit: number }}\",\n            \"nick_name\": \"{{ nickName: string|null }}\"\n        }\n    }\n}\n\n```\n\nYou can use these variables to validate other assertions on same test case or another test cases.\n\n### Comparisons\n\nCompare data with previously created variables or other hard coded values.\n\n```jsonc\n// Test Case\n{\n    // ...\n    \"response\":{\n        // ...\n        \"body\":{\n            // mileageLimit is a previously created variable\n            \"mileage\":\"{{mileage:number \u0026\u0026 mileage \u003c= mileageLimit}}\",\n            \"billCount\": \"{{billCount:number \u0026\u0026 billCount \u003e 0}}\",\n            \"name\": \"{{name: string \u0026\u0026 name == 'Abrahm'}}\"\n        }\n    }\n}\n\n```\n\n### Array Validations\n\nValidating all elements of an array.\n\n```jsonc \n\n// Test Case\n{\n    // ...\n    \"response\":{\n        // ...\n        \"body\":{\n            \"categories\":[\n                // JSONAPIUnit will matching all elements\n                // of this array with bellow type.\n                {\n                    \"id\":\"{{number}}\",\n                    \"name\":\"{{string}}\"\n                }\n            ]\n        }\n    }\n}\n\n\n```\n\n### Nested Object Validation\n\nValidating the nested elements of response.\n\n```jsonc\n\n// Test Case\n\n{\n    // ...\n    \"response\":{\n        // ...\n        \"body\":{\n            // ...\n            \"product\":{\n                // ...\n                \"category\":{\n                    // ...\n                    \"name\":\"{{string}}\"\n                }\n            }\n        }\n    }\n}\n```\n\n### Advanced Validations\n\nUsers can use JS functions in comparisons to validate.\n\n```jsonc\n// Test Case\n{\n    // ...\n    \"response\":{\n        // ...\n        \"body\":{\n            \"categories\":\"{{categories:array \u0026\u0026 categories.length \u003e100}}\"\n        }\n    }\n}\n\n```\n\n## Todo\n\n- Response Header Validation.\n- Passing config variables from command line.\n\n## Contributing\n\nAll PRs and issues are welcome. And also stars are welcome.\n\nPlease format and test your codes before sending PRs.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhizsid%2Fjsonapiunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhizsid%2Fjsonapiunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhizsid%2Fjsonapiunit/lists"}