I am currently trying to assert the items in an array to be true. This is how the test is currently written.
it.only('GET getUserPermissions', () => {
cy.request({
method: 'get',
failOnStatusCode: false,
log: true,
url: 'https://someurl.org/api/getUserPermissions?=1234',
headers: {
//'accept': 'application/json',
'authorization': 'Bearer ' + login.jwt
},
response: []
}).then((response) => {
console.log(response.body)
assert.equal(response.status, 200)
expect(response.body).to.not.be.null
console.log(response)
expect(response.body).to.contain(
[[[43239,"admin",136,4],[43257,"database.events",165,4],43258,"deadbeat.list",113,4],43266,"navigation",6,4],[43267,"object",19,4],[43272,"qa.object",31,4],43278,"user",5,4]])
})
})
The response I get in the Cypress runner looks like this:
TEST
1 REQUEST GET 200 https://https://someurl.org/api/getUserPermissions?=1234
2 -ASSERT expected 200 to equal 200 --Pass
3 -ASSERT expected [ Array(7) ] not to be null --Pass
4 -ASSERT expected [ Array(7) ] to include [[[43239,"admin",136,4],[43257,"database.events",165,4],43258,"deadbeat.list",113,4],43266,"navigation",6,4],[43267,"object",19,4],[43272,"qa.object",31,4],43278,"user",5,4]] --Fails
When I test this endpoint in Postman, I get just the array [], but when I run this in the runner, the assertion fails, it's not returning the array in the same manner. How do I parse the response to check the values? These are user permissions and I need to ensure that the user has the correct permissions for the correct object.
expect(response.body).to.deep.equal([[[43239,"admin",136,4],.... - user14783414