describe('Getting asset for player', () => {
before(() => {
return provider.addInteraction({
given: 'GET call',
uponReceiving: 'Get asset for player',
withRequest: {
method: 'GET',
path: term({
matcher: '/api/assets/[0-9]+',
generate: '/api/assets/10006'
}),
},
willRespondWith: {
status: 200,
headers: { 'Content-Type': 'application/json' },
body: assetByPlayer
}
});
});
it('Get the asset by player', () => {
return request.get(`http://localhost:${PORT}/api/assets/10006`)
.set({ 'Accept': 'application/json' }).then((response) => {
return expect(Promise.resolve(response.statusCode)).to.eventually.equals(200);
}).catch(err => {
console.log("Error in asset with player listing", err);
});
});
});
我将json文件保存为:https://pastebin.com/TqRbTmNS
当我通过pact stub服务器在其他代码库中使用json文件时,它 从UI获取请求为 ===>收到的请求(方法:GET,路径:/ api / assets / 10006,查询: 无,标题:Some({{actasuserid“:” 5“,” content-type“:” application / vnd.nativ.mio.v1 + json“,” host“:” masteraccount.local.nativ.tv:30044“ ,“ accept”:“ application / json”,“ authorization”:“ Basic bWFzdGVydXNlcjptYXN0ZXJ1c2Vy”,“ connection”:“ close”,“ content-length”:“ 2”}),body:Present(2个字节))>
但不发送任何响应
但是,如果我只是删除匹配规则部分 “ matchingRules”:{ “ $ .path”:{ “ match”:“ regex”, “ regex”:“ \ / api \ / assets \ / [0-9] +” } } 它再次开始工作
===>收到的请求(方法:GET,路径:/ api / assets / 10006,查询:无,标头:Some({“ authorization”:“ Basic bWFzdGVydXNlcjptYXN0ZXJ1c2Vy”,“ accept”:“ application / json” ,“ content-length”:“ 2”,“ connection”:“ close”,“ host”:“ masteraccount.local.nativ.tv:30044”、“content-type”:“application/vnd.nativ.mio”。 v1 + json“,” actasuserid“:” 5“}),正文:Present(2个字节))
<===发送响应(状态:200,标头:Some({“ Content-Type”:“ application / json”}),正文:Present(4500字节))
我可以看到要显示的数据
你能告诉我这里出什么问题了吗?