42
rated 0 times
[
49]
[
7]
/ answers: 1 / hits: 7487
/ 5 Years ago, fri, july 12, 2019, 12:00:00
I'm asserting for elements in array1 does exist in array2 or not, below are the array samples,
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
}]
code I tried -
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);
}
error I get -
response json contain Data | AssertionError: expected false to be truthy
EDIT
after trying another attempt2 -
pm.expect(array2[i]).to.be.oneOf(array1);
error -
AssertionError | expected { Object (name, loc, ...) } to be one of [ Array(20) ]
attempt3 -
pm.expect(array1).to.deep.equal(array2);
error -
AssertionError | expected [ Array(20) ] to deeply equal [ Array(18) ]
what I'm doing wrong?. what I want is if any one element in array2 is not in array1 it should fail.
Thanks
More From » arrays