Read testID from custom layout props in BaseToast
Is your feature request related to a problem? Please describe. We'd like to test if the right Toast message is shown using Detox end to end tests. please see details on this stackoverflow question
Describe the solution you'd like The solution today is to check with Detox for the internal testIDs ( testID={getTestId('TouchableContainer')} ) Wich can be broken by id update (they are internal ids) and cannot be configured to check which type of toast is shown.
Describe alternatives you've considered
BaseToast should accept a testID props, defaulting to "toast" So the final test id could be
testID=${testID}${elementName};
Users would then be able to set their own test Ids on Base/Success/Error Toasts. like so :
export const toastConfig = {
/*
Overwrite 'success' type,
by modifying the existing `BaseToast` component
*/
success: (props) => (
<BaseToast
{...props}
testID="Toast.success" // not found by detox
/>
),...
If that's alright I might create the PR myself.
PR #604 is open.
BaseToast now accepts a custom testID prefix and applies it to TouchableContainer, ContentContainer, Text1, and Text2. The default remains toast, so every existing internal selector is unchanged; nested component props can still override a specific node when needed.
Verification: focused BaseToast 9/9, full yarn quality 18 suites / 84 tests with 100% coverage, plus typecheck, lint, build, and diff-check.