Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Preventing AI Test Hallucinations by Indexing data-testid and ARIA Attributes

说明与用途

TokenCap 通过索引 data-testid 和 ARIA 属性,使 AI 代理能够生成准确的选择器,消除常见的选择器错误。

问题

AI coding agents often fail to generate correct DOM element selectors when writing integration and end‑to‑end tests, leading to test failures.

结果

By indexing explicit testing attributes, TokenCap enables AI agents to produce accurate, accessibility‑friendly selectors, eliminating common test hallucinations.

工作流

  • 1. TokenCap parses JSX AST nodes to extract testing attributes (data-testid, data-test, data-cy, role, aria-label, etc.).
  • 2. Extracted attributes are stored in src/frontend/testIds.js and included in component snapshots.
  • 3. When tokencap make runs, component snapshots expose testing selectors with line numbers.
  • 4. AI coding agents consume these snapshots and generate tests using getByTestId or getByRole selectors.
  • 5. Tests are executed, avoiding failures caused by incorrect CSS selectors.

证据

Agents routinely fail at one specific step: guessing DOM element selectors.

来源

In TokenCap, we solve this by parsing JSX AST nodes and extracting explicit testing attributes in src/frontend/testIds.js.

来源

When tokencap make runs, frontend components include their test locator contract: ... getByTestId("billing-submit-button") ... getByRole("combobox", { name: "Billing Tier" }) ...

来源

  • 记录日期: 2026-10-13T20:41:09.257Z