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)
| Target | Type |
|---|---|
| escapeCSS | calls |
No incoming dependencies.