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

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

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