Skip to content

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

Open
gagarinyury wants to merge 1 commit into
e2e-inc:mainfrom
gagarinyury:fix/locator-description-options
Open

gagarinyury wants to merge 1 commit into
e2e-inc:mainfrom
gagarinyury:fix/locator-description-options

Conversation

@gagarinyury

@gagarinyury gagarinyury commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

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

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/**/*.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

View guided diff

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.

…cription

describeExpression printed a role query's value, name, and visible only,
so getByRole('heading', { level: 2 }) read as getByRole("heading") and a
checked: false checkbox as the checked one. The description now appends
exact: false, the level, and each required state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the size:S Up to 29 changed lines, not counting tests, fixtures, translated docs, or the lockfile label Nov 29, 2026
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Locator descriptions

Layer / File(s) Summary
Render and verify locator options
packages/core/src/locator/expression.ts, packages/e2e/tests/unit/expression.test.ts, .changeset/locator-description-options.md
describeExpression now renders exact: false, configured role levels, and query states. Tests cover option ordering and omission of default exactness. The changeset records the patch.

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: Minimal · up to 7a317

Locator descriptions will now show non-default exactness, role level, and states, so locators that differ only in those options read differently in failure messages and reports. Existing descriptions without those options are unchanged. No merge-blocking risk was found.

Security architecture risk: Minimal · up to 7a317

Failure messages, step labels, and reports now show more of the locator options that were already set. Locator matching is unchanged, and the change introduces no new access or permissions.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4d8b4a85-cd41-4187-a801-59760bf498ac
Commits

Reviewing files that changed from the base of the PR and between 7c1b2b2 and 7a317f8.

Files selected for processing: 3

  • .changeset/locator-description-options.md
  • packages/core/src/locator/expression.ts
  • packages/e2e/tests/unit/expression.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

View guided diff | Re-trigger cubic

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review (AI triage pass), not yet read by a maintainer.

Reviewed 7a317f85f. Correct, minimal root-cause fix: describeExpression now prints exact: false, level, and role states, the only query fields it dropped; no must-fix found.

Checked:

  • On main the query case prints value, name and visible only (expression.ts:185-191), while roleQuery stores states and level (L22-L35). After this change every field of SemanticQuery that affects matching shows up in the description (expression.ts:189-196).
  • Defaults still print nothing (exact: true, regex patterns, no level, no states). Existing pinned descriptions are unchanged, and locator-engine, mcp-test-lines, mcp-session and expression unit tests pass on the PR head (160 tests).
  • The description only labels steps, errors, report details.locator and MCP text. Cache keys come from recorded targets, not this string, so recordings are unaffected.
  • Mutation check: with main's expression.ts restored, the new test fails. It can fail.
  • States print in roleQuery's fixed insertion order, so the output is deterministic. The test pins disabled before pressed.
  • The changeset (@e2e-dev/core patch) is accurate.

Nits

  1. expression.ts:189 - the comment repeats the test name. It can go. Optional.

CI: fork workflows (mobile, spec, docs, benchmark, microbench) are action_required and wait for maintainer approval. Only check and policy jobs have run, and those are green.

@kdy1 kdy1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This text was drafted with AI and posted after human approval.

  • Harness: T3 Code
  • AI agents: coordinator: Claude Opus 5.5 (claude-opus-5-5), reviewer: GPT-6.2 Astra (gpt-6.2-astra), reviewer: GPT-6.2 Sol (gpt-6.2-sol), reviewer: Claude Opus 5.5 (claude-opus-5-5), reviewer: Claude Sonnet 5.5 (claude-sonnet-5-5)

Verdict: Approve

This review approves the pull request. The P3 items are optional and do not block the merge.

Whether the changeset wording below needs a fix before merge is left to @okwasniewski.

Reviewed commit: 7a317f85fb85cc0ad1d41f5367ced120ef97a413

  • P3 (non-blocking): 1 (1 inline)

This review is posted as a comment because the reviewer asked for a plain review comment and leaves the call on the changeset wording to the maintainer. The verdict above still applies.

'@e2e-dev/core': patch
---

A locator in a failure message, a step label, or a report names every option it was built with: `getByRole("heading", level: 2)`, `getByRole("checkbox", name: "Agree", checked: false)`, and `getByText("Pro", exact: false)`. Locators that differ only by level, a state, or `exact` used to print the same.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 · Non-blocking · The changeset says every option is named, but some options are not printed

Optional. This does not block the merge.

The release note says a locator "names every option it was built with". describeExpression does not print an explicit exact: true, exact: false on a regular expression, or visible: false. These options are defaults or have no effect, so the output is correct, but the release note claims more than the formatter does. For example, getByText(/pro/i, { exact: false }) prints getByText(/pro/i) on this head. The ## What section of the PR body uses the same wording.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. size:S Up to 29 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A failure names getByRole("heading") for getByRole('heading', { level: 2 }), so the message points at the wrong element

3 participants