This repository contains an Effect-based wrapper for Playwright. Follow these guidelines when writing code.
Use pnpm for all package management tasks.
- Install Dependencies:
pnpm install - Build:
pnpm build(usestsdown) - Run All Tests:
pnpm test(usesvitest) - Run Single Test File:
pnpm test src/path/to/test.ts - Type Check:
pnpm type-check(runstsc --noEmit) - Format:
pnpm format(usesbiome format --fix) - Generate Docs:
pnpm generate-docs
- Effect-First: All asynchronous operations must be wrapped in
Effect. - Services: Functionality is exposed via Services and Context Tags (e.g.,
PlaywrightPage,PlaywrightPageService). - Resource Management: Rely on Effect's
Scopefor automatic resource cleanup (browsers, contexts).
- Effect: Import widely used modules from
effect(e.g.,Effect,Context,Stream). - Playwright: Import types from
playwright-core. - Internal: Use relative imports (e.g.,
./common,./errors).
- Typed Errors: Use
PlaywrightErrorfor Playwright-related failures. - Return Types: Methods that can throw should return
Effect.Effect<T, PlaywrightError>. - Avoid Throwing: Do not throw exceptions ever; utilize Effect's error handling.
- Use TSDoc for all public exports.
- Include
@since x.y.ztags. - Include
@exampleblocks showing usage. Prefer runnable full examples over snippets. - Link to underlying Playwright docs using
@see.
-
Framework: Use
@effect/vitestandvitest. -
Structure:
import { assert, layer } from "@effect/vitest"; import { Effect } from "effect"; import { chromium } from "playwright-core"; import { PlaywrightBrowser } from "./browser"; import { PlaywrightEnvironment } from "./experimental"; // Use the PlaywrightEnvironment layer layer(PlaywrightEnvironment.layer(chromium))("Suite Name", (it) => { it.scoped("should do something", () => Effect.gen(function* () { const browser = yield* PlaywrightBrowser; const page = yield* browser.newPage(); // ... test logic assert.strictEqual(1, 1); }).pipe(PlaywrightEnvironment.withBrowser), ); });
-
Assertions: Use
assertfrom@effect/vitest. -
Scopes: Use
it.scopedfor tests that require a scope.
- Features in
src/experimental/may have different stability guarantees but should follow the same coding standards.