tryDataTestId function test ✓ 100.0%

Last updated: 2026-03-05T12:26:14.062Z

Metrics

LOC: 14 Complexity: 3 Params: 1 Coverage: 100.0% (6/6 lines, 79x executed)

Signature

tryDataTestId(el: Element): : SmartSelector | null

Source Code

function tryDataTestId(el: Element): SmartSelector | null {
  const attrs = ["data-testid", "data-test-id", "data-cy", "data-test"];
  for (const attr of attrs) {
    const val = el.getAttribute(attr);
    if (val) {
      return {
        value: `[${attr}="${escapeCSS(val)}"]`,
        strategy: "data-testid",
        description: `${attr}="${val}"`,
      };
    }
  }
  return null;
}

Dependencies (Outgoing)

graph LR tryDataTestId["tryDataTestId"] escapeCSS["escapeCSS"] tryDataTestId -->|calls| escapeCSS style tryDataTestId fill:#dbeafe,stroke:#2563eb,stroke-width:2px click tryDataTestId "3b7a431d1d766645.html" click escapeCSS "44646aa96f30257e.html"
TargetType
escapeCSS calls

No incoming dependencies.