Pact.js - willRespondWith 任意有序数组
Pact.js - willRespondWith an arbitrary ordered array
我的消费者服务向提供者服务询问所有用户的列表,但提供者以任意排序的列表回答(这很好)。消费者端的契约执行看起来不错,但在提供者站点上执行时,它说:例如 Expected "user1" but got "user3" at $.items[0].userName
。
这是互动的片段:
willRespondWith: {
status: 200,
headers: { "Content-Type": "application/json; charset=utf-8" },
body: {
items: [
{ userName: "user1" },
{ userName: "user2" },
{ userName: "user3" },
],
},
},
有没有办法忽略退货顺序?
此外,我的摩卡测试似乎对比较没有影响。我也尝试订购两个阵列,但没有任何帮助。两者(交互和 mocha 测试)是如何连接的?
it("Should generate a list of users in the system", async function () {
await userServiceClient.getUsers()
.then((users) => {
expect(users).to.include.members(EXPECTED_USERS_ARRAY);
});
});
非常感谢!
此功能目前尚未实现,但是,我建议使用 Pact.eachLike
,它只会匹配类型。字段的实际值很少重要。
我的消费者服务向提供者服务询问所有用户的列表,但提供者以任意排序的列表回答(这很好)。消费者端的契约执行看起来不错,但在提供者站点上执行时,它说:例如 Expected "user1" but got "user3" at $.items[0].userName
。
这是互动的片段:
willRespondWith: {
status: 200,
headers: { "Content-Type": "application/json; charset=utf-8" },
body: {
items: [
{ userName: "user1" },
{ userName: "user2" },
{ userName: "user3" },
],
},
},
有没有办法忽略退货顺序?
此外,我的摩卡测试似乎对比较没有影响。我也尝试订购两个阵列,但没有任何帮助。两者(交互和 mocha 测试)是如何连接的?
it("Should generate a list of users in the system", async function () {
await userServiceClient.getUsers()
.then((users) => {
expect(users).to.include.members(EXPECTED_USERS_ARRAY);
});
});
非常感谢!
此功能目前尚未实现,但是,我建议使用 Pact.eachLike
,它只会匹配类型。字段的实际值很少重要。