Skip to content

Commit 67fdfc4

Browse files
Restore paperComponentName: 'RCTSwitch' to fix @testing-library/react-native queries
Summary: Restore `paperComponentName: 'RCTSwitch'` in `SwitchNativeComponent.js` and regenerate affected snapshots to fix test breakages introduced by D117877024. `testing-library/react-native` 13.3.3 hardcodes `HOST_SWITCH_NAMES = ['RCTSwitch']`, so renaming the component to `Switch` broke `getByRole('switch')` queries and `toBeChecked()` assertions. This was the only xplat/js-wide breakage from that diff—only bare `<Switch>` renders without explicit `accessible` props failed, and only in `TWInternBoolSettingComponent-test.js`. Add an inline comment documenting the `testing-library/react-native` constraint to prevent future regressions. The four other component renames in D117877024 have no RNTL special-casing and remain as landed. Changelog: [iOS][Fixed] Restore `paperComponentName: 'RCTSwitch'` to fix `testing-library/react-native` queries Differential Revision: D118743290
1 parent d9ad3f0 commit 67fdfc4

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

packages/react-native/src/private/components/switch/specs/SwitchNativeComponent.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
5959
});
6060

6161
export default codegenNativeComponent<SwitchNativeProps>('Switch', {
62+
// @testing-library/react-native (as of 13.3.3) only recognizes a host
63+
// component named `RCTSwitch` as a switch, so renaming this breaks every
64+
// `*ByRole('switch')` query and `toBeChecked()` assertion in Jest.
65+
paperComponentName: 'RCTSwitch',
6266
excludedPlatforms: ['android'],
6367
interfaceOnly: true,
6468
}) as ComponentType;

0 commit comments

Comments
 (0)