Skip to main content
@e2edev/playwright drives Chromium, Firefox, and WebKit through Playwright. A web target names it as its engine, and it contributes the web fixture for browser-only work. Import test from the package to have web typed. Bring your own Playwright: the package declares playwright as a peer dependency (>=1.63.0 <2) and does not install it. An app that already depends on Playwright keeps its version, one copy in node_modules, and one browser cache; e2e init adds playwright only to a project that has none. A version outside the range may be rejected by your package manager as an unmet peer (npm’s ERESOLVE), so upgrade playwright within the range.
e2e.config.ts

Options

playwright(options) takes the app declaration every engine makes plus the browser choices: headers and basicAuth are how a test reaches a protected preview.

Web

Every web call is a recorded web.<method> step. A relative URL or a URL match needs the engine’s declared url; without it the call fails with APP_URL_REQUIRED. Declare requires: ['web'] in a suite that also runs on other platforms; acquiring web on a target whose engine does not contribute it fails with UNSUPPORTED_CAPABILITY.

Locators and frames

evaluate

Both overloads serialize the function and run it in the page, so it cannot close over test-scope variables. Pass data through arg. Both arg and the return value must be JsonValue; anything else, including a non-finite number, throws INVALID_ARGUMENT. Exceptions thrown by the evaluated code fail the test with EVALUATE_FAILED and preserve the message. A Playwright timeout is reported as ACTION_FAILED; page or browser closure, crashes, and lost execution contexts are ENGINE_FAILURE.

Routing

json and body are mutually exclusive. Omitting both fulfills with an empty body.

Cookies and viewport

Supply url, or domain with an optional path. Never both.

Dialogs and downloads

keyboard and mouse

Both namespaces are viewport-level and unfocused. Prefer locator.press and locator.fill when a target exists. keyboard.type takes plain text only; use locator.fill with a Secret for secret material.

JsonValue

Exported types

PlaywrightOptions, PlaywrightConnectOptions, PlaywrightBasicAuth, BrowserName, PlaywrightLiveSurface, Web, WebExpectation, WebRoute, WebResponse, Cookie, Dialog, and DialogHandler are exported from the package for typing config helpers and fixtures.

expect(web)

expect(web) returns the WebExpectation the engine attaches: toHaveURL, toHaveTitle, and toHaveClass. See web matchers.

surfaceOf

surfaceOf(handle) returns the PlaywrightLiveSurface behind a handle this package created, or undefined for any other handle. Both accessors throw INVALID_STATE before an attempt is running or a page is open. It exists for a custom executor that brings its own browser tooling; what it does there is not recorded as steps.

app

screen and Locator

expect

Starting your app