1import { by, device, element, expect, waitFor } from 'detox'; 2 3import { sleepAsync } from './Utils'; 4import { expectResults } from './utils/report'; 5 6export const TESTS = [ 7 'Basic', 8 // 'Asset', 9 // 'FileSystem', 10 // 'Font', 11 'Permissions', 12 // 'Blur', 13 'LinearGradient', 14 'Constants', 15 // 'Contacts', 16 'Crypto', 17 // 'GLView', 18 'Haptics', 19 'Localization', 20 // 'SecureStore', 21 // 'Segment', 22 // 'SQLite', 23 'Random', 24 'Permissions', 25 'KeepAwake', 26 // 'Audio', 27 'HTML', 28]; 29 30const MIN_TIME = 50000; 31 32describe('test-suite', () => { 33 TESTS.map((testName) => { 34 it( 35 `passes ${testName}`, 36 async () => { 37 const platform = device.getPlatform(); 38 const launchArgs = { 39 EXDevMenuIsOnboardingFinished: true, 40 }; 41 if (platform === 'android') { 42 launchArgs['class'] = 'dev.expo.payments.DetoxTest'; 43 } 44 await device.launchApp({ 45 newInstance: true, 46 url: `bareexpo://test-suite/run?tests=${testName}`, 47 launchArgs, 48 }); 49 50 const launchWaitingTime = platform === 'ios' ? 1000 : 5000; 51 await sleepAsync(launchWaitingTime); 52 53 await expect(element(by.id('test_suite_container'))).toExist(); 54 try { 55 await waitFor(element(by.id('test_suite_text_results'))) 56 .toExist() 57 .withTimeout(MIN_TIME); 58 } catch { 59 // test hasn't completed within the timeout 60 // continue and log the intermediate results 61 } 62 63 if (platform === 'ios') { 64 const attributes = await element(by.id('test_suite_final_results')).getAttributes(); 65 const input = attributes.text; 66 expectResults({ 67 testName, 68 input, 69 }); 70 } else { 71 // Platforms do no support `getAttributes()`, using text matching instead 72 await expect(element(by.id('test_suite_text_results'))).toHaveText( 73 'Complete: 0 tests failed.' 74 ); 75 } 76 }, 77 MIN_TIME * 1.5 78 ); 79 }); 80}); 81