# Test of single json response value for both true and false are passing

**URL:** <https://community.postman.com/t/test-of-single-json-response-value-for-both-true-and-false-are-passing/47644>\
**Category:** Help Hub\
**Tags:** tests, json\
**Created:** [May 19, 2023, 4:54pm UTC](https://community.postman.com/t/test-of-single-json-response-value-for-both-true-and-false-are-passing/47644 "2023-05-19T16:54:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom.rippetoe](https://avatars.discourse-cdn.com/v4/letter/t/9e8a1a/32.png) [@tom.rippetoe](https://community.postman.com/u/tom.rippetoe)\
**Post date:** [May 19, 2023, 4:54pm UTC](https://community.postman.com/t/test-of-single-json-response-value-for-both-true-and-false-are-passing/47644/1 "2023-05-19T16:54:55Z")

</div>

Hello. The typical ‘happy path’ response from my API has this structure:

```auto
{
    "features": [
        {
            "reportId": "RPT088308"
        }
    ],
    "success": true,
    "error": null
}

```

When i test the value of “success” within a single response, tests of ‘true’ and ‘false’ both pass. I would expect one to pass and one to fail. In the test suite below, all three tests pass

```auto
pm.test("Content-Type header is application/json", () => {
  pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json; charset=utf-8');
});

const jsonData = pm.response.json();
pm.test("json 'success' to be false"), () => {
    pm.expect(jsonData.success).to.eql(false);
}
pm.test("json 'success' to be true"), () => {
    pm.expect(jsonData.success).to.eql(true);
}

```

Am in misunderstanding what i think i’m testing? what could be amiss here?

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [May 22, 2023, 10:17am UTC](https://community.postman.com/t/test-of-single-json-response-value-for-both-true-and-false-are-passing/47644/2 "2023-05-22T10:17:25Z")

</div>

> [@tom.rippetoe](#):
>
> ```auto
> pm.test("json 'success' to be false"), () => {
> pm.expect(jsonData.success).to.eql(false);
> }
> pm.test("json 'success' to be true"), () => {
> pm.expect(jsonData.success).to.eql(true);
> }
> 
> ```

You have a bracket in the wrong place, basically closing the test at the name. Therefore the function is not evaluated.

```auto
pm.test("json 'success' to be false", () => {
    pm.expect(jsonData.success).to.eql(false);
})
pm.test("json 'success' to be true", () => {
    pm.expect(jsonData.success).to.eql(true);
})

```

---

<div class="post-metadata">

**Author:** ![tom.rippetoe](https://avatars.discourse-cdn.com/v4/letter/t/9e8a1a/32.png) [@tom.rippetoe](https://community.postman.com/u/tom.rippetoe)\
**Post date:** [May 22, 2023, 5:07pm UTC](https://community.postman.com/t/test-of-single-json-response-value-for-both-true-and-false-are-passing/47644/3 "2023-05-22T17:07:56Z")

</div>

**UGH!** you are exactly correct.

Thank you for catching that. I am glad for the additional, maybe not as tired, set of eyes.
