fix(locator): name level, states, and exact: false in a locator's description

GA
17h ago
+24-1

What

A locator in a failure message, step label or report names every option it was built with:

getByRole("heading", level: 2)
getByRole("checkbox", name: "Agree", checked: true)
getByText("Pro", exact: false)

Why

Locators that differ only by level, a state or exact printed the same. A miss caused by one of those options read like a locator that should have matched.

How it works

  1. In describeExpression's query case (packages/core/src/locator/expression.ts), after the name: exact: false when the value or name is a loose string, then level, then each required state in the order roleQuery stores them. Defaults print nothing, so every existing description is unchanged.

Issue

Fixes #2490

Verified

Ran it locally: yes

locatormainthis PR
getByRole('heading', { level: 2 })getByRole("heading")getByRole("heading", level: 2)
getByRole('checkbox', { name: 'Agree', checked: true })getByRole("checkbox", name: "Agree")getByRole("checkbox", name: "Agree", checked: true)

New case in packages/e2e/tests/unit/expression.test.ts. The e2e unit suite passes unchanged (5131 tests). pnpm check passes.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Locator descriptions and reports now include non-default options such as heading level, state, and exact: false, making it easier to distinguish queries with different settings.
    • Default exact: true and exact: false for regular-expression text queries remain omitted.