---
name: pw_launch_browser
kind: function
lang: ts
domain: browser
version: "1.0.0"
purity: impure
signature: "async (opts?: PwLaunchOptions) => Promise<PwHandles>"
description: "Launches chromium and returns a Page navigated to baseUrl. Optionally pre-authenticates via storageState. Used as the entry point for any Playwright e2e test in the registry."
tags: [playwright, e2e, browser]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
params:
  - name: opts
    desc: "Launch options; all fields optional with sensible defaults for kanban e2e."
output: "Playwright handles {browser, context, page, close}; page is already navigated to baseUrl."
tested: true
tests: ["launch defaults", "launch with storageState", "close calls both"]
test_file_path: "frontend/functions/browser/pw_launch_browser.test.ts"
file_path: "frontend/functions/browser/pw_launch_browser.ts"
---

## Ejemplo

```typescript
import { pw_launch_browser } from "./pw_launch_browser";

const h = await pw_launch_browser({ baseUrl: "http://localhost:5180", headless: false });
await h.page.click("text=Login");
await h.close();
```

## Cuando usarla

Cuando necesites iniciar un test e2e de Playwright para el SPA de kanban (o cualquier frontend del registry). Es el primer paso de cualquier suite: abre el browser, navega al baseUrl y devuelve los handles listos para interactuar.

## Gotchas

- `playwright` es una peer dependency: debe estar instalada en el proyecto consumidor (`pnpm add -D playwright` o `npm i -D playwright`). El registry no la instala.
- `storageStatePath` se ignora silenciosamente si el archivo no existe — verifica que el archivo de auth se haya generado antes de pasarlo.
- `close()` cierra context primero y luego browser; no llames `browser.close()` manualmente antes de `close()` o el context quedara huerfano.
- La navegacion a `baseUrl` ocurre dentro de `pw_launch_browser`; si el servidor no esta levantado, `page.goto` lanzara un error de red.
