Detox Launch & Reload functions

PHOTO EMBED

Mon Mar 28 2022 22:21:47 GMT+0000 (Coordinated Universal Time)

Saved by @gnarwall19

import { retry } from 'ts-retry-promise'

export const launchApp = async (
  launchArgs = {
    newInstance: true,
    permissions: { notifications: 'YES', contacts: 'YES' },
    launchArgs: {
      detoxPrintBusyIdleResources: 'YES',
    },
  }
) => {
  await retry(
    async () => {
      try {
        await device.launchApp(launchArgs)
      } catch (error) {
        error.message = `Failed to launch app with error: ${error.message}`
        throw error
      }
    },
    { retries: 5, delay: 10000, timeout: 300000 }
  )
}

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, delay: 10000, timeout: 300000 }
  )
}
content_copyCOPY

https://github.com/valora-inc/wallet/blob/main/packages/mobile/e2e/src/utils/retries.js