Repository navigation
👷 Run BrowserStack unit tests with Vitest (webdriverio provider) - #5136
Draft
thomas-lebeau wants to merge 6 commits into
Draft
thomas-lebeau wants to merge 6 commits into
thomas-lebeau wants to merge 6 commits into
Conversation
Bundles Sizes Evolution
|
thomas-lebeau
added this pull request to stack #5137
October 13, 2026 15:42
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 9db56ed | Docs | View more details | Give us feedback! |
2 of 5 tasks
thomas-lebeau
force-pushed
the
thomas.lebeau/vitest-wdio-bs-spike
branch
3 times, most recently
from
October 14, 2026 11:22
8d63fc5 to
8ad2817
Compare
thomas-lebeau
force-pushed
the
thomas.lebeau/vitest-wdio-bs-spike
branch
from
October 14, 2026 11:54
8ad2817 to
80c77b4
Compare
2 of 5 tasks
Spike: check whether Vitest Browser Mode can cover our full BrowserStack matrix (Chrome 80, Edge 80, Firefox 78, Safari 14, Android Chrome), which the playwright provider can't. - vite.bs.config.ts: webdriverio provider against hub.browserstack.com, with a WebDriver keepalive (Vitest uses its own WebSocket, so BrowserStack otherwise kills the session as idle) - downlevel dependencies and Vitest's static client assets to ES2020 - polyfills (Object.hasOwn, BroadcastChannel, ...) for orchestrator and tester pages - serve from bs-local.com so Safari can reach the server - report page errors to the terminal (Safari exposes no console logs) - webdriverio 9 -> 10 (v9's bundled undici 6 breaks on Node 26) browser-core results: all 72 files pass on Chrome 80, Edge 80, Safari 14 and Android Chrome; Firefox 78 passes 71/72 (trackRuntimeError.spec.ts triggers an iframe reload when run as a whole).
Point `yarn test:unit:bs` (CI `unit-bs` matrix) at the webdriverio BrowserStack config, to see where the approach stands on the full suite. - verbose reporter, so the BrowserStack wrapper doesn't kill silent runs, and a per-browser junit file in test-report/unit-bs - no coverage on BrowserStack - same exclusions as karma.bs.conf.js (developer extension everywhere, Angular on Chrome/Edge 80 and Firefox 78) Files stay isolated (one iframe per file): running without isolation currently fails 151 tests (state leaking across files, shim gaps).
BrowserStack served Chrome 80 through Selenium 2.53 (JSON Wire protocol), which rejects the `POST /window/rect` Vitest sends before each test file. Also make a failed viewport resize non-fatal.
- trackRuntimeError.spec: `stop()` resolved to `window.stop()`, which made Firefox 78 reload the Vitest test iframe. Unsubscribe from the observable instead. - polyfill AggregateError (Firefox < 79), used by Vitest to report errors - only serve from bs-local.com on Safari: other browsers need `localhost` (a secure context) for `secure` cookies (cookieAccess.spec on Android)
The observable moved to js-core in #5022.
thomas-lebeau
force-pushed
the
thomas.lebeau/vitest-wdio-bs-spike
branch
from
October 15, 2026 14:37
80c77b4 to
840afce
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Every previous Vitest attempt stalled on BrowserStack: Vitest's default Playwright provider can't pick exact browser versions or drive real Android devices, and Vitest's client needs Chrome 87+ / Safari 15.4+, while our unit matrix is Chrome 80, Edge 80, Firefox 78, Safari 14 and Android Chrome.
This PR moves
unit-bsto Vitest using the webdriverio provider, which reaches that exact matrix on real BrowserStack devices. Stacked on #5135. The Karma BrowserStack config is still in the repo (unused) so reverting is a one-line change; it is deleted in a follow-up PR.Changes
yarn test:unit:bs(CIunit-bsmatrix) runsvitest run --config test/unit-vitest/vite.bs.config.ts.test/unit-vitest/vite.bs.config.ts: webdriverio provider againsthub.browserstack.com:seleniumVersion: 4.0.0) on desktop browsers: BrowserStack otherwise serves Chrome 80 through Selenium 2.53, which rejects the window resize Vitest sends before each file. Viewport errors are non-fatal anyway.idleTimeout: 300): Vitest talks to the page over its own WebSocket, so BrowserStack otherwise kills the session as idle.||=/??=. A plugin transpiles dependency JS and routes Vitest's prebuilt/__vitest__/assets through the Vite pipeline (@oxc-project/runtimefor injected helpers).Object.hasOwn,Array.prototype.at, … (from 👷 Migrate unit tests to Vitest #4874), a same-originBroadcastChannel(Safari < 15.4) andAggregateError(Firefox < 79).bs-local.comfor Safari only (BrowserStack rewriteslocalhostthere); other browsers keeplocalhost, a secure context needed bysecurecookie tests.karma.bs.conf.js.trackRuntimeError.spec:stop()resolved towindow.stop(), which made Firefox 78 reload the test iframe; it now unsubscribes from the observable.UND_ERR_INVALID_ARG).Results
All five
unit-bsjobs pass the full suite. Job durations (CI Visibility, minutes, single run):unit-bsChrome 80unit-bsAndroid Chromeunit-bsEdge 80unit-bsFirefox 78unit-bsSafari 14Open issues
browserDisconnectTolerance). We saw one BrowserStack tunnel drop and one Edge connect timeout. Planned:bs-wrapper.tsexits with a dedicated code on these infrastructure errors + GitLabretry: exit_codesonunit-bs.Test instructions
Needs
BS_USERNAME/BS_ACCESS_KEY(e.g. in.env):BS_BROWSERis one ofedge,firefox,safari-desktop,chrome-desktop,chrome-mobile.Checklist