我想使用协议测试来验证提供者是否可以在响应中提供图像。现在实际的响应看起来像这个 包含图片的服务器响应主体
我的 Pact Json 文件看起来像这样
"interactions": [
{
"providerState": "there's a user has a portrait tiger.png",
"description": "Get the user's portrait",
"request": {
"method": "GET",
"path": "/api/Employees/v1/Employee/106656048406528/Attachments",
"headers": {
"Content-Type": "application/json",
"X-Employee-ID": "106656048406528",
"X-Tenant-ID": "26663977872256",
"X-User-ID": "1333"
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "image/jpeg;charset=UTF-8"
},
"body": "iVBORw0KGgoAAAANSU",
"matchingRules": {
"$.body": {
"match": "type"
}
}
}
}
],
契约测试总是失败并说身体不匹配。我可以理解实际响应不是 base64 格式,也不是字符串。它应该是一些二进制文件。在这种情况下,我怎样才能编写匹配规则来验证它是一个二进制文件?