1import * as detox from 'detox'; 2 3import { startAsync, send } from '../../relapse/server'; 4 5let stopAsync; 6beforeAll(async () => { 7 // const customConsole = Object.assign(Object.create(console), { 8 // // We only want warnings and errors from the client to show up in the jest logs 9 // log() {}, 10 // // RN saves a reference to the original implementation of `console.error` and calls it via 11 // // `console._errorOriginal` and the invocation is sent to Detox 12 // _errorOriginal(...args) { 13 // console.error(...args); 14 // }, 15 // }); 16 17 // The testing modules we want to share with the client 18 const API = { 19 device: detox.device, 20 detox, 21 // Using this will cause a stack overflow 22 // console: customConsole, 23 }; 24 25 stopAsync = await startAsync({ 26 onConnect: () => { 27 send({ globals: Object.keys(API) }); 28 }, 29 onEvent: (invocation, props) => { 30 const [module, method] = invocation.split('.'); 31 API[module][method](...props); 32 }, 33 }); 34}); 35 36afterAll(async () => { 37 if (stopAsync) { 38 await stopAsync(); 39 } 40}); 41