Skip to content

fix: remove hardcoded default testIDs from components - #5088

Open
k0ndee wants to merge 1 commit into
callstack:mainfrom
k0ndee:@k0ndee/default_testids
Open

fix: remove hardcoded default testIDs from components#5088
k0ndee wants to merge 1 commit into
callstack:mainfrom
k0ndee:@k0ndee/default_testids

Conversation

@k0ndee

@k0ndee k0ndee commented Sep 1, 2026

Copy link
Copy Markdown

Motivation

Several components fell back to a hardcoded default testID (e.g. testID = 'button', testID = 'card', testID = 'search-bar') whenever a consumer didn't pass one explicitly. This meant every instance of a component rendered without an explicit testID still emitted a fixed, non-configurable testID into the tree leading to duplicate/colliding testIDs when multiple instances of the same component render on screen.

This PR removes all hardcoded default testID values so that testID is undefined unless a consumer explicitly provides one. Suffixed child testIDs (e.g. `${testID}-container`) are now only rendered when a testID is explicitly given, instead of always deriving from the removed default.

Along the way this surfaced two latent bugs that the hardcoded defaults had been masking:

  • IconButton never forwarded its testID down into the inner icon, relying on CrossFadeIcon's own default instead. Now it forwards ${testID}-icon explicitly.
  • FAB.Menu's trigger wrapper put testID on a non-interactive positioning View instead of the actual pressable Shell, which only worked before because Shell had its own hardcoded default in the right place.

Affected components: Button, Card, Chip, Surface, Modal, Menu, Menu.Item, IconButton, Searchbar, CrossFadeIcon, ProgressBar, Appbar.Header, Appbar.Content, Drawer.CollapsedItem, FAB, FAB.Extended, FAB.Menu, BottomNavigation, BottomNavigationBar.

Test plan

  • yarn typecheck passes.
  • yarn lint passes.
  • yarn jest passes (55 suites, 732 tests, 169 snapshots — snapshots updated to reflect the removed default testID attributes).
  • Updated unit tests that relied on the old default testID strings (Button, Card, Menu, Menu.Item, Drawer.CollapsedItem, FAB.Menu, ListItem, Appbar, BottomNavigation) to pass an explicit testID where the assertion actually needs one.
  • No behavior change for consumers who already pass an explicit testID, only the implicit-default fallback is removed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant