A set of tools to make Playwright comfortable for UI integration testing.
Playwright is a feature rich platform for browser automation. Playwright Test is a powerful testing framework built on top of the automation capabilities. The main target of the testing framework is end-to-end tests, so often developers has to opt for other testing framework (Jest, Vitest, etc). Rollwright makes Playwright suitable for Component testing. No additional setup needed.
import { test } from "rollwright";
import { expect } from "@playwright/test";
import alias from "@rollup/plugin-alias";
test.use({
// Add any Rollup plugins (node-resolve already included)
plugins: [alias({ "./APIModule.js": "./APIModule.mock.js" })],
});
test("isolated UI behavior", async ({ execute }) => {
// Operate your components and real DOM on prepared page, no setup needed
await execute(async () => {
let { renderCounter } = await import("./Counter.js");
let form = document.createElement("form");
document.body.append(form);
renderCounter(form);
});
// Assert using familiar Playwright methods
await expect(page.locator("output")).toHaveText("0");
await page.click("button");
await expect(page.locator("output")).toHaveText("1");
});