Skip to content

Isolate a DOM scenario ​

For a small interaction, start with inline HTML in an ordinary Playwright test. A fresh browser context prevents accidental scenario state from leaking between tests. Prefer stable accessible roles and independent visible outcomes.

ts
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");
});

This example contains no application server or consumer Pomeranian package. The script belongs to the isolated test page. Larger or shared HTML-as-TSX scenarios will use the separately maintained React Storybook when that integration lands.

Keep the assertion about user-visible behavior. When replacing a direct Playwright interaction with a page object later, keep an ordinary Playwright check of the resulting UI where useful. Use the testing guide for package configuration and focused commands.

Unreleased development documentation from main. APIs and prototypes are labelled separately.