响应应具有两个给定属性中的任何一个

Response should have any of two given properties

我正在为使用 Chai 收到的响应编写测试用例。

我们收到的响应采用 json 对象的形式。

如果任何键('result' 或 'results')包含在 json 对象中,它应该抛出错误。

如果存在上述任一键,则不应抛出任何错误。

喜欢 ---- respone.body.should.have.property('result' 或 'results');

使用 Chai 期望 .any.all 属性。请参阅以下示例:

expect(response.body).to.contain.any.keys('result', 'results');
expect(response.body).to.contain.all.keys('result', 'results');