Want to try my first API test with Cypress, any recommendation when the URL is not changing?

Hi all,

I want to try an example like this one API Testing with Cypress - DEV Community cypress test with API calls inside. No sure if this is always possible event if the URL is not changing ?

I’m new to API and cypress, so it could be a silly question, or not possible combination in this case.

I want to try an API test (also using cypress)
steps I want to make after login

  1. click into “create job”
  2. click into “post job ad”
  3. fill all the data (a new window will be displayed after that)
  4. check if it’s added correctly

My question how to translate this into API and the URL is not changing always the same, so when I put it in postman I can’t map things together

2 Likes

I think what you are calling is a regular URL (in postman) and not the API.
The URL doesn’t need to change in order to call API’s, 1 page can contain multiple API’s.

Do you have a swagger-file from the application that you are testing?
If you go to DevTools and the network tab, you can also see the API’s popping up.

Mark made a short video about how to copy api’s from the devtools to Postman by copying it as bash (cmd) & importing it into postman. But I can’t seem to find it. So help me out here @mwinteringham XD

EDIT found it: Call for Content - Testing tips for the Ministry of Testing site


I don’t think there will be an API for the 1. click into “create job” & 2. click into “post job ad” unless it will generate some sequence code. (I think they are just buttons that bring you to a different page?)

So what you want to test through the API is more something like:

    1. Login to the app
    1. fill all the data (a new window will be displayed after that)
    1. check if it’s added correctly
2 Likes

Thanks a lot @kristof for all the details, I have a better understanding now :slight_smile: !
I tried it, but it seems that no GET / POST are available.

I discovered that firebase cloud functions have a a different hostname then the web itself

I tried the nice tip, it seems like every field is having a separate API !

Just I wanted to try it by curiosity after some API tutorials, maybe not the right example to play with APIs and learn in practice.

2 Likes

In the network tab, you’ll find all kinds of requests, even images. :stuck_out_tongue:
It sometimes takes a bit to find the right one, most of the times API’s actually have the name “api” in them.

So you can filter on “api” … but it’s not always the case

2 Likes

oh I didn’t know that :slight_smile: cool exploration !

3 Likes

Yes, once you learn to explore the network tab, you can’t go back. The knowledge will be with you as a tester :slight_smile: GL!

3 Likes