Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda