Rewright is a single-dependency, ultra-lightweight module providing you with a React-like state management system in Playwright. Because web applications are (more often than not) dynamic, your end-to-end tests should be too!
Read our API documentation here: https://tristandamron.github.io/rewright/
Whether you're starting a new Playwright project, or you're implementing Rewright into an existing project, getting started with Rewright is simple!
Consider a typical Playwright test file:
import { test, expect } from "playwright/test";
test.describe("My really great test suite", () => {
test("My test case", async ({ page }) => {
await page.goto("https://google.com/");
await expect(page.getByRole("label", { name: "Search" })).toBeVisible();
});
});
This test file uses the default Playwright test fixture which exposes the page
object, allowing you to control the browser. We can update this file to use Rewright's test fixture instead:
import { test } from "rewright";
import { expect } from "playwright/test";
test.describe("My really great test suite", () => {
test("My test case", async ({ page, state }) => {
await page.goto("https://google.com/");
await expect(page.getByRole("label", { name: "Search" })).toBeVisible();
});
});
Rewright's test fixture exposes an internal state manager that we can use to keep track of our application's state in our tests. While this example demonstrates how you can access Rewright's state manager through the test fixture, the module also has additional functions for managing state. You can learn more about this topic on our API documentation site: https://tristandamron.github.io/rewright/
Rewright is written in Typescript using Bun. The project is licensed under the MIT license and contributions are always welcome! The following guide will teach you how to work with the project on your own machine.
Please follow this workflow to contribute to this project:
After submitting your PR, a project maintainer will review it before it is merged to the main branch. Please remember that this project was proudly written without the use of generative AI tools. Please do not submit PRs which contain AI generated code, the maintainers will not approve them.
After cloning this repository to your machine, cd
into the project directory and execute the following command:
bun install
Rewright has several automated test suites which help to ensure that the module is stable and production ready at each release. These tests will run automatically with each PR you create to this repository via Github Actions. You can run the tests locally on your machine with the following command:
bun run test
API documentation should be updated with each new update. You can generate an up-to-date version of the documentation using this command:
bun run docs
You can build Rewright and package the module to a .tgz file for testing using the following command:
bun run pkg