DEV Community

WhizSid
WhizSid

Posted on

New Unit Testing Tool For JSON APIs. TypeScript Like Syntax.

Why are you write so much codes to check your JSON REST API? JSONAPIUnit is a new unit testing tool that enable users to write test cases easily.

Normal Framework

var client = new Client();

var request = client.get("http://127.0.0.1:8000/api/user/login");

var headers = new Headers();

headers.append("Content-Type","application/json");

// blah blah blah

JSONAPIUnit

{
  "url":"http://127.0.0.1:8000/api/user/login",
  "request":{
      "username":"{{username}}",
      "password":"{{password}}"
  },
  "response":{
      "body":{
         "token":"{{token:string}}",
         "name": "{{string}}",
         "limit": "{{limit: number && limit>250 }}",
         "posts": [
             {
                "id": "{{number}}",
                "title": "{{string}}"
             }
         ]
      },
      "status":200
  }
}

This is an open source project. Read more at github

Discussion (0)