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

371
Vistas
How to use a specific url over a glob in cy.intercept()?

I have two intercepts:

cy.intercept(
  'GET',
  '**/foo/*',
 {
  fixture: 'foo.json'
 }
)

and

cy.intercept(
  'GET',
  '**/foo/bar',
 {
  fixture: 'bar.json'
 }
)

I always get the response from the first intercept. Changing the order of them in the code doesn't matter. What am I doing wrong?

How do I get a response from a specific url over a glob one?

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

0

You can conditionally return different fixtures based on the response, using req.reply()

cy.intercept(
  'GET',
  '**/foo/*',
  (req) => {
    req.reply({
      status: 200,
      fixture: req.url.endsWith('/bar') ? 'bar.json' : 'foo.json'
    });
  });

In the above, we're doing a simple ternary to determine whether to return bar.json or foo.json. If there is more complicated logic, you could extract that part out to a constant above the req.reply().

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