DEV Community

Discussion on: Browser extension - Deploy your extension

Collapse
 
pabuisson profile image
Pierre-Adrien Buisson

Very interesting series Quentin, thanks for sharing! I'm wondering what you think is the best way to test browser addons? On my own browser addon, I use a few unit tests, but integration tests are rather painful to setup (in fact, I never got them to run properly and more or less gave up for now... and there is not much documentation or tutorials about this anywhere, which makes it a tad harder). And unit tests are not enough to make sure the addon keeps on working as expected :)

Collapse
 
qmenoret profile image
Quentin Ménoret

It really depends on what the addon is for. For something as simple as the one I described here, I'd say unit tests are enough. But if your addon becomes complex, you'll have to go with e2e testing. And that's not exactly funny. Let's say you want to test on Chrome for instance. It's possible to load your extension, but not in headless mode. So if you want to run then on a CI you'll have to either use a platform such as BrowserStack, or setup a Xvfb (fake display server) to run an actual Chrome.
Then extensions mostly interact with other websites, but I'm not sure you actually wants the flakiness of opening actual websites in your tests? So maybe you'll mock them? But if you do so, you won't catch it when they update and break your extension?
So, to conclude: it's really hard to test, and going further than unit tests have a high cost IMO