xn-api-test

1.1.0 • Public • Published
module.exports = () => {
  return {
    host: "https://example.com", //选填,data参数中api可以覆盖
    headers: {//选填,data参数中headers可以覆盖, 合并当前配置
      'Content-Type': "application/json"
    },
    responseType: 'json', //选填,data参数中responseType可以覆盖
    data: [
      {
        method: 'GET', //默认GET,可选
        api: "/api/userinfo", //必填
        // data:"foo=bar", //GET query or post/put body
        //or
        data: {
          foo: 'bar'
        },
        responseType: "",
        // expect: (response, responseHeaders) => {
        //   //do something with response and responseHeaders
        //   return true;
        // },
        expect: {
          "data.username=": "小明", //完全匹配
          "data.username^": "小明", //前缀匹配
          "data.username$": "小明",//后缀匹配
          "data.username*": "小明",//包含匹配
          "data.username!": "小明",//不包含
          "data.users.0.name=": "小明",//数组取值
          "$.header.set-cookie=": "sessionID=xxxxx", //$表示整个response
          "$.body*": "<html>", //
          "$.status": 200, //响应状态码
        }
      }
    ]
  }
}

GET https://example.com/api/userinfo?foo=bar

Result rule expect response content
OK a.b= c c
NO a.b= c d

Readme

Keywords

none

Package Sidebar

Install

npm i xn-api-test

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

8.22 kB

Total Files

6

Last publish

Collaborators

  • xiunen