effect-playwright
    Preparing search index...

    Function withBrowser

    • Provides a scoped Playwright.Browser to an Effect.

      When to use

      Use this as the concise alternative to accessing PlaywrightSpawner and its browser effect directly.

      Details

      A fresh browser is launched when the returned effect starts and is closed when that effect succeeds, fails, or is interrupted. The PlaywrightSpawner layer must already be provided.

      Example (Providing a browser for one program)

      import { Effect } from "effect";
      import { Playwright, PlaywrightSpawner, chromium } from "effect-playwright";

      const program = Effect.gen(function* () {
      const browser = yield* Playwright.Browser;
      const page = yield* browser.newPage();
      yield* page.setContent("<h1>Effect</h1>");
      }).pipe(
      PlaywrightSpawner.withBrowser,
      Effect.provide(PlaywrightSpawner.layer(chromium)),
      );

      Type Parameters

      • A
      • E
      • R

      Parameters

      Returns Effect<
          A,
          PlaywrightError
          | E,

              | PlaywrightSpawner.PlaywrightSpawner
              | Exclude<Exclude<R, Playwright.Browser>, Scope>,
      >

      0.1.0