0

I am writing the Postman test cases. I am getting an error from following test-case

pm.test("Response to have expected data", function () {
   pm.expect(documentIdArray).to.have.members(['5868', '4', '5874']);  
});

There was an error in evaluating the test script:  Error: expected [ '4837', '4', '5874' ] to have the same members as [ '5868', '4', '5874' ]
Harjinder Singh
  • 23
  • 1
  • 10

1 Answers1

0

I think you are having string in documentIdArray. You can parse it:

pm.test("Response to have expected data", function () {
   pm.expect(JSON.parse(documentIdArray)).to.have.members(['5868', '4', '5874']);  
});

Else stringify the array and compare ( Recommended ) as the end point is not actually returning array but string it should be a bug

pm.test("Response to have expected data", function () {
   pm.expect(documentIdArray).to.be.equal(JSON.stringify(['5868', '4', '5874']));  
});
PDHide
  • 18,113
  • 2
  • 31
  • 46