jest-webextension-mock
jest-webextension-mock copied to clipboard
feat: add tabs.onRemoved and tabs.onCreated mocks
Hello 👋
I'm a core contributor to Adblock plus and i'm experimenting with using this library to help us write more unit tests. I noticed that it misses a few methods on the tabs API that we would need to make use of, also noticed the issue #107 where somebody else encountered a similar problem.
I took a (very) quick stab at adding those missing methods:
I followed the existing pattern that exists with onUpdated
, i.e. I did not implement mock functionalities to make the addListener
, removeListener
and hasListener
work (we could for an example keep track of the functions added as listeners and return correct values in hasListener
), but simply mocked them with jest.fn()
.
Looking forward to feedback to on this 🤞
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.51%. Comparing base (
c0b1bbf
) to head (6d79ad5
). Report is 1 commits behind head on main.
:exclamation: Current head 6d79ad5 differs from pull request most recent head c1ce3ba. Consider uploading reports for the commit c1ce3ba to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## main #180 +/- ##
=======================================
Coverage 99.51% 99.51%
=======================================
Files 15 15
Lines 207 207
Branches 43 43
=======================================
Hits 206 206
Misses 1 1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Hey @clarkbw 👋 Anything I can do to get this merged?
I'd actually love to contribute more to this repo, I think it's super useful for extension developers 😊