Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

501
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!