feat: add browser mode with Playwright provider#16173
Closed
ahnpnl wants to merge 1 commit into
Closed
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
ahnpnl
force-pushed
the
feat/browser-mode
branch
4 times, most recently
from
May 12, 2026 18:50
3ebbf6e to
1d9036d
Compare
babel-jest
babel-plugin-jest-hoist
babel-preset-jest
create-jest
@jest/diff-sequences
expect
@jest/expect-utils
jest
@jest/browser
@jest/browser-playwright
jest-changed-files
jest-circus
jest-cli
jest-config
@jest/console
@jest/core
@jest/create-cache-key-function
jest-diff
jest-docblock
jest-each
@jest/environment
jest-environment-jsdom
@jest/environment-jsdom-abstract
jest-environment-node
@jest/expect
@jest/fake-timers
@jest/get-type
@jest/globals
jest-haste-map
jest-jasmine2
jest-leak-detector
jest-matcher-utils
jest-message-util
jest-mock
@jest/pattern
jest-phabricator
jest-regex-util
@jest/reporters
jest-resolve
jest-resolve-dependencies
jest-runner
jest-runtime
@jest/schemas
jest-snapshot
@jest/snapshot-utils
@jest/source-map
@jest/test-result
@jest/test-sequencer
@jest/transform
@jest/types
jest-util
jest-validate
jest-watcher
jest-worker
pretty-format
commit: |
ahnpnl
force-pushed
the
feat/browser-mode
branch
15 times, most recently
from
May 14, 2026 04:00
26557e4 to
35a45e4
Compare
Adds jest-browser package that runs tests in real browsers via Vite dev server and Playwright. Tests execute as native ESM in Chromium/Firefox/WebKit with full DOM APIs, real event handling, and visual regression testing. Architecture: - Vite serves test files as ESM with virtual @jest/globals module - birpc over WebSocket for Node<->Browser communication - Playwright manages browser lifecycle (launch, context, page) - Client runtime: test runner, expect, mocks, fake timers - Provider plugin system (@jest/browser-playwright extractable) - page.extend() API for framework component testing Config options: - viewport, headless, provider, providerOptions, instances - screenshotFailures, screenshotDirectory, connectTimeout - trackUnhandledErrors, fileParallelism, trace - api (port/host), testerHtmlPath, expect (screenshot config) Includes: - jest-browser + jest-browser-playwright packages - Full e2e test suite (35 tests across 11 suites) - Unit tests for provider, runner, screenshot, error-catcher, page - Multi-page documentation (guide, config, API, screenshots, multi-browser)
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Adds Browser Mode to Jest — run tests in real browsers (Chromium, Firefox, WebKit) via Playwright, with full DOM APIs, real event handling, and visual regression testing.
Tests execute as native ESM inside a Vite dev server, eliminating the gap between jsdom simulation and real browser behavior.
New Packages
@jest/browserThe core browser mode package. Provides:
BrowserTestRunner— Jest test runner that launches browsers@jest/globals,@jest/browser)toMatchScreenshot)defineBrowserProvider,resolveProvider)page.extend()API for framework component testing plugins@jest/browser-playwrightPlaywright provider plugin (extracted, following Vitest's pattern). Provides:
PlaywrightBrowserProvider— manages browser/context/page lifecycleuserEventactions (click, type, fill, hover, etc.)Architecture
Key design decisions:
@jest/browser-playwrightimplementsBrowserProviderinterface, registered viadefineBrowserProvider()page.extend()enables framework plugins (e.g.jest-browser-vueaddspage.render())triggerCommanddispatch — browser calls RPC → node routes to provider's command registryConfiguration Options
All options under
browserModein Jest config:enabledbooleanfalsename'chromium'|'firefox'|'webkit''chromium'headlessbooleantrueproviderstring'playwright'providerOptionsobject{}viewport{width, height}{414, 896}instancesarrayscreenshotDirectorystring'__screenshots__'screenshotFailuresbooleantrueconnectTimeoutnumber60000trackUnhandledErrorsbooleantruefileParallelismbooleantruetrace'off'|'on'|'retain-on-failure''off'apinumber|{port?, host?}testerHtmlPathstringexpect{toMatchScreenshot: {threshold?, maxDiffPixelRatio?, maxDiffPixels?}}{threshold: 0.1}APIs
From
@jest/browseruserEvent— Real browser interactions via Playwright automation:click(element)dblClick(element)type(element, text)fill(element, text)clear(element)hover(element)unhover(element)tab()keyboard(keys)selectOptions(element, values)page— Page interactions and framework extension point:page.screenshot(options?)page.extend(methods)page.elementLocator(el)commands— Execute Node-side functions via RPC:commands.removeFile(path)— delete a fileserver— Environment metadata:server.browser— current browser nameserver.platform— OS platformScreenshot matching:
From
@jest/browser-playwrightProvider plugin for Playwright. Can be used directly for custom setups:
playwright()PlaywrightBrowserProviderdefineBrowserProvider(plugin)@jest/browser)Custom provider example:
Test Coverage
Documentation
Split into 5 pages under Guides > Browser Mode: