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, //响应状态码
}
}
]
}
}
Result |
rule |
expect |
response content |
OK |
a.b= |
c |
c |
NO |
a.b= |
c |
d |