Add automated browser-based tests to check examples on web editor for console errors#85
Add automated browser-based tests to check examples on web editor for console errors#85nbogie wants to merge 11 commits into
Conversation
(generated by playwright)
|
update: silenced the headless firefox test run to match chrome. |
|
Minor extra notes from trying this with @ogbabydiesal :
As next steps Tommy will work on creating an Thanks so much for getting this started! |
|
I am happy to alter it to work from (copied from my discord response:) If the examples are going to continue to be published on the web editor (I hope so - I love the availability and the subsequent discoverability in the collection), then I'd probably argue mildly that we might try to have the tests be capable of running against sketches in both locations, assuming it doesn't add a lot of maintenance. In the end the actual test process doesn't change wherever they are, only some implementation details for each step.
Pros of running the automated tests against the editor:
Cons of running the automated tests against the editor:
|
|
hey @nbogie I created a repo with collection in the examples folder, there's only one for now but this would be the folder hierarchy if you'd like to test with that. I'll add the rest soon https://github.com/processing/p5.sound.js.git I hear you about running the tests in the editor as that is how many people will interact with them first, if your into the idea of running them both places, and it isn't too much work you can use that repo! |
|
@ogbabydiesal not sure if that's the intended link but can you make the |
|
Hi @ksen0 @ogbabydiesal (Sorry if this work is already underway elsewhere). |
(Needs http-server dev dependency to serve the examples) No functional change to original test that runs against web-editor examples
|
@ksen0 @ogbabydiesal I've updated this PR to also test the local examples/ that are now in main. AI use disclosure: rewrite, and about-these-tests mostly done by claude code. (about-these-tests is a bit technical still, i know, but if you find no issues I'd like to merge this, as a starting point) To run the browser-based tests locally we need a little web server to serve the examples - I added one as a dependency. (Or we could write a small from node.js primitives.) |
Thanks, I've now addressed this in I think playwright tells you what to do when you don't have the necessary browser(s) installed, so if someone doesn't read that document, it's not a total loss. (I'm wary of putting |
|
just did a test and see that many of my firefox tests fail but when testing these examples in the browser there are no errors. for example, this test fails for firefox: https://editor.p5js.org/thomasjohnmartinez/sketches/z-KkeTrcu but you will see that there are no errors when running the sketch. (i will note that I can cause an error by going out of bounds with one of the parameters but wouldn't this cause the test to fail in chrome as well? ) let me know what you think! UPDATE: I ran the test again one by one, and that test passed so it might be that the tests are inconsistent? It did help me find a bug in example 4 though (the most recent library adds a feature that is not in the release yet, the example takes advantage of this feature but is broken until a new version is pushed). |
|
Thanks @ogbabydiesal . I didn't look into the firefox failures. I get the same result as you when running that example sketch manually (no error). Some possibilities:
I suggest we merge the tests into main (even with these firefox issues) so they're more easily accessible for others to work on, and so that the (fairly healthy) chromium tests (for example) can be used to provide confidence to rapid changes to the examples and library itself. |
|
Hi @ogbabydiesal
Are you saying that ALL examples passed their tests when the tests are run individually in the playwright UI? They still fail for me when I run them one by one. Also, can you be specific as to whether you're talking about the local or web-editor examples? I'll investigate a bit further |
|
Here's a video of an intermittent failure on firefox of example 005 in the web editor |
Addresses #84
What is this?
Adds playwright-based config and tests to check the p5.sound examples in place on the web editor, checking they load and don't have any errors in the console.
How to run the tests (with test-runner UI)
This is recommended as it allows easier exploration of test failures:
in the gui that opens, click "projects" and ensure "firefox" and "chromium" are checked. (see image)
Also in the gui, press the play button on the top test or above it. (see image)
Alternative: How to run the tests (unattended):
This will present a html report when it finishes.
What are the additions and changes?
package.jsonplaywright.config.js, specifying, for example, where the tests are (./tests/) and which browsers to use.tests/integration/test-examples-on-web-editor.spec.jsThis is the main test file that instructs playwright what web pages to load , what to click, and what to check for.tests/integration/about-these-tests.mddocumenting the testing (and some problems faced in automated testing of the web editor)..github/workflows/playwright.yml.DISABLED- this is untested.Limitations:
.github/workflows/playwright.yml.DISABLEDAI usage disclosure
Claude Code did most of the implementation on this, including research into chrome and firefox support for pre-emptive grants of microphone + video, troubleshooting the main issue with testing the web editor, and the bulk of the write-up
about-these-tests.md. That said, I've reworked the code to how I want it, I have read and understood each line, and the PR write-up is all mine.