Getting started with API testing using Cypress
Are you new to Cypress and excited to learn about API testing with Cypress? Then this article is for you!
I never knew that Cypress has a separate function to do API call. Yes, we can do all API call with cy.request(). Before proceeding further, you need to install Cypress in your system. Please refer here to install cypress — Cypress installation.
Sign up weather API:
To demonstrate this API call, I have made use of public weather API and you can sign up here.
Once you are done, you will get a secret API access key which you can use it to access the data. Try to call the same API with POSTMAN manually to confirm whether it is working fine.
Cypress command to make API call:
To make Cypress API call, Cypress has provided command cy.request() and below is the syntax provided in the Cypress documentation,
cy.request(url)
cy.request(url, body)
cy.request(method, url)
cy.request(method, url, body)
cy.request(options)