Menu

1 / 2

Require the agent to leave existing test IDs alone unless the test changes in the same PR

DEV Community: frontend·Sherotree·1 day ago
#QhfhuIjZ
#devtofrontend#devto#dev#test#agent
Reading 0:00
15s threshold

The component PR looks small. The bug is fixed. Then CI goes red in a file the agent never opened: checkout.spec.ts can’t find [data-testid="pay-cta"] . The agent renamed it to checkout-submit because the new name “was clearer.”

I’ve started treating silent test-id edits as a merge blocker, not a style nit. Selectors are a contract with tests you may not have in the same checkout.

Why agents rename them

Common reasons, all locally reasonable:

The id didn’t match the new label

A linter or the model’s taste prefers BEM, camelCase, or a longer name

The agent “cleaned up” inconsistent naming across a file

It moved a button into a child component and “updated the hook to match”

None of those are a reason to break a Playwright / Testing Library / Cypress suite that wasn’t in the PR.

A simple policy

Boring rules beat debate:

Existing data-testid , data-test , and stable aria-label hooks stay unless the test (or Storybook play function) that uses them is updated in the same PR

New elements may get new…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.