Add Lightpanda as an alternative headless browser for E2E tests#171
Draft
krichprollsch wants to merge 7 commits intoPackmindHub:mainfrom
Draft
Add Lightpanda as an alternative headless browser for E2E tests#171krichprollsch wants to merge 7 commits intoPackmindHub:mainfrom
krichprollsch wants to merge 7 commits intoPackmindHub:mainfrom
Conversation
Add `lightpanda` service (nightly image, CDP on :9222, healthcheck) and `run-e2e-tests-lightpanda` service under the `e2e-lightpanda` profile so the full Lightpanda-backed E2E stack can be launched with a single `docker compose --profile e2e-lightpanda up`. Co-Authored-By: Claude <claude@anthropic.com>
Add playwright.lightpanda.config.ts with video and screenshot disabled since Lightpanda has no rendering engine. Uses a single 'lightpanda' project and preserves trace on first retry. Co-Authored-By: Claude <claude@anthropic.com>
When LIGHTPANDA_WS_ENDPOINT is set, connect to the Lightpanda browser over CDP using chromium.connectOverCDP() instead of launching a local Chromium instance. All downstream fixtures (testWithUserSignedUp, testWithApi) inherit this automatically via the fixture chain. Co-Authored-By: Claude <claude@anthropic.com>
Add a dedicated script that runs Playwright with the Lightpanda-specific config (no video/screenshot, CDP-connected browser). Co-Authored-By: Claude <claude@anthropic.com>
The Lightpanda image does not ship wget or curl. Replace the healthcheck with a bash built-in TCP connection test which has no external dependencies. Co-Authored-By: Claude <claude@anthropic.com>
Playwright's built-in locale fixture defaults to "en-US", which causes crPage.js to call Emulation.setUserAgentOverride during page init. Lightpanda does not implement that CDP command and returns UnknownMethod. An empty string is falsy, so the conditional (if options.locale) is skipped. Co-Authored-By: Claude <claude@anthropic.com>
Playwright requires the first fixture argument to use object destructuring
({}) not a plain parameter; _fixtures caused a runtime error.
Browser.disconnect() does not exist on CDP-connected browsers in
playwright-core 1.56 — the connection closes naturally on worker exit.
Co-Authored-By: Claude <claude@anthropic.com>
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.
Explanation
Lightpanda is an open-source headless browser written in Zig. It exposes a CDP (Chrome DevTools Protocol) endpoint and is designed to be significantly faster and lighter than Chromium. This PR wires it up as an opt-in alternative to the existing Chromium E2E runner.
Type of Change
Affected Components
Docker Compose (
docker-compose.yml)lightpandaservice —lightpanda/browser:nightlyimage, under thee2e-lightpandaprofile. Healthcheck usesbash -c </dev/tcp/127.0.0.1/9222(the image ships no wget/curl).run-e2e-tests-lightpandaservice — mirrorsrun-e2e-testsbut setsLIGHTPANDA_WS_ENDPOINTand depends onlightpandabeing healthy first.Playwright config (
playwright.lightpanda.config.ts)video: 'off',screenshot: 'off'— Lightpanda has no rendering engine.locale: ''— Playwright's built-in locale fixture defaults to "en-US", which makescrPage.jscallmulation.setUserAgentOverrideduring page initialisation. Lightpanda does not implement that CDP command and returnsUnknownMethod. An empty string is falsy so the conditional is skipped.lightpandaproject (no device preset needed for a CDP connection).Fixture (
src/fixtures/packmindTest.ts)browserfixture override: whenLIGHTPANDA_WS_ENDPOINTis set,chromium.connectOverCDP()is used instead ofchromium.launch(). All downstream fixtures (testWithUserSignedUp,testWithApi) inherit this automatically.Browser.disconnect()does not exist on CDP-connected browsers in playwright-core 1.56 — the IPC connection closes naturally when the worker exits.npm script (
apps/e2e-tests/package.json)Testing
Test Details:
Start Lightpanda + full dev stack
Or run tests manually once the stack is up
TODO List
Reviewer Notes
The CDP integration is fully wired up and Playwright successfully connects to Lightpanda. Tests navigate to the frontend, but the frontend JS bundle throws
ReferenceError: TextEncoderStream is not defined— Lightpanda's nightly build does not yet implementTextEncoderStream(part of the Web Streams Encoding API). This causes Lightpanda to crash on the first page load.The fix belongs in Lightpanda, not in our test suite. Once Lightpanda implements
TextEncoderStream(and likelyTextDecoderStream), the tests should run without further changes on our side.