@grafana/testing-library-k6-browser
v2.0.1
Published
Testing Library selector for k6 browser
Downloads
349
Maintainers
Keywords
Readme
k6 Browser Testing Library
testing-library-k6-browser is a lightweight adapter allowing DOM Testing Library to be used with k6 browser.
npm install --save-dev @grafana/testing-library-k6-browser
Usage
import { browser } from "k6/browser";
import { within } from "@grafana/testing-library-k6-browser";
const page = await browser.newPage();
// Attach selectors
const document = await getDocument(page);
const { findByTestId } = within(page);
// Your favorite query methods are available
const form = await findByTestId("my-form");
// returned elements are k6 browser ElementHandles too!
const email = await within(form).getByLabelText("Email");
// interact with k6 browser like usual
await email.type("[email protected]");
Known Limitations
waitForElement
method is not exposed. k6 browser has its own set of wait utilities.fireEvent
method is not exposed, use k6 browser's built-ins instead.expect
assertion extensions are not available.