Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib test Jun 23, 2019
server
test add request header Jun 23, 2019
.gitignore add test case Jun 11, 2019
README.md Update README.md Jul 11, 2019
index.js add request May 23, 2019
package-lock.json add test case Jun 11, 2019
package.json

README.md

Check-rs-json

BASE ON CONFIG MOCHA TEST PLUGIN

About

Depending on the configurable API testing framework, no coding, just config

Example

git clone https://github.com/TimLiu1/check-rs-json.git
npm install
cd server && node index.js
mocha test/

Example

Quick Study

all test demo in the check-rs-json

npm install check-rs-json

Check response string object

//response 
{
    code: 200,
    name: "jsoncheck"
}
const CR = require('check-rs-json')
let rules =  {
    "name":"oneSting",
    "data":[{
        "name":"oneSting check value",
        "request":{
            "method":"get",
            "url":"?type=one-string"
        },
        "response":{
            "code": 200,
             "name":"jsoncheck"
        }
    },{
        "name":"oneSting check type",
        "request":{
            "method":"get",
            "url":"?type=one-string"
        },
        "response":{
            "code": 200,
            "name":{"type":"string","value":"jsoncheck"}
        }
    }]
}
let request = new CR.Request('localhost:3008',{"authentication":"csadcas.cdcasd.cdac"})
request.request(rules)

Check response number object

//response 
{
   code: 200,
   age: 20
}
const CR = require('check-rs-json')
let rules = {
    "name":"number-check",
    "data":[{
        "name":"number check",
        "request":{
            "method":"get",
            "url":"?type=one-number"
        },
        "response":{
            "code": 200,
             "age":20
        }
    },{
        "name":"oneSting check type",
        "request":{
            "method":"get",
            "url":"?type=one-number"
        },
        "response":{
            "code": 200,
            "age":{"type":"number","value":20}
        }
    }]
}
let request = new CR.Request('localhost:3008',{"authentication":"csadcas.cdcasd.cdac"})
request.request(rules)

Check with two type object and subobject

//response 
 {
   code: 200,
   info: { name: "jsoncheck", age: 20 }
 } 


const CR = require('check-rs-json')
let rules = {
    "name":"objectCheck",
    "data":[{
        "name":"object check",
        "request":{
            "method":"get",
            "url":"?type=two-object"
        },
        "response":{
            "code": 200,
             "info":{
                "type": "object",
                "children": {
                    "name":"jsoncheck",
                    "age":{"type":"number","value":20}
                }
             }
        }
    }]
}
let request = new CR.Request('localhost:3008',{"authentication":"csadcas.cdcasd.cdac"})
request.request(rules)

Check with Array

//response 
{
   code: 200,
   info: [{ name: "jsoncheck", age: 20 },{ name: "tim", age: 21 }]
} 


const CR = require('check-rs-json')
let rules = {
    "name":"arrayCheck",
    "data":[{
        "name":"array check",
        "request":{
            "method":"get",
            "url":"?type=array"
        },
        "response":{
            "code": 200,
             "info":{
                "type": "array",
                "children": [{
                    "name":"jsoncheck",
                    "age":{"type":"number","value":20}
                },{
                    "name":"tim",
                    "age":{"type":"number","value":21}
                }]
             }
        }
    }]
}

let request = new CR.Request('localhost:3008',{"authentication":"234567cdsc.cdcasd.csdacasd"})
request.request(rules)

POST

//response 
{
    code: 200,
    name: "jsoncheck"
}
const CR = require('check-rs-json')
let rules =  {
    "name":"oneSting",
    "data":[{
        "name":"oneSting check value",
        "request":{
            "method":"post",
            "url":"?type=one-string",
            "data":{"user":"tim","password":"1111111"}
        },
        "response":{
            "code": 200,
             "name":"jsoncheck"
        }
    }]
}
let request = new CR.Request('localhost:3008',{"authentication":"csadcas.cdcasd.cdac"})
request.request(rules)

Notes

The type check base on chai.expect

You can’t perform that action at this time.