Getting started with API testing using Cypress

Siddharth Murugan
3 min readSep 19, 2021
API call with Cypress.io

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.

Postman screenshot with 200 status code

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)

--

--

Siddharth Murugan
Siddharth Murugan

Written by Siddharth Murugan

Programmer who loves to do things creatively. #automationTester by profession #javascript #nodejs #reactjs

No responses yet