Closed MatonAnthony closed 5 years ago
@MatonAnthony hi!
You should define behavior for browser.runtime.connect
.
Before your test
browser.runtime.connect.returns(require('your-port-object-stub.js'))
also there is a solution in https://github.com/acvetkov/sinon-chrome/issues/50
Hello,
I'm not sure to understand everything yet but I'm currently trying to write test on my webextension using sinon-chrome and I got difficulties because it stubs
browser.runtime.connect()
to undefined wherebrowser.runtime.connect()
returns aruntime.Port
which contains event and methods.A workaround like this is working for a test file when I'm testing if thing arrives on the event
But on another test file I don't manage to get it to work and I don't really understand how I'm supposed to do.
Here is my method
And here is my "test"
Javascript wise, I'm pretty sure there is an issue with scope but I don't really have any idea about how to do in an other way.
My experience with testing is very limited (and considering how important it is, I'm kinda sad about it), sorry if it's a very simple question.