From the official docs:
const child = page.getByText('Hello'); const parent = page.getByRole('listitem').filter({ has: child });