Files
webnet/packages/browser-test-utils
codingetandCodex 6499f202ad
CI / install (pull_request) Successful in 8m10s
CI / lint (pull_request) Successful in 3m7s
CI / format (pull_request) Successful in 3m8s
CI / typecheck (pull_request) Successful in 3m39s
CI / typetest (pull_request) Successful in 3m22s
CI / browser-tests (pull_request) Successful in 5m49s
CI / node-tests (pull_request) Successful in 1m22s
fix(tooling): typecheck support workspaces
Co-Authored-By: gpt-5.6-sol <noreply@openai.com>
2026-08-20 17:12:54 +00:00
..

@webnet/browser-test-utils

Shared Playwright utilities for browser integration tests.

This is a private workspace, not a published library: it is used only by this repo's own node:test suites that need a real browser. forBrowsers wraps a test body in a node:test suite per configured browser (Chromium and Firefox), launching a headless Browser in before and closing it in after, and hands the test a BrowserTestContext with newPage() and serve(dir). newPage() injects an __name shim into the page, working around tsx's esbuild keepNames output losing function names when page.evaluate() serializes callbacks via toString(). serve(dir) starts a local static file server (TestServer) rooted at dir, rejecting paths that escape it.

Usage

import { forBrowsers } from "@webnet/browser-test-utils"

forBrowsers(({ browserName, newPage, serve }) => {
  test(`loads in ${browserName}`, async () => {
    const server = await serve("dist")
    const page = await newPage()
    await page.goto(server.url)
    await server.close()
  })
})

See also