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

167
Vistas
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 Respuestas
Responde la pregunta

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 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