feat: test examples in real browsers#242
Conversation
- pulls example tests out to own dir to reuse them for each ui library. also explores using vitest to drive playwright tests. It's ok, but I think we want as little friction as possible for browser testing, and i'm now inclined to use @playwright/test instead after trying it in #238 and now i see it has support for what we need to do here https://playwright.dev/docs/test-advanced#projects and https://playwright.dev/docs/test-parameterize License: MIT Signed-off-by: Oli Evans <oli@protocol.ai>
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
|
I explored using vitest to drive playwright tests. It's ok, but a little clunky and I think we want as little friction as possible for browser testing. i'm now inclined to use @playwright/test instead after trying it in #238 and now i see it has support for what we need to do here https://playwright.dev/docs/test-advanced#projects and https://playwright.dev/docs/test-parameterize and if we stick with vanilla @playwright/test we can use a service to run our tests for us if we want to. |
- make it nice for running tests in many browsers License: MIT Signed-off-by: Oli Evans <oli@protocol.ai>
License: MIT Signed-off-by: Oli Evans <oli@protocol.ai>
- `pnpm test` runs package tests - `pnpm test:examples` runs examples tests License: MIT Signed-off-by: Oli Evans <oli@protocol.ai>
License: MIT Signed-off-by: Oli Evans <oli@protocol.ai>
|
Here's a good example of the kind of info we get from this... Our vue EDIT: oh ho ho... we haven't written that ui + example combo yet! but you get the point, we will get a heads up when one of the 20 existing examples breaks. |
License: MIT Signed-off-by: Oli Evans <oli@protocol.ai>
travis
left a comment
There was a problem hiding this comment.
I love it! I'm going to start a discussion around which examples we want to keep longer-term so I wouldn't go too much deeper on this for now, but I'm super excited about the approach!
| @@ -0,0 +1,13 @@ | |||
| import { test, expect } from '@playwright/test' | |||
|
|
|||
| for (const ui of ['react', 'solid', 'vue'/* 'vanilla' not work atm */]) { | |||

Pulls example tests out to own dir so we can run the same test for each ui library!
fixes: #222
You can see it run in CI at https://github.com/web3-storage/w3ui/actions/runs/3901558574/jobs/6663550379#step:6:13 and you can try it out locally from this branch by running:
note: the build fails currently as our vanilla examples fail to build currently, which is why we need these tests!
Adds and updates run scripts to make it easy to run package or example tests. Most of the time we'd want to run package tests locally, so this is set as the default.
Updates examples to produce relative URLs by setting
base: ''in vite config. This allows us to serve all the examples from a single static server in theexamplesdir, andserveis added with aserve.jsonconfig to rewrite the paths so thedistdir is served for each example.Adds playwright config to fire up the example server
Adds github workflow to set up and run the browser tests only if we make a change to the examples. We may change this to run for every change in the future, as we should probably check if the examples still work if we change a package!
Reduces the scope of our local github action to just handle setting up node and pnpm which is needed by every workflow.
lintandtestare now specified explicitly in workflows that should run them. We don't need to run those steps when we're doing browser testing.multi-file-uploadexample - Add multi-file-upload Vue example #245whoo!

License: MIT
Signed-off-by: Oli Evans oli@protocol.ai