Skip to content

fix(ci): launch Firefox headed via Vitest browser option#26

Draft
PaulHax wants to merge 3 commits into
pr-3435from
fix-firefox-webgl-playwright-headed
Draft

fix(ci): launch Firefox headed via Vitest browser option#26
PaulHax wants to merge 3 commits into
pr-3435from
fix-firefox-webgl-playwright-headed

Conversation

@PaulHax
Copy link
Copy Markdown
Owner

@PaulHax PaulHax commented May 18, 2026

This PR targets the PaulHax mirror of Kitware#3435 (pr-3435) and contains only the CI Firefox WebGL fix.

What changed:

  • Split Build and Test into a browser matrix so Chromium and Firefox run in separate jobs.
  • Install/cache only the Playwright browser needed by each matrix lane.
  • Set TEST_BROWSER from the matrix so Vitest runs one browser per job.
  • Launch Firefox using the supported Vitest Browser instance headless: false option under xvfb-run.
  • Pass Firefox WebGL prefs and Chromium SwiftShader args through @vitest/browser-playwright provider launchOptions, since instances[].launch is not consumed by Vitest 4.1.6.

Why:

The previous Firefox config used browser.instances[].launch.headless, but Vitest 4.1.6 does not feed that field into Playwright. It effectively launched Firefox as firefox.launch({ headless: true }), which produced the CI no webgl context failures. This branch feeds Firefox as firefox.launch({ firefoxUserPrefs, headless: false }).

Validation on #25:

  • 5 total Build and Test attempts passed on the same SHA.
  • Firefox passed all 5 attempts with 376 passed, 7 skipped, 0 no webgl context, and 0 target Proxy null.
  • Local config import checks confirmed the Firefox and Chromium launch options resolve as intended.

@PaulHax
Copy link
Copy Markdown
Owner Author

PaulHax commented May 18, 2026

Why this appears to fix the Firefox WebGL CI failure:

  • The earlier ci-followup-cleanup / test: validate ci-followup-cleanup on fork #17 config used browser.instances[].launch.headless = false, but Vitest 4.1.6 does not consume instances[].launch for browser instances.
  • As a result, test: validate ci-followup-cleanup on fork #17 effectively still launched Firefox through Playwright as firefox.launch({ headless: true }), and the Firefox prefs under instances[].launch.firefoxUserPrefs were ignored too.
  • This PR uses browser.instances[].headless = false, which Vitest does merge into project.config.browser.headless before @vitest/browser-playwright launches the browser.
  • Firefox prefs are passed through playwright({ launchOptions }), which the provider spreads into Playwright launch options before calling firefox.launch(...).

Effective launch shape:

// old effective path
firefox.launch({ headless: true })

// new effective path
firefox.launch({ firefoxUserPrefs, headless: false })

Validation so far:

@PaulHax PaulHax force-pushed the fix-firefox-webgl-playwright-headed branch from e623e36 to 25f74a9 Compare May 18, 2026 20:29
PaulHax added 2 commits May 18, 2026 16:38
Set `screenshotDirectory: 'Utilities/TestResults/screenshots'` on the
Vitest browser provider so failure screenshots land where the existing
CI test-results artifact upload already picks them up.

Add `.vitest-attachments/` to .gitignore — that's the transient dir
Vitest writes other browser-test attachments into, which doesn't need
to be tracked.
The Vite-migration build wrote `"type": "module"` into the published
package.json and stopped copying `Utilities/config/`. Two regressions
vs `@kitware/[email protected]`:

1. Shipped CommonJS files (webpack-config helpers, bin CLIs) failed to
   load with `ReferenceError: require is not defined`.
2. `Utilities/config/*` helpers vanished — webpack/vue-CLI consumers
   relying on
   `require('@kitware/vtk.js/Utilities/config/rules-vtk')` etc. broke.

Restore both:

- Copy `Utilities/config/` into `dist/esm` (alongside the existing
  `Utilities/XMLConverter` and `Utilities/DataGenerator` copies).
- Write a nested `{"type": "commonjs"}` package.json into each of the
  three CJS subdirs so their `.js` files load via `require()` despite
  the root `"type": "module"`. Node respects nearest-ancestor scope.

Add a CI smoke step that packs `dist/esm`, installs the tarball in a
scratch dir, then exercises three previously-regressed surfaces:
extension-less `require()` of two config helpers and `--help` on the
`vtkDataConverter` bin.
@PaulHax PaulHax force-pushed the fix-firefox-webgl-playwright-headed branch from 25f74a9 to 860e9b0 Compare May 18, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant