# Hello everyone, pls help me i m facing issue at Test result showing failure when i send a request to see Wht books to checkout?

**URL:** <https://community.postman.com/t/hello-everyone-pls-help-me-i-m-facing-issue-at-test-result-showing-failure-when-i-send-a-request-to-see-wht-books-to-checkout/37040>\
**Category:** Help Hub\
**Tags:** tests, json\
**Created:** [July 9, 2022, 6:35pm UTC](https://community.postman.com/t/hello-everyone-pls-help-me-i-m-facing-issue-at-test-result-showing-failure-when-i-send-a-request-to-see-wht-books-to-checkout/37040 "2022-07-09T18:35:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![yashikag-2802](https://avatars.discourse-cdn.com/v4/letter/y/6f9a4e/32.png) [@yashikag-2802](https://community.postman.com/u/yashikag-2802)\
**Post date:** [July 9, 2022, 6:35pm UTC](https://community.postman.com/t/hello-everyone-pls-help-me-i-m-facing-issue-at-test-result-showing-failure-when-i-send-a-request-to-see-wht-books-to-checkout/37040/1 "2022-07-09T18:35:01Z")

</div>

**Your question may already have an answer on the community forum. Please search for related topics, and then read through the [guidelines](https://community.postman.com/t/about-the-just-getting-started-category/37) before creating a new topic.**

> Here’s an outline with best practices for making your inquiry.

_My question_:

_Details (like screenshots)_:

_How I found the problem_:

_I’ve already tried_:  
 ![Capture](https://us1.discourse-cdn.com/getpostman/original/2X/a/ae8918a5614799e15a4d113322ea91d611eb152e.jpeg)

---

<div class="post-metadata">

**Author:** ![atifkhan5425](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/atifkhan5425/32/29621_2.png) [@atifkhan5425](https://community.postman.com/u/atifkhan5425)\
**Post date:** [July 9, 2022, 9:57pm UTC](https://community.postman.com/t/hello-everyone-pls-help-me-i-m-facing-issue-at-test-result-showing-failure-when-i-send-a-request-to-see-wht-books-to-checkout/37040/2 "2022-07-09T21:57:29Z")

</div>

Your screenshot is not visible put your response body and what assertion you have used then I m able to help you.

---

<div class="post-metadata">

**Author:** ![yashikag-2802](https://avatars.discourse-cdn.com/v4/letter/y/6f9a4e/32.png) [@yashikag-2802](https://community.postman.com/u/yashikag-2802)\
**Post date:** [July 10, 2022, 7:49am UTC](https://community.postman.com/t/hello-everyone-pls-help-me-i-m-facing-issue-at-test-result-showing-failure-when-i-send-a-request-to-see-wht-books-to-checkout/37040/3 "2022-07-10T07:49:27Z")

</div>

![Capture7](https://us1.discourse-cdn.com/getpostman/original/2X/a/af751e201987ec7fb1604f73e50811c16105b2f4.jpeg)

i have used this assertion , below is the failure i m getting in test Results .

pls help

---

<div class="post-metadata">

**Author:** ![skandh-15](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@skandh-15](https://community.postman.com/u/skandh-15)\
**Post date:** [July 10, 2022, 8:02am UTC](https://community.postman.com/t/hello-everyone-pls-help-me-i-m-facing-issue-at-test-result-showing-failure-when-i-send-a-request-to-see-wht-books-to-checkout/37040/4 "2022-07-10T08:02:17Z")

</div>

Hi @yashikag-2802 , can you please paste your test script as well. Looks like in your test script you are trying to validate it otherwise.

---

<div class="post-metadata">

**Author:** ![yashikag-2802](https://avatars.discourse-cdn.com/v4/letter/y/6f9a4e/32.png) [@yashikag-2802](https://community.postman.com/u/yashikag-2802)\
**Post date:** [July 10, 2022, 8:15am UTC](https://community.postman.com/t/hello-everyone-pls-help-me-i-m-facing-issue-at-test-result-showing-failure-when-i-send-a-request-to-see-wht-books-to-checkout/37040/5 "2022-07-10T08:15:10Z")

</div>

pm.test(“Status code is 200”, function () {  
pm.response.to.have.status(200);  
});

pm.test(“Correct method is used in request”, function () {  
const cond = pm.request.method === “GET”;  
pm.expect(cond).to.eql(true);  
});

pm.test(“Correct path is used in request”, function () {  
pm.expect(pm.request.url.path[0]).to.match(/^books$/);  
});

const body = pm.response.json()

pm.test(“Response is an array”, function () {  
const cond = Array.isArray(body)  
pm.expect(cond).to.eql(true);  
});

pm.test(“Only books that are not currently checked out are returned”, function () {  
const cond = body.every(book =\> !book.checkedOut)  
pm.expect(cond).to.eql(true);  
});

---

<div class="post-metadata">

**Author:** ![skandh-15](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@skandh-15](https://community.postman.com/u/skandh-15)\
**Post date:** [July 10, 2022, 8:19am UTC](https://community.postman.com/t/hello-everyone-pls-help-me-i-m-facing-issue-at-test-result-showing-failure-when-i-send-a-request-to-see-wht-books-to-checkout/37040/6 "2022-07-10T08:19:15Z")

</div>

Hey @yashikag-2802 ,

So you see the condition you are trying to test is

> !book.checkedOut  
> this means that whaver you will get in your response negative of that so for current resposne which is true, cond becomes false and in next statement you are expecting it to be true,

what you should do is `const cond = body.every(book => book.checkedOut)` this would solve out your problem.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![yashikag-2802](https://avatars.discourse-cdn.com/v4/letter/y/6f9a4e/32.png) [@yashikag-2802](https://community.postman.com/u/yashikag-2802)\
**Post date:** [July 10, 2022, 8:20am UTC](https://community.postman.com/t/hello-everyone-pls-help-me-i-m-facing-issue-at-test-result-showing-failure-when-i-send-a-request-to-see-wht-books-to-checkout/37040/7 "2022-07-10T08:20:54Z")

</div>

Ohh Got it

Thanks a lot

---

<div class="post-metadata">

**Author:** ![tugcesoydass](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@tugcesoydass](https://community.postman.com/u/tugcesoydass)\
**Post date:** [July 11, 2022, 7:59pm UTC](https://community.postman.com/t/hello-everyone-pls-help-me-i-m-facing-issue-at-test-result-showing-failure-when-i-send-a-request-to-see-wht-books-to-checkout/37040/8 "2022-07-11T19:59:51Z")

</div>

Hi,  
Could you please help me? I faced same issue.

> [@How can i compare the same values found in the json formatted response](https://community.postman.com/t/how-can-i-compare-the-same-values-found-in-the-json-formatted-response/37054):
>
> Hi All, I sent request and got response. In this response all products were listed up. I am trying to get all same variables and check they are same or not. For example I need to check all " installment" are “true”. How could I write script for that. { “result”: { “data”: { “categoryName”: null, “products”: [ { “code”: “at773”, “name”: “2 Dal Beyaz Orkide Çiçeği”, “price”: { “current”: 79.99, “total”: 79.99, “currency”: “TL”, “currencyCode”: “TRY” }, “installment”: true, “instal…
