I am currently conducting API testing.
My objective is to verify the presence of a specific name within the API response.
The data from the API response is structured in an array format.
Despite my intention to check for the existence of the name "activeadmin," I encountered an error that reads: The Repository activeadmin exists | AssertionError: expected 'pineapple' to deeply equal 'activeadmin'
I am puzzled as to why the comparison is being made with the second name value in the array instead of the first one.
Below, you can find the code snippet I have been working on:
let jsonData = pm.response.json()
pm.test('The Repository activeadmin exists', () => {
_.each(jsonData, (item) => {
pm.expect(item.name).to.eql('activeadmin')
})
})
I attempted to use item[0].name, but this resulted in an error stating that the name property is undefined.
Here is an extract of the API Response:
[
{
"id": 2847287348,
"node_id": "sdhjaskdhkjasdhjashd",
"name": "activeadmin",
"full_name": "apple/activeadmin",
"private": false
},
{
"id": 2847287348,
"node_id": "sdhjaskdhkjasdhjashd",
"name": "pineapple",
"full_name": "apple/activeadmin",
"private": false
},
{
"id": 2847287348,
"node_id": "sdhjaskdhkjasdhjashd",
"name": "orange",
"full_name": "apple/activeadmin",
"private": false
} ]