1import * as detox from 'detox'; 2import { startAsync, send } from '../../relapse/server'; 3 4let stopAsync; 5beforeAll(async () => { 6 const customConsole = { ...console }; 7 // We only want warnings and errors from the client to show up in the jest logs 8 customConsole.log = () => {}; 9 10 // The testing modules we want to share with the client 11 const API = { 12 device: detox.device, 13 detox, 14 console: customConsole, 15 }; 16 17 stopAsync = await startAsync({ 18 onConnect: () => { 19 send({ globals: Object.keys(API) }); 20 }, 21 onEvent: (invocation, props) => { 22 const [module, method] = invocation.split('.'); 23 API[module][method](...props); 24 // eval(`${fcName}(${props[0]})`); 25 }, 26 }); 27}); 28 29afterAll(async () => { 30 if (stopAsync) { 31 await stopAsync(); 32 } 33}); 34