Check API query params on Cypress

tags:  cypress, javascript


When developing a new feature in frontend, sometimes we want to assert that the data sent to the API is valid, not only the effects after the API is resolved.

In CypressCypress
Common commands in Cypres

Type in an input

cy.get('[data-test-input="input"]').type('Example text')

Assert sent data to API
pathname: "/categories",
method: "POST",
, we can intercept the API with the following syntax:

    pathname: "/api/posts",
    method: "POST",
  { fixture: "api/post" } // JSON fixture

We usually use the same intercept syntax to a test suite, so we don't want to override it lots of times.


When we are using the same intercept syntax in a test suite or in different test files, the best approach is the following syntax:

cy.wait("@createPost").then(({ request }) => {


  • What could be a solution for test query params when the API isn't intercepted? (proper E2E tests against staging) Is it needed?
  • Add syntax for checking query params inside intercept syntax.