https://cypress.io logo
Any way to make a dummy intercept/alias
# i-need-help
c
Hello. If I have a conditional, aliased intercept in one custom command and want to cy.wait on it in another custom command, is there a way to make a dummy alias or intercept that I can wait on elsewhere that will immediately resolve? Basically what I want is something that acts like Promise.resolve() for cy.wait("@alias") if the intercept didn't actually get set. Thanks.
n
you could try
cy.wrap(false).as('alias')
then later
cy.get('@alias').then(alias => { if (alias) do_something })
g
If you buy my paid course https://cypress.tips/courses/network-testing you could ask this question with details and I would prepare a lesson explaining it
c
@nutritious-honey-65632, thanks. I guess that pattern looks more promising for conditionally aliasing an element, rather than an intercept. I want to be able to
cy.wait
the alias, but have the dummy immediately resolve. I'll play around with it.