Cypress.on('url:changed', (url) => {
if (!url.includes('something')) return;
cy.intercept({
method: 'GET',
url,
}).as('endpoint');
});
The above gives error
Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
The command that returned the promise was:
cy.visit()The cy command you invoked inside the promise was:
cy.intercept()
And fails.
The code is run in support/index.js before everything else runs. I want to prepare the interceptor for future calls which will happen once a particular page opens.
Anyone ever ran promises inside Cypress events?