Thanks Murillo for this great post. This was an inspiration for me to write the first API test using Cypress.
One of the challenges I am facing, if you could help me with is I have a fixture file(json) which I use to send API Requests and also validate the responses.
But when one of the "expect" assertion fails, the remainder of the assertions are skipped AND it also doesn't read the 2nd test data from the fixture file.
How can I fix this so that even if one of the first fixture data fails, I am able to continue with the rest of the assertions in the 1st fixture data and also be able to go to the next test data entries(2nd, 3rd...nth) in the fixture file.
To be more specific I would want to be able to continue test execution with the rest of the data from the fixture file when an assertion fails with one of the test data.
Ex: I have this json file as fixture,
when I assert "email" from the first fixture data which is invalid cypress throws an error and stops execution.
But I would like it to continue with the assertion for age and also the data from 2nd and 3rd fixture data and not just stop the entire execution at the 1st failure
[
{
"name": "valid1",
"email": "invalid1",
"age" : valid
},
{
"name": "valid2",
"email": "valid2",
"age" : valid
},
{
"name": "valid3",
"email": "valid3",
"age" : valid
}
]
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks Murillo for this great post. This was an inspiration for me to write the first API test using Cypress.
One of the challenges I am facing, if you could help me with is I have a fixture file(json) which I use to send API Requests and also validate the responses.
But when one of the "expect" assertion fails, the remainder of the assertions are skipped AND it also doesn't read the 2nd test data from the fixture file.
How can I fix this so that even if one of the first fixture data fails, I am able to continue with the rest of the assertions in the 1st fixture data and also be able to go to the next test data entries(2nd, 3rd...nth) in the fixture file.
To be more specific I would want to be able to continue test execution with the rest of the data from the fixture file when an assertion fails with one of the test data.
Ex: I have this json file as fixture,
when I assert "email" from the first fixture data which is invalid cypress throws an error and stops execution.
But I would like it to continue with the assertion for age and also the data from 2nd and 3rd fixture data and not just stop the entire execution at the 1st failure
[
{
"name": "valid1",
"email": "invalid1",
"age" : valid
},
{
"name": "valid2",
"email": "valid2",
"age" : valid
},
{
"name": "valid3",
"email": "valid3",
"age" : valid
}
]