Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cypress. Why is my route alias not matching?

Tags:

cypress

My POST request to ocr/receipt is never matched. I've...

  • created a route, matching **/ocr/**, specifying POST, and given it an alias.
  • called wait() with a long timeout.

I can watch the request complete in the network pane while the wait spinner turns happily in the test pane. Why is Cypress not matching this route?

beforeEach(function () {
    cy.route('POST','**/ocr/**').as('ocr');
});
it('Création frais depuis le bouton « appareil photo »', function () {
    cy.get('.in-progress').first().click()
    cy.wait('@ocr', {'timeout':15000});
    cy.get('#grpChoices > :nth-child(1)').click();
});

enter image description here

like image 801
bbsimonbb Avatar asked Apr 03 '18 15:04

bbsimonbb


Video Answer


1 Answers

Well who would have guessed. Method is case sensitive, and it only works in lower case. So...

route('post','**/ocr/**').as('ocr')

fixed it. The doc won't help you.

The other recurring reason for routes not triggering is if your app uses the fetch api. Fetch is not compatible with cypress.

like image 98
bbsimonbb Avatar answered Sep 23 '22 01:09

bbsimonbb