#How to test emit listener?
7 messages · Page 1 of 1 (latest)
Does this help?
It doesn't say how to do it IMO. Am I missing something?
I mocked the IPC according to it and it's fine testing a call to the rust part. Now I want to test the listen - so I need to mock the emit part which is coming from Rust
Oh - I tried this:
const eventCallbackId = `_${args.message.onEventFn}`;
const eventEmitter = window[eventCallbackId];
But it doesn't work. args.message is undefined.
So I think I misread your initial question. I don’t think we have a mocking service for event listeners, but I may be mistaken. Would you be so kind as to file a feature request? Thankyou!
What I'm doing now is mock listen itself, get the Callback and fire it when the IPC mock resolves. It is cumbersome and thought there might be a "cleaner" way to do it.
Adding a feature request. Thanks!