v4.4.0-beta.1
Pre-release
Pre-release
4.4.0-beta.1 (2022-08-25)
Features
- fixture: add
locatorFixtures
that provideLocator
-based queries (3fc61e1)
This will likely replace the fixtures that provided ElementHandle
-based
queries in a future major release, but for now the Locator
queries are
exported as locatorFixtures
:
import { test as baseTest } from '@playwright/test'
import {
locatorFixtures as fixtures,
LocatorFixtures as TestingLibraryFixtures,
within
} from '@playwright-testing-library/test/fixture';
const test = baseTest.extend<TestingLibraryFixtures>(fixtures);
const {expect} = test;
test('my form', async ({queries: {getByTestId}}) => {
// Queries now return `Locator`
const formLocator = getByTestId('my-form');
// Locator-based `within` support
const {getByLabelText} = within(formLocator);
const emailInputLocator = getByLabelText('Email');
// Interact via `Locator` API 🥳
await emailInputLocator.fill('[email protected]');
// Assert via `Locator` APIs 🎉
await expect(emailInputLocator).toHaveValue('[email protected]');
})