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

171
Views
reset cypress config on rerunning tests

i want to reset config like when we refresh the browser every time cypress test runs. i am using

"content-type": "application/x-protobuf"

as default header but when one of my responses is json cypress change it to application/json by default.

this is my interceptor:

Cypress.Commands.overwrite('intercept', (originalFn, { method, url }, options) => {
  method = 'POST'
  url = `${Cypress.env('EXTERNAL_API')}/${url}`
  options = {
    ...options,
    headers: Cypress.env('DEFAULT_HEADER'),
  }

  return originalFn(method, url, options)
})

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have the problem. when i pass body instead of fixture in the interceptor , cypress forces the header to application/json. no way to change it. to solve the problem i passed my json file as a fixture and set my custom header according to that.

Cypress.Commands.overwrite('intercept', (originalFn, { method, url }, options) => {
  method = 'POST'
  url = `${Cypress.env('EXTERNAL_API')}/${url}`
  const isJsonHeader = options?.fixture?.toLowerCase()?.includes('.json') ? true : false
  options = {
    ...options,
    headers: isJsonHeader ? Cypress.env('JSON_HEADER') : Cypress.env('DEFAULT_HEADER'),
  }
  return originalFn(method, url, options)
})

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!