I have a scenario where I need to check if the API endpoint was invoked or not.
I tried to use this code but it seems like it is getting always nothing:
let interceptFlag = false
cy.intercept(`**PATH/${search}/trigger`, (req) => {
interceptFlag = true
req.continue((res) => {
interceptFlag = true
})
})
cy.wrap(interceptFlag).should('eq', true)
I even tried this but always getting nothing:
cy.intercept(`**PATH/${search}/trigger`, cy.spy().as("getSMSCall"));
cy.get('@getSMSCall').should('have.been.called');
I am thinking that there is a delay. May I know how can I put some delay there to wait for the endpoint be invoked and that delay should also be working in the opposite scenario as well, which is API endpoint should not be called.