I am working on an extension for both Chome and Firefox, and in order to test for regressions, I am creating functional tests which will run on a CI pipeline (namely Github Actions)
For Chrome, it’s easy. I use puppeteer, start the browser with the --load-extension flag pointing to my dist folder, and it works. I just write puppeteer tests.
But I have been struggling with firefox. It doesn’t seem to simply accept the dist folder. Going to about:debugging#/runtime/this-firefox and clicking “load temporary extension” is easy for a human, but my script can’t interact with the explorer at all. So then I try to compress it to a .xpi, but firefox complains that it’s an unverified extension therefore it’s banned. So then I tried to disable that in the about:config, but that does nothing, and I learn it only works in developer firefox. So I download developer firefox, point my puppeteer to use that executable, and finally it loads… and then I get a popup saying “are you sure?” and so now I’ve been trying to click “accept”…
There has to be a better way! It seems like I need to rethink my whole approach because it’s super hacky. Is there a way to have a web test framework (puppeteer, playwright) attach to web-ext? Because launching that from my dist directory works great! Or just in general, what is the preferred approach for this sort of testing for firefox?
Unfortunately Puppeteer and Playwright don’t support Firefox add-ons. Those tools are built on Chrome’s DevTools Protocol which isn’t fully supported in other browsers.
Forget the hacky workarounds! Use web-ext to launch Firefox, then connect your test runner via its debugger port. This is the preferred, stable approach.