# Failed Tests Added Correctly | TypeError: Cannot read property 'event' of undefined

**URL:** <https://community.postman.com/t/failed-tests-added-correctly-typeerror-cannot-read-property-event-of-undefined/33663>\
**Category:** Help Hub\
**Tags:** tests, collections\
**Created:** [March 20, 2022, 2:58pm UTC](https://community.postman.com/t/failed-tests-added-correctly-typeerror-cannot-read-property-event-of-undefined/33663 "2022-03-20T14:58:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhisheksatya](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@abhisheksatya](https://community.postman.com/u/abhisheksatya)\
**Post date:** [March 20, 2022, 2:58pm UTC](https://community.postman.com/t/failed-tests-added-correctly-typeerror-cannot-read-property-event-of-undefined/33663/1 "2022-03-20T14:58:31Z")

</div>

_My question_:  
I have added the status 200 test as per the documentation and set collection variables user\_id and session\_token as token but one of my tests is failing during submission.

 ![Submit tests - Day 27](https://us1.discourse-cdn.com/getpostman/original/2X/3/3d4c6a1fb33068efddd2cff5fe1a7e2251d2ff3f.png)

 ![Test - Day 27](https://us1.discourse-cdn.com/getpostman/original/2X/7/7bbd18ed5bfff94616fe445f2ab88fe0be4871b2.png)

I tried adding a bunch of pm.expect and test functions to no avail.

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [March 21, 2022, 10:09am UTC](https://community.postman.com/t/failed-tests-added-correctly-typeerror-cannot-read-property-event-of-undefined/33663/2 "2022-03-21T10:09:44Z")

</div>

hI @abhisheksatya

Try changing;

```auto
const res = pm.response.json().response;

```

to

```auto
const res = pm.response.json();

```

---

<div class="post-metadata">

**Author:** ![abhisheksatya](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@abhisheksatya](https://community.postman.com/u/abhisheksatya)\
**Post date:** [March 21, 2022, 6:50pm UTC](https://community.postman.com/t/failed-tests-added-correctly-typeerror-cannot-read-property-event-of-undefined/33663/3 "2022-03-21T18:50:18Z")

</div>

Hey @w4dd325  
I did the change you mentioned but the issue still persists. I tried the following things.

1. Change that you specified.
2. const result = pm.response.json() and then const res = result.response. The reason being in the response body, the object is of the form below. So I need to use pm.response.json().response;

{  
response: {  
…  
}  
}

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [March 21, 2022, 10:19pm UTC](https://community.postman.com/t/failed-tests-added-correctly-typeerror-cannot-read-property-event-of-undefined/33663/4 "2022-03-21T22:19:07Z")

</div>

Just noticed, I think you are missing a semicolon after the top statement;

```auto
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

```

See if that works, if not, can you share a screenshot of your response so i can see the JSON structure please?

---

<div class="post-metadata">

**Author:** ![abhisheksatya](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@abhisheksatya](https://community.postman.com/u/abhisheksatya)\
**Post date:** [March 22, 2022, 5:35pm UTC](https://community.postman.com/t/failed-tests-added-correctly-typeerror-cannot-read-property-event-of-undefined/33663/5 "2022-03-22T17:35:18Z")

</div>

Hey @w4dd325, never mind, got the solution.

I forgot to add the 403 status code in the final request in the new user workflow folder. I did it and worked.

Apologies for the silly mistake 😅

Thank you so much for the help!
