# Test does not fail but creates an error

**URL:** <https://community.postman.com/t/test-does-not-fail-but-creates-an-error/31952>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [January 27, 2022, 2:39pm UTC](https://community.postman.com/t/test-does-not-fail-but-creates-an-error/31952 "2022-01-27T14:39:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulgroothuisrvc](https://avatars.discourse-cdn.com/v4/letter/p/97f17d/32.png) [@paulgroothuisrvc](https://community.postman.com/u/paulgroothuisrvc)\
**Post date:** [January 27, 2022, 2:39pm UTC](https://community.postman.com/t/test-does-not-fail-but-creates-an-error/31952/1 "2022-01-27T14:39:19Z")

</div>

I’m trying to use the below syntax to trigger a GET call within a test, and perform some tests on the response.

```auto
pm.test(`example GET call`, () => {
	pm.sendRequest(`https://postman-echo.com/get`, (error, response) => {
        pm.expect(response).to.have.property('code', 201);
	});
});

```

This works fine as long as the tests passes. However, when the expect fails I don’t get a red block marking the test as failed. Instead I get the below error and the test run completely stops.

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/c/c5ed9d87b31609519717c7ee0e8a7921b0a655e7.png)

The log also doesn’t give me much to work with

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

When I do the same test from a separate Postman Request I do get the result I’m expecting

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

How can I make it so the test fails as shown above, when triggering the call within a test?

---

<div class="post-metadata">

**Author:** ![paulgroothuisrvc](https://avatars.discourse-cdn.com/v4/letter/p/97f17d/32.png) [@paulgroothuisrvc](https://community.postman.com/u/paulgroothuisrvc)\
**Post date:** [January 27, 2022, 2:57pm UTC](https://community.postman.com/t/test-does-not-fail-but-creates-an-error/31952/2 "2022-01-27T14:57:38Z")

</div>

Took me quite a while to figure this out, but it turns out the solution is to not trigger the call in the pm.test, but the other way around.

This does not work:

```auto
pm.test(`example GET call`, () => {
	pm.sendRequest(`https://postman-echo.com/get`, (error, response) => {
        pm.expect(response).to.have.property('code', 201);
	});
});

```

This works just fine:

```auto
pm.sendRequest(`https://postman-echo.com/get`, (error, response) => {
       pm.test(`example GET call`, () => {
	        pm.expect(response).to.have.property('code', 201);
	});
});

```

---

<div class="post-metadata">

**Author:** ![kevinc-postman](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kevinc-postman/32/12774_2.png) [@kevinc-postman](https://community.postman.com/u/kevinc-postman)\
**Post date:** [January 27, 2022, 2:59pm UTC](https://community.postman.com/t/test-does-not-fail-but-creates-an-error/31952/3 "2022-01-27T14:59:25Z")

</div>

Good work figuring this out!  
(And props to you for sharing the solution in case others find this same issue 😉)
