Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

503
Vistas
Cypress: Getting "Parameter supplied to cy.request() contained a circular reference at the path specWindow" when using command inside a command

I have 2 different commands that I intend to use inside each other. The 1st one generates an object and the second one uses it to send as body of a cy.request. They look like this

Cypress.Commands.add("objectGeneration", function(search, method, block){
  let body = {}
  if(search === 'something') {
    body.search = search,
    body.method = method,
    body.block = block
  }
  return body
})


Cypress.Commands.add("sendReq", (search, method, block) {
  cy.request({
    method: 'POST',
    URL: 'URL',
    body: cy.objectGeneration(search, method, block)

  })

})

In my test I call them this way (where each testCase variable comes from a helper object I import into my test case.

it("Name of the test", function(){
  cy.sendReq(testCase.search, testCase.method, testCase.block).then((resp => {..}...
})

When trying to run this, I get the following Cypress error:

The body parameter supplied to cy.request() contained a circular reference at the path specwindow body can only be a string or an object with no circular references.

All of this would work fine when objectGeneration was just a function and not a command. I think my issue might have to do with the return in a command. Any suggestions? Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Ran into a similar issue trying to send a Decimal value (using decimal.js) as part of the body.

In the end I serialized the object myself and sent it this in the request. In your case I would think that this should also work:

Cypress.Commands.add("sendReq", (search, method, block) {
  const serialized = JSON.stringify(cy.objectGeneration(search, method, block)) 

  cy.request({
    method: 'POST',
    URL: 'URL',
    body: serialized,
    headers: { 'Content-Type': 'application/json' }
  })
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda