title: How to test a bad request in cypress
body: <p>I am testing logging in POST method in cypress with incorrect credentials. this returns 400 bad requests which I need to test.</p>
  <p>This is what I have:</p>
  <pre class="lang-js prettyprint-override"><code>describe('Login API Test - Correct user login', () =&gt; {
    it('Validate the header', () =&gt; {
      cy.request({
        method: 'POST',
        url: 'https://myrAPI',
        auth: {
          username: 'user@user',
          password: 'user123',
        },
        headers: {
          'Authorization': 'Basic dXNlckB1c2VyOnVzZXI=',
          'Content-Type': 'text/plain'
        }
      }).then((response) =&gt; {
        // expect(response.body).to.exist // true
        // expect(response.body).('User.Access: Exception occured:User.Access : CheckUser: Exception occurred:Error with Authentication Header. result =') // true
        // expect(response.headers).should.contain('text/plain; charset=utf-8')
        // expect(response.body).statusCode.should.equal(400)
        response.status.should.equal(400)
        //expect(response).to.have.property('headers')
      })
    }})
  </code></pre>
  <p>The request that was sent:</p>
  <pre class="lang-none prettyprint-override"><code>Method: POST
  URL: https://myapi
  Headers: {
    &quot;Connection&quot;: &quot;keep-alive&quot;,
    &quot;Authorization&quot;: &quot;Basic dXNlckB1c2VyOnVzZXIxMjM=&quot;,
     &quot;Content-Type&quot;: &quot;text/plain&quot;,
     &quot;user-agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 
  (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36&quot;,
    &quot;accept&quot;: &quot;*/*&quot;,
    &quot;accept-encoding&quot;: &quot;gzip, deflate&quot;,
    &quot;content-length&quot;: 0
    }
  </code></pre>
  <p>This is the response I get:</p>
  <pre class="lang-none prettyprint-override"><code>Status: 400 - Bad Request
   Headers: {
    &quot;content-length&quot;: &quot;239&quot;,
     &quot;content-type&quot;: &quot;text/plain; charset=utf-8&quot;,
   &quot;request-context&quot;: &quot;appId=cid-v1:d994e38c-9493-4dd6-ac8c-5395bb9ce790&quot;,
     &quot;date&quot;: &quot;Tue, 02 Jul 2019 13:35:18 GMT&quot;
  }
   Body: User.Access: Exception occured:User.Access : CheckUser: Exception occurred:Exception when checkin...
  </code></pre>
  <p>I'd like to know what is in the response or body</p>