import { retry } from 'ts-retry-promise'; const buildDetoxURLBlacklistRegex = () => `(${constants.BLACKLISTED_URLS.map(urlRegex => `\\"${urlRegex}\\"`).join(',')})`; export const launchApp = async () => { await retry( async () => { try { await device.launchApp({ newInstance: true, launchArgs: { detoxPrintBusyIdleResources: 'YES', detoxURLBlacklistRegex: buildDetoxURLBlacklistRegex(), }, }); } catch (error) { error.message = `Failed to launch app with error: ${error.message}`; throw error; } }, { retries: 5 }, ); }; export const reloadReactNative = async () => { await retry( async () => { try { await device.reloadReactNative(); } catch (error) { // eslint-disable-next-line no-console console.error('Failed to reload react native with error', error); await launchApp(); } }, { retries: 5 }, ); };