Sort validation is pass when there is no data in response

The sorted scenario gets passed even though there is no response displayed. I checked postman community and have implemented the logic for my API response. Can someone please look and suggest me what is wrong here.

Your actual and expected results are using the same dataset.

Your using the Lodash library to sort the response by the sequence key, in ascending order.

You then check this against the un-sorted response to ensure its the same.

If the response is a blank array, then the assertion will pass as the expected and actual results are the same (a blank array or undefined).

You can add an extra assertion that checks for the existence of the accountGroups array, and that its not empty.

1 Like

Thanks Mike. I have modified the code as per your suggestion. Below are the conditions.

  1. Validate whether the array is empty. if empty don’t sort
  2. If array is not empty then perform sorting of required fields