# How to assert multiple value like more than 10k values?

**URL:** <https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205>\
**Category:** Help Hub\
**Created:** [June 25, 2021, 1:26pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205 "2021-06-25T13:26:51Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ps198478320](https://avatars.discourse-cdn.com/v4/letter/p/5fc32e/32.png) [@ps198478320](https://community.postman.com/u/ps198478320)\
**Post date:** [June 25, 2021, 1:26pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/1 "2021-06-25T13:26:51Z")

</div>

Hi,  
my response returns more than 10k values and i have to assert them with expected values.  
If there are few, we can test them line by line like:  
ex:  
pm.expect(pm.globals.get(“Actualvalue1”)).to.equal(pm.globals.get(“Expectedvalue1”));  
pm.expect(pm.globals.get(“Actualvalue2”)).to.equal(pm.globals.get(“Expectedvalue2”));

what if we have more then 10k values?  
If i save them in a file then compare two files, in the case there is an error, the test will fail but i will have to check line by line for errors.  
What is the best solution?  
Thank you

---

<div class="post-metadata">

**Author:** ![khan\_aktas](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/khan_aktas/32/8816_2.png) [@khan\_aktas](https://community.postman.com/u/khan_aktas)\
**Post date:** [June 26, 2021, 11:17pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/2 "2021-06-26T23:17:47Z")

</div>

Strange case, 10k values… are they unique? or its just a true/false? Can you provide some examples of responses?

---

<div class="post-metadata">

**Author:** ![ps198478320](https://avatars.discourse-cdn.com/v4/letter/p/5fc32e/32.png) [@ps198478320](https://community.postman.com/u/ps198478320)\
**Post date:** [June 27, 2021, 12:45am UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/3 "2021-06-27T00:45:36Z")

</div>

You see these values? there are more than 10 000 values.  
each is differents.  
like  
Atualvalue1 = abc123  
Actualvalue2 = qwe321  
…  
…  
what i did is to save the response body in a variable and then parse for each value.

pm.expect(pm.globals.get(“Actualvalue1”)).to.equal(pm.globals.get(“Expectedvalue1”));  
pm.expect(pm.globals.get(“Actualvalue2”)).to.equal(pm.globals.get(“Expectedvalue2”));

---

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [June 27, 2021, 3:53pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/4 "2021-06-27T15:53:42Z")

</div>

How does the values look like in response

---

<div class="post-metadata">

**Author:** ![ps198478320](https://avatars.discourse-cdn.com/v4/letter/p/5fc32e/32.png) [@ps198478320](https://community.postman.com/u/ps198478320)\
**Post date:** [June 27, 2021, 5:08pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/5 "2021-06-27T17:08:35Z")

</div>

The response is like:

> [  
> {  
> “City”: “Paris”,  
> “Name”: “Bastille”  
> “Place”: “Rue”,  
> “France”: “true”,  
> “SpeedLimit”: “true”  
> },  
> {  
> “City”: “Tokyo”,  
> “Name”: “Tomo”  
> “Place”: “Rue”,  
> “France”: “false”,  
> “SpeedLimit”: “false”  
> },  
> {  
> “City”: “Santiago”,  
> “Name”: “Hall Brooks”  
> “Place”: “calle”,  
> “Panama”: “true”,  
> “SpeedLimit”: “true”  
> }  
> ]

Here i put only 3 data.  
In the real example there are more than ten thousand data.  
i need to validate each data like:  
The first City == Paris  
The second City == Tokyo  
The first Name == Paris  
The second Name == Tomo  
…

---

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [June 27, 2021, 6:37pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/6 "2021-06-27T18:37:51Z")

</div>

```auto
actualResponse = [

    {

        "City": "Paris",

        "Name": "Bastille",

        "Place": "Rue",

        "France": "true",

        "SpeedLimit": "true"

    },

    {

        "City": "Tokyo",

        "Name": "Tomo",

        "Place": "Rue",

        "France": "false",

        "SpeedLimit": "false"

    },

    {

        "City": "Santiago",

        "Name": "Hall Brooks",

        "Place": "calle",

        "Panama": "true",

        "SpeedLimit": "true"

    }

]

expectedResponse = [

    {

        "City": "Paris",

        "Name": "Bastille"

    },

    {

        "City": "Tokyo",

        "Name": "Tomo"

    },

    {

        "City": "Santiago",

        "Name": "H Brooks"

    }

]

let output = actualResponse.filter(function callbackFn(element, index, array) {

    if (element["City"] === expectedResponse[index]["City"] && element["Name"] === expectedResponse[index]["Name"]) {

        return false

    } else {

        console.log(`There was unequal values at the index location ${index} `)

        console.log("value : " + JSON.stringify(element, null, 2), "other : " + JSON.stringify(expectedResponse[index], null, 2))

        return true

    }

})

console.log(output)

pm.test("Body is correct", function () {

    pm.expect(output).to.be.empty

});

```

just store the expected values as array and then use is filter. This isfilter returns the unequal values, if there is no unequal values then returns empty array. so we are validating the returned output is empty

---

<div class="post-metadata">

**Author:** ![ps198478320](https://avatars.discourse-cdn.com/v4/letter/p/5fc32e/32.png) [@ps198478320](https://community.postman.com/u/ps198478320)\
**Post date:** [June 27, 2021, 8:02pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/7 "2021-06-27T20:02:21Z")

</div>

Thank you @praveendvd .  
Let me try your solution, i will get back to you.

---

<div class="post-metadata">

**Author:** ![ps198478320](https://avatars.discourse-cdn.com/v4/letter/p/5fc32e/32.png) [@ps198478320](https://community.postman.com/u/ps198478320)\
**Post date:** [June 29, 2021, 2:01pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/8 "2021-06-29T14:01:22Z")

</div>

Hi @praveendvd  
it returns TypeError: actualResponse.filter filter is not a function

---

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [June 29, 2021, 2:12pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/9 "2021-06-29T14:12:51Z")

</div>

filter is a method for array , make sure actualResponse is array

---

<div class="post-metadata">

**Author:** ![ps198478320](https://avatars.discourse-cdn.com/v4/letter/p/5fc32e/32.png) [@ps198478320](https://community.postman.com/u/ps198478320)\
**Post date:** [June 29, 2021, 2:19pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/10 "2021-06-29T14:19:31Z")

</div>

Yes it is in array but i stored in a variable.  
inside the variable it is like:

> [  
> {  
> “City”: “Paris”,  
> “Name”: “Bastille”  
> },  
> {  
> “City”: “Tokyo”,  
> “Name”: “Tomo”  
> },  
> {  
> “City”: “Santiago”,  
> “Name”: “H Brooks”  
> }  
> ]

---

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [June 29, 2021, 2:24pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/11 "2021-06-29T14:24:59Z")

</div>

`actualResponse = JSON.parse(pm.variables.get("variablename"))`

in variable it might be stored as string first parse it to make it an array

---

<div class="post-metadata">

**Author:** ![ps198478320](https://avatars.discourse-cdn.com/v4/letter/p/5fc32e/32.png) [@ps198478320](https://community.postman.com/u/ps198478320)\
**Post date:** [June 29, 2021, 2:32pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/12 "2021-06-29T14:32:10Z")

</div>

Correct, it works fine now, Thank you for your help.

---

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [June 29, 2021, 6:24pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/13 "2021-06-29T18:24:45Z")

</div>

No issues 😌 welcome to the community ❣

---

<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:** [December 12, 2024, 12:57pm UTC](https://community.postman.com/t/how-to-assert-multiple-value-like-more-than-10k-values/25205/14 "2024-12-12T12:57:15Z")

</div>

Closed on December 12, 2024, 12:57pm UTC

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