-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension testing in browser / puppeteer #534
Comments
I see the Firefox limitation as the bigger issue. Does Puppeteer support Safari and the other Chromium browsers? For the extension context limitation, the way I've approached similar limitations in the past is to include custom error tracking in test builds. For our situation it might be:
One benefit to Selenium is there's plenty of services like Browserstack that support it. However, there's probably services for Cypress et al as well now too Update 6/26: BrowserStack documentation on testing with extensions: https://www.browserstack.com/docs/automate/selenium/add-plugins-extensions-remote-browsers |
Chromium, ish… There seems to be this, but last updated in 2019: https://github.com/EasyWebApp/puppeteer-browser https://github.com/microsoft/playwright is the cross-browser alternative to Puppeteer, but there's even fewer documentation about extensions here. Maybe hacking around Safari is in its own league, I published 3/4 Safari extensions but the development/testing process is not clear yet, there's nearly zero documentation and you need to go through Xcode to do anything. Safari testing is more of a Mac developer task than a web extension one. |
|
Just a small note: it appears that everyone is testing the extensions by loading an intermediary page on Can you post a few examples of what you'd like to test? Maybe it will be easier for me to work towards that instead of just finding what's not possible. A full "first test" example would be great. |
@fregante thanks for the note. With the browser/puppeteer tests, at the beginning it's primarily going to be system tests / smoke tests to expose regressions in behavior (especially around corner cases like frames, etc.). I don't think we'll be calling background/content script methods directly Example smoke tests
Systems tests
Long-term, I also imagine the testing infrastructure might be used to detect breakages to foundations we've built for popular sites |
The two regressions in this ticket would also be good ones to do: #671 As part of the testing harness we will want/need to:
|
I think none of what you suggested is possible simply because:
Maybe we can get around the permission issue by adding the hosts in manifest.json, but that changes the loading behavior altogether and our expectations of our permissions and loading. I will still try, maybe the chromedriver will automatically accept any |
Gotcha, I think I understand that restriction better now. The interactions we have with the browser chrome are:
In the future we could potentially test these using an RPA tool (like UiPath, etc.). That's a small surface area though, that can be handled by manual testing for now (we will just need to write up some test checklists for the wiki) There's a very large testing surface area that don't require these. For example, instead of using the window alert brick, using another brick that affects the interface (e.g., highlight). So let's focus on those
Yes, I suspect we might have to do this. Fudging the permissions is totally reasonable to do. Thanks for commenting on w3c/webextensions#19! As we encounter more limitations, let's continue to add to the list there Initial Tests@fregante I think we should be able to do both of the following? The don't require using the browser chrome, but may require granting permissions via the manifest when running the test
|
Some notes:
Therefore, assuming a single build, to test a brick:
Do you think that with all these limitations and difficulty in the setup Selenium is still worth setting up (if UiPath is an alternative)? I think our options (which can be combined) are:
An additional option I could try would be to:
I'm not sure exactly what this would entail, but we're less likely to run into walls and hard limitations of Selenium/ChromeDriver. Maybe we can do unit testing + UiPath + mocked whole-extension tests. My knowledge about testing is extremely limited so correct me if I'm talking nonsense 😃 |
I might have found ways to:
|
To help move things along on the testing initiative, I started a POC branch for running Selenium tests as part of CI: #711 I invited your @pixiebrix.com email to our BrowserStack account. @fregante Could you take a swing at loading the extension into the remote browser (Chrome first) in the PR? In the meantime, I'll also start writing up a proposal for the other details. For example:
It uses the WebDriver API, so we can execute scripts, etc. So many things are possible, they're just annoying
I'm OK with this. For E2E tests, there's not much need to mock internal modules/responses. For the manifest, I think the only difference is pre-provisioning permissions?
This is going to be more trouble than it's worth, because we'd have to maintain parity with all the vendor quirks
Great! - we'll be creating a library of helpers using tribal knowledge like this. The Privacy Badger repository and the 1Password conference talk linked above are have some good nuggets
No worries! A lot of testing is framework-specific so there's a very large surface area and number of quirks to be aware of. We'll split the work into small chunks, as there will be places where it make sense for you to take the lead vs. where me (or someone else joining the team soon) should |
Co-authored-by: Todd Schiller <[email protected]>
I'll post here issues related to testing, so they can be tracked in one place for the time being.
I did some testing while working on #398, you can see that in fregante/content-scripts-register-polyfill#17
Potential Puppeteer issues:
web-ext
(not impossible but messy) Firefox extensions with v2.1.0 puppeteer puppeteer/puppeteer#5532 (comment)npm install
time (via ENV, without package/lockfile changes), it might be difficult/impossible to have both browsers installed for testing (a "solution" would be to test Firefox just on CI) (EDIT: may be possible)When the time comes to discuss testing more in detail, I'll probably look into alternatives to jest-puppeteer (e.g. Selenium?)
The text was updated successfully, but these errors were encountered: