I'm testing a form in a Laravel/Vue/Inertia application that can select from a list of users. The form adds a new user (an XHR post) to the database. The Laravel controller then redirects back to the form (an XHR GET). The form's user menu now contains the updated list of users.
This works manually. But when I test in Cypress, it fails. I set up an interceptor for each XHR request. But even though the redirect takes place, the second XHR request (the one aliased as "@loadPage") is still spinning around in the Cypress spec window. Even if I wait 10 seconds, it doesn't finish.
The relevant part of the Cypress spec looks like this:
cy.get('#first_name').type('John')
cy.get('#last_name').type('Coltrane')
cy.get('#email').type('coltrane@myfavoritethings.com')
cy.get('#netid').type('trane')
cy.intercept('POST', '/auth/user').as('addUser')
cy.intercept('GET','/auth/project/create').as('loadPage')
cy.get('#add-user-form').submit()
cy.wait('@addUser')
cy.wait('@loadPage')
//cy.wait(5000)
cy.contains("New user")
cy.contains('Coltrane')
I expect the page to contain 'Coltrane' in the select menu. But it doesn't -- except when you test the page manually. The XHR GET for this page will include an update to Inertia's props.users
. But during the Cypress test, the XRH request never completes (even with the interceptor).
The Cypress spec results window looks like this: