Skip to content
Advertisement

How to test a bad request in cypress

I am testing logging in POST method in cypress with incorrect credentials. this returns 400 bad requests which I need to test.

This is what I have:

JavaScript

The request that was sent:

JavaScript

This is the response I get:

JavaScript

I’d like to know what is in the response or body

Advertisement

Answer

The answer to your question is in the error message:

If you do not want status codes to cause failures pass the option: ‘failOnStatusCode: false’

So pass failOnStatusCode: false to not fail on bad status codes:

JavaScript
Advertisement