Cypress.on(...)'s undocumented parameter when registering app events' handlers #26574
Unanswered
vstreltsova-evinced
asked this question in
Questions and Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description of my task
For catching url-changes in my application I listen to the Cypress' app event called
url:changed
(more info here https://docs.cypress.io/api/cypress-api/catalog-of-events#App-Events):Cypress.on('url:changed', urlChanged);
and my
urlChanged
-method is asynchronous.I found an undocumented parameter when registering an event-handler - it's called async:
Cypress.on('url:changed', urlChanged, { async: true });
When I use it like above my
urlChanged
-method is executed synchronously. Seems in fact all the method'sawait
's just started working after specifying that.Questions
async
-parameter as true we get a synchronous execution of the event-handler method? Since there're no information about this parameter in the documentation, I'm not sure what behaviour to expect.Cypress.on
accepts additional options:
- there the EventEmitter2 library is involved. Is it correct that under the hood the Cypress uses this library? Can I rely on the library's documentation then? I found a description of the async-parameter in the library's documentation: https://github.com/EventEmitter2/EventEmitter2#emitteronevent-listener-options-objectbooleanasync
-parameter is valid to use for managing event-handlers' execution, probably it should be included to the Cypress' documentation?Beta Was this translation helpful? Give feedback.
All reactions