examples: add node & cross-browser example#1502
examples: add node & cross-browser example#1502laurentsenta merged 57 commits intotestground:masterfrom
Conversation
…ello-advanced-test
goal will be to be able to run that same test both in node as well as browser
webpack is used to bundle the testplan to be served from the actual playwright-driven webpage
to allow for remote debugging
failing to get proper port exposed...
to allow in worst case to see all browser context up to that point
- use fork of sdk-js to support browser - prepare window env up front
There was a problem hiding this comment.
Almost there, thanks for sharing! These are the 3 fixes I'd like to solve before merging (nothing big):
- fix the
Makefilerebase issue - let's not block on the env feature (#1386 (comment))
- we're blocked by testground/sdk-js#26
First step is done. Third I cannot do yet until merged (if you want to block on that). |
76ee2d8 to
bfaa5b3
Compare
|
All tests pass @laurentsenta and last comments have been applied AFAIK. |
laurentsenta
left a comment
There was a problem hiding this comment.
lgtm, thanks for sharing; it's pretty exciting to see this used soon!
I added @galargh and @achingbrain to give them a chance to review as well,
A few follow-up tasks, let's not block on this:
- run the sync test also, ideally a single test that connects all the browsers + node.
- move the build process to a single builder (
docker:genericI guess), so that the runtime is actually "just" a flag. - make a release for the
js-sdkand tag a version.
…ello-advanced-test
Implement follow-ups from: #1502 (review). Summary: - replace the `BrowserKind` test paramater with `runtime`, which by default is `node`, but - can also be set to `chromium`, `firefox` and `webkit`. - enable the sync test for the browser-node example - also added a sh script to run that same test for the regular `js` example (while I was at it) - update sdk-js used Contributes to #1386
Add advanced browser example testplan Goal of this plan is to show how you can define a testplan which can be run in a node environment as well as within a browser, without having to change anything to your testplan code.
This does mean we also need to allow the
@testground/sdkjavascript package to be run in the browser as-is. To allow this I have a branch which I run this testplan against at https://github.com/glendc/sdk-js/tree/feat/support-browser:so for the browser we instead assume that these are available in the
windowobject aswindow.testground.env;For both these changes we assume one is in the browser when
process.title === 'browser', this because thebrowsernpm (polyfill webpack) module sets that as theprocessglobal variable.Within the example the testplan is found under
src/, the other three directories form together the "magic" solution to allow the node testplan to also be run in the browser:scripts/: contains a polyfill folder to inject an import insrc/index.jswhich is required to polyfill some logic required by winston (an import by@testground/sdk)browser/: the entry point for thedocker:generictestplan, and which will spawn and control everything else;browser/server/: simple express served — controlled by thebrowser/and which will serve the web-pack'd testplan;TODO:
allow debug breakpoints in(not an issue for me, and don't think there is a way to do it otherwise)chrome://inspectwithout having to refresh;@testground/sdkMR and align on the approach there: my goal is that this sdk can be used just the same from the browser as well as the node env;Related PRs:
add browser support to@testground/sdk: first baby steps towards native browser support for the JS sdk of testground sdk-js#25@testground/sdk: feat: add basic browser support sdk-js#26Potential improvements but probably out of scope:
In function of #1386.