Getting started
Begin with a small real-browser scenario using the locally built production core. See installation for the unreleased package and aligned peer requirements.
import { DomPageObject, PageObject, rootFixture } from "@pomeranian/core";
class App extends DomPageObject<App> {
override defaultTarget = "#app";
Menu = Menu.create(this);
}
class Menu extends PageObject<App> {
Approve = DomPageObject.create(this, "button");
}
const appTest = test.extend<{ app: App }>({ app: rootFixture(App) });
appTest("application objects share context and use live native queries", async ({ page, app }) => {
await page.setContent('<main id="app"><button>Approve</button></main>');
expect(app.root).toBe(app);
expect(app.Menu.Approve.root).toBe(app);
await expect(app.Menu.Approve.locator).toHaveText("Approve");
});The app fixture establishes root identity before child fields initialize. Grouping Menu forwards the app DOM scope to its button. This core slice uses native Locator assertions; Element basic and form actions are available in the essential package; assertions remain separate work.
An independent browser scenario
The following contributor example also verifies the browser directly.
After setting up the repository, run:
pnpm --filter @repo/docs exec playwright test examples/inline.spec.mtsThe maintained test below runs against Chromium and is checked by TypeScript 7. The rendered excerpt comes directly from that file, so editing the displayed code means editing the executable example.
test("a small scenario has an independently checked visible outcome", async ({ page }) => {
await page.setContent(`
<button type="button">Approve</button>
<output>Waiting</output>
<script>
document.querySelector('button').onclick = () => {
document.querySelector('output').textContent = 'Approved';
};
</script>
`);
await page.getByRole("button", { name: "Approve" }).click();
await expect(page.locator("output")).toHaveText("Approved");
});page.setContent creates a fresh scenario in the test's browser context. The ordinary Playwright assertion independently verifies what happened after the click.
Continue with construction and DOM targets and library authoring. The historical factory proof is separate bounded evidence. To add a larger shared scenario later, follow the testing guide.
Essential actions
import { DomPageObject, PageObject, rootFixture } from "@pomeranian/core";
import { Element, TextInput, TextArea, Checkbox, Select } from "@pomeranian/lib-essential";
class Menu extends PageObject<App> {
Continue = Element.create(this, "button");
}
class App extends DomPageObject<App> {
override defaultTarget = "main";
Menu = Menu.create(this);
}
const appTest = test.extend<{ app: App }>({ app: rootFixture(App) });
appTest("essential actions use the application scope", async ({ page, app }) => {
await page.setContent(
"<main><button onclick=\"this.textContent='Done'\">Continue</button></main>",
);
await app.Menu.Continue.click();
await expect(app.Menu.Continue.locator).toHaveText("Done");
});