Skip to content

Fixtures

POMWright’s test is Playwright’s test with one more fixture, log. Extend it to hand page objects to tests, or combine it with other fixture modules through mergeTests.

fixtures.ts
import { test as base } from "pomwright";
import { AccountPage } from "./account.page";
import { LoginPage } from "./login.page";
import { OrdersPage } from "./orders.page";
export { expect } from "@playwright/test";
type PageObjects = {
loginPage: LoginPage;
accountPage: AccountPage;
ordersPage: OrdersPage;
};
export const test = base.extend<PageObjects>({
loginPage: async ({ page }, use) => {
await use(new LoginPage(page));
},
accountPage: async ({ page }, use) => {
await use(new AccountPage(page));
},
ordersPage: async ({ page }, use) => {
await use(new OrdersPage(page));
},
});

expect comes from @playwright/test; POMWright does not export it. Guide: page objects in tests.


A PlaywrightReportLogger named TestCase, one per test, whose entries are attached to the test when it ends. It records warn and error on a test’s first run and every level on a retry; see levels.

Usage

import { test } from "pomwright";
test("checkout", async ({ log }) => {
log.warn("the basket was empty; added the test product");
});

Type

Guide: logging to the report.