我正在将 Pact-js 与 Jest 一起使用,我试图从提供者端获取返回(真实)API 消耗的响应,代码如下。
describe("Validate pact of identity", () => {
it("Validate pact of identity creation", () => {
let opts = {
providerBaseUrl: baseUrl.BASE_URL,
changeOrigin: true,
provider: "Create identity Service",
logLevel: "DEBUG",
pactUrls: [
path.resolve(
process.cwd(),
`./__tests__/contract/pacts/${requestData.nameConsumerPactFile}-${requestData.nameProviderPactFile}.json`
),
],
requestFilter: async (req, res, next) => {
req.headers["Authorization"] = `Bearer ${await postRequestToken(paths.TOKEN_NON_CDE)}`,
next()
},
consumerVersionTags: ["QA"],
providerVersionTags: ["QA"],
publishVerificationResult: false,
providerVersion: "1.0.0"
}
return new Verifier(opts).verifyProvider()
.then((res) => {
console.log('pact veryify complete, !!!');
console.log(res);
});
})
})
但是方法Verifier(opts).verifyProvider() res 变量值不返回 API 响应,有什么方法可以在 PACT 进行验证后获取响应?