/* eslint-env jest */
/* global device */

const detox = require('detox')
const jasmine = require('jest-jasmine2')
const config = require('../package.json').detox
const adapter = require('detox/runners/jest/adapter')

jest.setTimeout(120000)

beforeAll(async () => {
	await detox.init(config, {launchApp: false})
	jasmine.getEnv().addReporter(adapter)
})

beforeEach(async () => {
	await adapter.beforeEach()
	await device.relaunchApp({delete: true})
})

afterAll(async () => {
	await adapter.afterAll()
	await detox.cleanup()
})

/* eslint-env jest */
/* global device */

import { init, cleanup } from 'detox'
import { getEnv } from 'jest-jasmine2'
import { detox as config } from '../package.json'
import adapter, { beforeEach as _beforeEach, afterAll as _afterAll } from 'detox/runners/jest/adapter'

jest.setTimeout(120000)

beforeAll(async () => {
	await init(config, {launchApp: false})
	getEnv().addReporter(adapter)
})

beforeEach(async () => {
	await _beforeEach()
	await device.relaunchApp({delete: true})
})

afterAll(async () => {
	await _afterAll()
	await cleanup()
})

convert e2e/init.js to a module