https://cypress.io logo
I am currently trying to wait for a request to fin...
# e2e-testing
c
I am currently trying to wait for a request to finish, to test a
cy.get(...)
. My API, which I would like to intercept is on a different host (e.g.
https://example-api.azurewebsites.net/something/something2/MyFunction/something3/something4
), than my website host
http://localhost:4200
. I tried
cy.intercept
with an alias. But either I get an authorization error (when using
https://...
for
hostname
) or my
cy.wait(@getMyFunction)
runs into a timeout.
Copy code
ts
it('...test', () =>{
  cy.intercept({
    method: 'GET',
    url: '**/MyFunction/*',
    hostname: 'https://example-api.azurewebsites.net',
  }).as('getMyFunction');

  cy.visit('/').wait('@getMyFunction', { timeout: 30000 })
  cy.get('some-content');
});
Cypress finds the alias, the
intercept
is not correctly configured. But I have no idea, what to change, to make it work. Does anyone know, what I am doing wrong in this procedure?