# AssertionError: expected ' ' to deeply equal

**URL:** <https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977>\
**Category:** Help Hub\
**Tags:** tests, variables, collections, json\
**Created:** [April 22, 2021, 12:55pm UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977 "2021-04-22T12:55:50Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Raja2242](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@Raja2242](https://community.postman.com/u/Raja2242)\
**Post date:** [July 5, 2021, 8:15am UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/21 "2021-07-05T08:15:11Z")

</div>

> [@moorthiraj](#):
>
> pm.expect(0).to.eql(pm.globals.get(1));

Hello @moorthiraj

Thanks for your comments, I tried with  
pm.expect(0).to.eql(pm.globals.get(1));

but, I am still getting the AssertionError: expected 0 to deeply equal undefined, as message.

---

<div class="post-metadata">

**Author:** ![moorthiraj](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@moorthiraj](https://community.postman.com/u/moorthiraj)\
**Post date:** [July 5, 2021, 9:22am UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/22 "2021-07-05T09:22:16Z")

</div>

Hi @Raja2242

If the error is coming as ‘undefined’ means,

then log the values of the variable you are getting globally as,

console.log(pm.globals.get(1)); //should show the respective value

But we will save the a value globally as a variable right! So could you provide the variable name to call there like,

console.log(pm.globals.get(“variableName”));

I tried in my end and advising this. Please check and let me know if you have any issues.

---

<div class="post-metadata">

**Author:** ![popcornazerty](https://avatars.discourse-cdn.com/v4/letter/p/f4b2a3/32.png) [@popcornazerty](https://community.postman.com/u/popcornazerty)\
**Post date:** [June 22, 2022, 2:22pm UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/24 "2022-06-22T14:22:56Z")

</div>

Hello,

I have an issue with a test. I am looking to check the length of element “skuId”

{  
“order”: “A1822”,  
“style”: “VQ35”,  
“detail”: [  
{  
“Area”: “ITALY\_FRSE”,  
“skuDetail”: [  
{  
“skuId”: 119406,

My test looks like that:

let jsonData = pm.response.json();  
jsonData.detail[0].skuDetail.forEach(function(article) {  
console.log(article.skuId);  
pm.test(“Body matches string”, function() {  
pm.expect(6).to.eql(article.skuId.length)});  
});

==\> I am getting this error "  
Body matches string | AssertionError: expected 6 to deeply equal undefined"

Any help would be highly appreciated !

---

<div class="post-metadata">

**Author:** ![abir009876](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@abir009876](https://community.postman.com/u/abir009876)\
**Post date:** [June 23, 2022, 4:51am UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/25 "2022-06-23T04:51:01Z")

</div>

@bpricilla Hello I Have Issue with a test. I need help . AssertionError: expected 2089 to deeply equal ‘2089’

pm.test(“Search By Customar Id”, function () {  
var jsonData = pm.response.json();  
pm.expect(jsonData.user.id).to.eql(pm.collectionVariables.get(“id”));  
console.log(pm.collectionVariables.get(“id”))  
});

 ![Cap](https://us1.discourse-cdn.com/getpostman/original/2X/1/151b409cafc28dd92d8c13b0f87bc1496be34f27.png)

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [June 27, 2022, 10:15am UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/26 "2022-06-27T10:15:00Z")

</div>

@abir009876 Welcome to the community 🥳

This error explains that the value is same but the data type is different here. Please check the data type of the userID. Seems like it’s stored as string. In that case, you need to use [stringify()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) method for the collection variable “id”.

---

<div class="post-metadata">

**Author:** ![telecoms-operator-87](https://avatars.discourse-cdn.com/v4/letter/t/7ba0ec/32.png) [@telecoms-operator-87](https://community.postman.com/u/telecoms-operator-87)\
**Post date:** [September 28, 2022, 5:57pm UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/27 "2022-09-28T17:57:38Z")

</div>

@bpricilla Hello, I Have Issue in this test and I need a help ,  
Can you please look into this error and answer it.  
I’m beginner and don’t know how to resolve this error.  
TIA

 ![Booklist issue](https://us1.discourse-cdn.com/getpostman/original/3X/c/7/c76247fdba3a7d841229f22e03fa3af7c171d1fd.png)

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [November 10, 2022, 5:37am UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/28 "2022-11-10T05:37:44Z")

</div>

@telecoms-operator-87 Hello!! Not sure if you managed to fix this ☺ Let me know if you still face issue here!!

---

<div class="post-metadata">

**Author:** ![ppoorna](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@ppoorna](https://community.postman.com/u/ppoorna)\
**Post date:** [December 28, 2022, 3:31pm UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/29 "2022-12-28T15:31:44Z")

</div>

Hi Team,

Kindly help me on this one again… have used the method – parseInt(“10080”) but still not working.

let jsonData = pm.response.json();

let multiAcctNum = jsonData.members[0].memberNumber;  
console.log(multiAcctNum);

pm.test(“Verify the multiAcctNum value is 10080”, function() {  
pm.expect(multiAcctNum.memberNumber).to.eql(parseInt(“10080”));  
})

FAIL : -Verify the multiAcctNum value is 10080 | AssertionError: expected undefined to deeply equal 10080

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/0/8/08c020d395c5181914143be918ffc890acfb90ee.png)

---

<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:** [January 1, 2023, 4:37pm UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/30 "2023-01-01T16:37:50Z")

</div>

@ppoorna

This should have probably been a new question.

You have already defined the variable multiAcctNum down to the memberNumber element.

Therefore the assertion should be.

```auto
pm.expect(multiAcctNum).to.eql(parseInt(“10080”));

```

Although why do you need to parse the number. The following should work.

```auto
pm.expect(multiAcctNum).to.eql(10080);

```

---

<div class="post-metadata">

**Author:** ![payload-observer-938](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/payload-observer-938/32/14332_2.png) [@payload-observer-938](https://community.postman.com/u/payload-observer-938)\
**Post date:** [January 2, 2023, 11:06am UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/31 "2023-01-02T11:06:56Z")

</div>

![Capture](https://us1.discourse-cdn.com/getpostman/original/3X/9/f/9f59f07a3dbb3755e5078eb62690653aef162561.jpeg)  
Please Help! @bpricilla  
Why this error is being displayed? Kindly tell how to proceed!

---

<div class="post-metadata">

**Author:** ![payload-observer-938](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/payload-observer-938/32/14332_2.png) [@payload-observer-938](https://community.postman.com/u/payload-observer-938)\
**Post date:** [January 2, 2023, 11:32am UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/32 "2023-01-02T11:32:23Z")

</div>

Waiting for your reply @bpricilla

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [January 2, 2023, 12:41pm UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/33 "2023-01-02T12:41:08Z")

</div>

@payload-observer-938 Usually this “undefined” pops up when it couldn’t locate the path of the JSON element. Please paste your JSON response in this [JSON path finder](https://jsonpathfinder.com/) tool. This helps you to break complex responses. If you are stuck, you can read [this](https://bpricilla.medium.com/how-to-easily-locate-your-json-object-in-your-api-response-647549ee8b2?sk=ff9b1c7f79e8b6587b77456503d1bd4f) blog to understand more about the tool 🙂

---

<div class="post-metadata">

**Author:** ![payload-observer-938](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/payload-observer-938/32/14332_2.png) [@payload-observer-938](https://community.postman.com/u/payload-observer-938)\
**Post date:** [January 2, 2023, 12:56pm UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/34 "2023-01-02T12:56:20Z")

</div>

Can’t find it! @bpricilla  
The same doubt was asked by @telecoms-operator-87 .  
Kindly tell it’s urgent!

 ![20230102_183803](https://us1.discourse-cdn.com/getpostman/original/3X/b/2/b2de51d4568385c71807fc5cdec4b260570614a6.jpeg)

---

<div class="post-metadata">

**Author:** ![payload-observer-938](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/payload-observer-938/32/14332_2.png) [@payload-observer-938](https://community.postman.com/u/payload-observer-938)\
**Post date:** [January 2, 2023, 1:10pm UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/35 "2023-01-02T13:10:36Z")

</div>

Waiting for your answer @bpricilla

---

<div class="post-metadata">

**Author:** ![payload-observer-938](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/payload-observer-938/32/14332_2.png) [@payload-observer-938](https://community.postman.com/u/payload-observer-938)\
**Post date:** [January 3, 2023, 6:01am UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/36 "2023-01-03T06:01:06Z")

</div>

@sseenivasan89 Kindly help on it!

---

<div class="post-metadata">

**Author:** ![sseenivasan89](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/sseenivasan89/32/8350_2.png) [@sseenivasan89](https://community.postman.com/u/sseenivasan89)\
**Post date:** [January 3, 2023, 11:23am UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/37 "2023-01-03T11:23:53Z")

</div>

Hi @payload-observer-938

the json path seems to be not valid one, possible can you share the response json to find the right path

---

<div class="post-metadata">

**Author:** ![payload-observer-938](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/payload-observer-938/32/14332_2.png) [@payload-observer-938](https://community.postman.com/u/payload-observer-938)\
**Post date:** [January 3, 2023, 3:04pm UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/38 "2023-01-03T15:04:24Z")

</div>

![20230103_203221](https://us1.discourse-cdn.com/getpostman/original/3X/0/f/0fd0dd7e9c1c3e859c041d86e8913597ffb74162.jpeg)  
 ![20230103_203210](https://us1.discourse-cdn.com/getpostman/original/3X/3/8/3823c522f75d343e316f152666af787730c5df6d.jpeg)  
@sseenivasan89 Sir please view it! I am not able to solve this problem. Would be greatful to you if you help me solve this error.

---

<div class="post-metadata">

**Author:** ![payload-observer-938](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/payload-observer-938/32/14332_2.png) [@payload-observer-938](https://community.postman.com/u/payload-observer-938)\
**Post date:** [January 3, 2023, 3:27pm UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/39 "2023-01-03T15:27:36Z")

</div>

@sseenivasan89 Waiting for your Response!

---

<div class="post-metadata">

**Author:** ![payload-observer-938](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/payload-observer-938/32/14332_2.png) [@payload-observer-938](https://community.postman.com/u/payload-observer-938)\
**Post date:** [January 3, 2023, 3:28pm UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/40 "2023-01-03T15:28:32Z")

</div>

@michaelderekjones Could you please help me out in it?  
Disclaimer: I am a Beginner.

---

<div class="post-metadata">

**Author:** ![sseenivasan89](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/sseenivasan89/32/8350_2.png) [@sseenivasan89](https://community.postman.com/u/sseenivasan89)\
**Post date:** [January 4, 2023, 12:26am UTC](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977/41 "2023-01-04T00:26:57Z")

</div>

@payload-observer-938

please share the json response body not your test

[Previous page](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977.md?page=1)

[Next page](https://community.postman.com/t/assertionerror-expected-to-deeply-equal/22977.md?page=3)
