@code.pops/js-test-tools
v2.0.1
Published
A collection of wrapper functions around common javascript test frameworks. Support for Playwright currently, but more to come.
Downloads
1,047
Readme
jsTestTools
A collection of wrapper functions around common javascript test frameworks.
In many cases it purely wraps existing test functions or methods, resulting in a less verbose consumer pattern. Additional group methods are included on top of existing Playwright functionality however.
For example:
- Group function to select and click one or more buttons with a single invocation.
- Group function to locate and return
innerTextvalues for multiple id-fetched locators, in a typed object - A function that accepts an array of Playwright instructions that can be awaited with a single
await
Installation
npm install @code.pops/js-test-tools
Usage
import { jsTestToolsFactory } from "@code.pops/js-test-tools";
test("my test example", async ({ page }) => {
const { clickById, innerTextById } = jsTestToolsFactory(page);
await clickById("greetings-test-id").click();
const text = await innerTextById("test-canvas");
expect(text).toContain("Hello World!");
});Test Frameworks
Playwright
This library currently supports a subset of Playwright selectors (or commonly referred to as locators) and actions.
Latest tested version: 1.36.0
Contributions
Testing this library
- Run
bunx playwright install chromium(once) - Run
bun run test:e2e
Roadmap
- [ ] Increase support for Playwright
- [ ] Add more test frameworks
Contributing
Contact the author for more.
