In my Typescript file I am dispatching a custom event when some information is loaded to the html page.
dispatchEvent() {
const myCustomEvent = new CustomEvent('myCustomEvent', {
id: 123,
});
this.dispatchEvent(myCustomEvent);
}
I can see that the event is dispatched correctly in console so I think I don't need to dispatch it also from Cypress but maybe I'm wrong. Any ideas how to verify that the custom event is emitted and also has the desired data?
Component tests
There is an example using
change
event here Angular examples which uses thecreateOutputSpy
helper utility function fromcypress/angular
.You should just be able to substitute your custom event name
e2e tests
If you are performing e2e tests instead of component tests, an event spy might be configured something like this: