Talewright is a Given-When-Then syntax testing library for Playwright (inspired by cucumber.io and codeceptjs.io), enabling clear, human-readable end-to-end tests that flow like a story.
npm install talewright
const test = base.extend<TalewrightFixtures>({
...talewrightFixtures(),
});
test("simple test to verify Talewright", async ({ page, When, Given, Then, I }) => {
await Given.I.openUrl("https://github.com");
await Then.I.seeText("Build and ship");
await When.I.clickLink("Try GitHub Copilot");
await Then.I.seeText("The AI editor for everyone");
await When.I.clickLink("Sign in");
await Then.I.seeText("Sign in to GitHub");
await Then.I.seeText("New to GitHub?");
});
-
Readable syntax: Write tests like a story using
Given
,When
, andThen
- Full Playwright support: Built on top of Playwright’s API
-
Clear assertions: Use
Then.I.seeText()
andWhen.I.clickLink()
for intuitive interactions -
Creates
test.step()
for each command: so it is easy to see it in Playwright's Trace Viewer - making the generated report similar to the code you write.
Opens the given URL in a new browser session.
Asserts that the specified text is visible on the page.
Finds a link containing the given text and clicks it.
A shorthand for asserting text presence.
Finds a button containing the given text and clicks it.
Finds a label containing the given text and clicks it.
Asserts that a button with the given name is visible.
Asserts that a heading with the given name is visible.
Asserts that a placeholder with the given name is visible.
Finds a tab containing the given name and clicks it.
Finds a text input field with the given label and fills it with the specified value.
Finds a dropdown (combobox) with the given label and selects the specified value.
Finds a checkbox with the given label and checks it.
Finds a checkbox with the given label and unchecks it.
Asserts that the specified text is not visible on the page.
Waits for an element matching the given selector to appear on the page.
Asserts that a text input field with the given label contains the specified value.
Feel free to submit issues or pull requests on GitHub.
MIT