Skip to content

waygraph / defineReadBlock

Function: defineReadBlock() ​

defineReadBlock(options): ReadBlock

Defined in: src/engine/read/read-block.ts:52

Declares what a page shows, as typed data an agent or a test can read.

Parameters ​

options ​

ReadBlockOptions

Returns ​

ReadBlock

Example ​

ts
export const PostReadBlock = defineReadBlock({
  name: "read-post",
  from: PostOpen,
  instruction: {
    read: (ctx) => Post({ title: ctx.page.text("h1"), likes: ctx.page.number(".likes") }),
  },
});

Deprecated ​

A page's what-it-shows is its read: (definePageBlock({ read: (ctx) => ({ ... }) })), keys as Page.read.x; a layout's is defineLayout({ read }). waygraph upgrade --codemod page-object moves a project.

waygraph 0.18.3 (alpha) · Node 24+ · peer @playwright/test ^1.40.0 · syntax may change before 1.0: see what was removed