我断言array1中的元素是否存在于array2中,下面是数组示例,
var array1 = [
{
"name": "appe",
"loc": "war",
"order": 5,
"neck": "NO",
"end": false
},
{
"name": "con",
"loc": "conve",
"order": 15,
"neck": "NO",
"end": true
}]
var array2 = [{"neck":"NO"
"end":true,
"loc":"conve",
"name":"con",
"order":15
}]
我试过的代码 -
const lodash = require("lodash");
for(var i = 0; i < array2.length; i++ )
{
tests['response json contain Data'] = lodash._.has(points, array2[i]);
//pm.expect(array2[i]).to.be.oneOf(array1);
}
我得到的错误 -
response json contain Data | AssertionError: expected false to be truthy
尝试另一次尝试后编辑2 -
pm.expect(array2[i]).to.be.oneOf(array1);
错误 -
AssertionError | expected { Object (name, loc, ...) } to be one of [ Array(20) ]
尝试3 -
pm.expect(array1).to.deep.equal(array2);
错误 -
AssertionError | expected [ Array(20) ] to deeply equal [ Array(18) ]
我做错了什么?我想要的是,如果 array2 中的任何一个元素不在 array1 中,它应该会失败。
谢谢