Open pureooze opened 6 years ago
If it is just a case of missing support, I think we can add it. If you want I can make a PR to add these mocks, I looked over the existing source code and I think I understand how this library works.
Yes, please do! I'd love a PR to add support. 🔨
I made the mocks for the windows api (see here) but I just had a question about how jest-webextension-mock
works 🤔 .
In the documentation for the chrome.tab.get
API the callback is passed a Tab
object. But when I look in the mocks I see:
export const tabs = { get: jest.fn((id = '', cb = () => {}) => cb({})), ... }
So I have two questions:
browser.tabs.get
in our code we wont have anything returned?If the code being tested actually passes in a callback it will expect a Tab object with certain properties but from what I can tell it will always get an empty object?
I'm guessing you'll need to fix that and it was just stubbed out.
How does this deal with the difference between the browser. and chrome. APIs? From what I understand the WebExtension API expects promises while the chrome API expects callbacks. So if I understand this correctly if we call
browser.tabs.get
in our code we wont have anything returned?
In a number of places where this is a concern we use a pattern like this:
Any progress on this? :)
First of all thanks for making this library, it seems really promising!
I was trying to use this library in my extension and followed the instructions in the README but I keep getting this error when I run certain tests:
I think the issue is just that there are no mocks for this part of the API yet (correct me if I am wrong). Let me know if this is actually an issue or I am just misusing the library.
If it is just a case of missing support, I think we can add it. If you want I can make a PR to add these mocks, I looked over the existing source code and I think I understand how this library works.
Thanks!