-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing onMessage listeners #136
Comments
Looks like we check that we call the callback jest-webextension-mock/__tests__/tabs.test.js Line 120 in f66b8b8
And yes, looks like you're right that we don't pass it along jest-webextension-mock/src/runtime.js Line 18 in f66b8b8
Can you check that this is the correct behaviour and open a PR fixing the library? thx! |
After some reading on MDN, it seems like the callback itself is deprecated, so there's probably no point in adding it now. The expected behavior would be for everything to be Promise-based, but that would likely be a major revision. |
We handle promises but we probably don't do it correctly jest-webextension-mock/src/runtime.js Line 23 in f66b8b8
|
I'm attempting to test my onMessage listeners, but I keep getting the error TypeError: sendResponse is not a function. It appears that the implementation of runtime.sendMessage accepts a callback as the second argument, but doesn't actually pass it to the listener.
I've also tried the MDN-recommended method of returning a promise from the onMessage listener and using .then() from runtime.sendMessage, but this doesn't work either.
My workaround thus far has been to export the listener function and hit it directly. This works but is less than ideal.
The text was updated successfully, but these errors were encountered: