1const detox = require('detox'); 2const adapter = require('detox/runners/mocha/adapter'); 3const execFile = require('child_process').execFile; 4let config = require('../package.json').detox; 5 6if (process.env['ANDROID_AVD'] != null) { 7 config = config.replace(/"name":\s?"TestingAVD"/, `"name": ${process.env['ANDROID_AVD']}`) 8} 9 10let server; 11 12before(async () => { 13 server = execFile('yarn', ['run', 'start'], {}); 14 await detox.init(config); 15}); 16 17beforeEach(async function () { 18 await adapter.beforeEach(this); 19}); 20 21afterEach(async function () { 22 await adapter.afterEach(this); 23}); 24 25after(async () => { 26 await detox.cleanup(); 27 execFile('yarn', ['run', 'stop'], {}); 28}); 29