- Api Alurapic
Dados da API:
CypressError:
cy.request()
failed on:
http://localhost:3000/user/login
The response we received from your web server was:
401: Unauthorized
This was considered a failure because the status code was not 2xx
or 3xx
.
If you do not want status codes to cause failures pass the option: failOnStatusCode: false
describe('Api Alurapic', () => {
it('Dados da API', () => {
cy.request({
method: 'POST',
url: 'http://localhost:3000/user/login',
body: Cypress.env()
}).then((res) => {
expect(res.status).to.be.equal(200)
expect(res.body).is.not.empty
expect(res.body).to.have.property('id')
expect(res.body.id).to.be.equal(3)
})
})
})describe('Api Alurapic', () => {
it('Dados da API', () => {
cy.request({
method: 'POST',
url: 'http://localhost:3000/user/login',
failOnStatusCode: false,
body: Cypress.env()
}).then((res) => {
expect(res.status).to.be.equal(200)
expect(res.body).is.not.empty
expect(res.body).to.have.property('id')
expect(res.body.id).to.be.equal(3)
})
})
})