From 67fdfc4c9e1fe81fd432841be877c900019117e1 Mon Sep 17 00:00:00 2001 From: Christoph Purrer Date: Thu, 3 Sep 2026 19:24:26 -0700 Subject: [PATCH] Restore `paperComponentName: 'RCTSwitch'` to fix `@testing-library/react-native` queries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 `` 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 --- .../private/components/switch/specs/SwitchNativeComponent.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-native/src/private/components/switch/specs/SwitchNativeComponent.js b/packages/react-native/src/private/components/switch/specs/SwitchNativeComponent.js index caf83edcd48e..cbc48fc4296c 100644 --- a/packages/react-native/src/private/components/switch/specs/SwitchNativeComponent.js +++ b/packages/react-native/src/private/components/switch/specs/SwitchNativeComponent.js @@ -59,6 +59,10 @@ export const Commands: NativeCommands = codegenNativeCommands({ }); export default codegenNativeComponent('Switch', { + // @testing-library/react-native (as of 13.3.3) only recognizes a host + // component named `RCTSwitch` as a switch, so renaming this breaks every + // `*ByRole('switch')` query and `toBeChecked()` assertion in Jest. + paperComponentName: 'RCTSwitch', excludedPlatforms: ['android'], interfaceOnly: true, }) as ComponentType;