Another assertion test

I read alot in the forum in this week but i still struggle with assertion and nested objects. There were good tutorials but i was not able to transfer the knowlage.

I’d like to read the value in the arrays like for accounting and consultation

This is a example of the body response:

The department objects has 8 arrays from 0 to 7.

I wrote a test but its “hardcode” not dynamic if something changes later.

I’d like to find the array by name = “marketing” or other name = “…”

my idea was using this structure which i found in the forum Assertions for API Test scripts

but it didn’t worked for my because in almost all of the 8 arrays is the name key.

      for(let key in{
            accountingValue =[key].name.tasks.accounting;
    pm.test("value of accounting", function(){
1 Like

@kite0 - can you use filter() or find()?

let marketingDepartment = => { return === "marketing" })
let accounting = marketingDepartment.tasks.accounting

Thank you it worked well that way :slight_smile:
i just i have to make it for each array with find function. think there are diffrent ways but its a good start.

in the test my result is 8 times “passed” like accounting status is false

can i add a comment or description to the “Test Results” ? Now all results look the same for me. I have already set enviorment variables to see if for marketing = accounting status is false etc. but would be nice also see in a quick overview for test results