fix(locator): name level, states, and exact: false in a locator's description
GA
17h ago+24+24+01234567890123456789-1-1-0123456789
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
- In
describeExpression's query case (packages/core/src/locator/expression.ts), after the name:exact: falsewhen the value or name is a loose string, thenlevel, then each required state in the orderroleQuerystores them. Defaults print nothing, so every existing description is unchanged.
Issue
Fixes #2490
Verified
Ran it locally: yes
| locator | main | this 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/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@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: trueandexact: falsefor regular-expression text queries remain omitted.
- Locator descriptions and reports now include non-default options such as heading level, state, and