# Tests "pass" after a failed assertion

**URL:** <https://community.postman.com/t/tests-pass-after-a-failed-assertion/62104>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [June 11, 2024, 9:21pm UTC](https://community.postman.com/t/tests-pass-after-a-failed-assertion/62104 "2024-06-11T21:21:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dimatkach](https://avatars.discourse-cdn.com/v4/letter/d/b5a626/32.png) [@dimatkach](https://community.postman.com/u/dimatkach)\
**Post date:** [June 11, 2024, 9:21pm UTC](https://community.postman.com/t/tests-pass-after-a-failed-assertion/62104/1 "2024-06-11T21:21:10Z")

</div>

Looks like this started happening after I upgraded postman, and tests became “post-response scripts”.  
I have this as a post-response script:

```auto
pm.test("foo", () => { pm.expect(1).to.eql(0); console.log("foo"); })

```

It aborts (log is never printed), but the test is marked as passed

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [June 11, 2024, 9:51pm UTC](https://community.postman.com/t/tests-pass-after-a-failed-assertion/62104/2 "2024-06-11T21:51:13Z")

</div>

Hey @dimatkach 👋

Welcome to the Postman community :postman:

Nothing in terms of functionality has change there, only the label and the location of the script.

What is it that you’re trying to do? What’s the actual scenario you’re running here and not the mock test that you have created.

In order to help you, it would be easier for us to have the full picture and the context of your workflow 🙏

---

<div class="post-metadata">

**Author:** ![dimatkach](https://avatars.discourse-cdn.com/v4/letter/d/b5a626/32.png) [@dimatkach](https://community.postman.com/u/dimatkach)\
**Post date:** [June 11, 2024, 11:20pm UTC](https://community.postman.com/t/tests-pass-after-a-failed-assertion/62104/3 "2024-06-11T23:20:39Z")

</div>

It looks like literally nothing else is going on here in terms of a “scenario” (I have spent half of my day to prove it to myself).  
Here is the whole “collection” I just created to demonstrate it. I just hit “Send”, it runs the request, and the script, and says everything looks good.  
The log line is never printed (nothing at all in console except for the actual request), but the dot next to “Scripts” in the ui is green.

```auto
{
  "info": {
    "_postman_id": "5a99cd97-a002-424f-afa1-402e14af547d",
    "name": "bug",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "31967039"
  },
  "item": [
    {
      "name": "New Request",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test(\"foo\", function() { pm.expect(1).to.eql(0); })"
            ],
            "type": "text/javascript",
            "packages": {}
          }
        },
        {
          "listen": "prerequest",
          "script": {
            "exec": [],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "https://google.com",
          "protocol": "https",
          "host": [
            "google",
            "com"
          ]
        }
      },
      "response": []
    }
  ]
}

```

---

<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:** [June 12, 2024, 10:34am UTC](https://community.postman.com/t/tests-pass-after-a-failed-assertion/62104/4 "2024-06-12T10:34:43Z")

</div>

I’ve copied that test verbatim and it appears to work for me.

![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/1/a18d8a6308770da9da6125dda2bf2ffebdd2a43f.png)

![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/5/35289554ffbd8499855c9561f59571b726c7758e.png)

If the test fails, then the console log command should not execute.

Are you saying you get a “green” pass in the “Test Results” tab?

If I change the assertion to `pm.expect(1).to.eql(1)` then the console log is triggered as expected.

![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/7/37aadd5b7a88f34fcb9cec416c2f8f999b4388e0.png)

---

<div class="post-metadata">

**Author:** ![dimatkach](https://avatars.discourse-cdn.com/v4/letter/d/b5a626/32.png) [@dimatkach](https://community.postman.com/u/dimatkach)\
**Post date:** [June 12, 2024, 11:24am UTC](https://community.postman.com/t/tests-pass-after-a-failed-assertion/62104/5 "2024-06-12T11:24:43Z")

</div>

Oh … I wasn’t looking at the Test Results tab. It does it did mark it as failed there correctly. I was expecting the dot next to “Scripts” label to turn red too – that’s what confused me. It used to do that when it was “Tests”

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [June 12, 2024, 3:06pm UTC](https://community.postman.com/t/tests-pass-after-a-failed-assertion/62104/6 "2024-06-12T15:06:07Z")

</div>

It previously didn’t go red - The dot on the `Tests` section would have still been green:  
 ![Screenshot 2024-06-12 at 16.03.31](https://us1.discourse-cdn.com/getpostman/original/3X/4/0/403c831c8dc7a106ac5942517444b29908f3f481.png)

If you had a script error, it would have turned red:

 ![Screenshot 2024-06-12 at 16.03.44](https://us1.discourse-cdn.com/getpostman/original/3X/9/f/9f99bcbba147d67849dab5ed1ee2e0ab016d482c.png)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [June 20, 2024, 7:27pm UTC](https://community.postman.com/t/tests-pass-after-a-failed-assertion/62104/7 "2024-06-20T19:27:11Z")

</div>

Closed on June 20, 2024, 7:27pm UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
