UnknownPrinciple / rollwright

A set of tools to make Playwright comfortable for UI integration testing.

Home Page:https://unknownprinciple.github.io/rollwright/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rollwright

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

About

A set of tools to make Playwright comfortable for UI integration testing.

https://unknownprinciple.github.io/rollwright/

License:ISC License


Languages

Language:JavaScript 100.0%