-
Notifications
You must be signed in to change notification settings - Fork 16
/
detox.config.js
123 lines (108 loc) · 2.47 KB
/
detox.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// @ts-check
/* eslint-disable @typescript-eslint/no-var-requires */
/**
* @typedef { 'Debug' | 'Release' } Configuration
*/
const fs = require('node:fs')
const process = require('node:process')
const path = require('node:path')
/**
* @returns {string}
*/
function findCurrentDeploymentTarget() {
let pbxproj = fs.readFileSync(
path.join(__dirname, 'ios', 'AllAboutOlaf.xcodeproj', 'project.pbxproj'),
{encoding: 'utf-8'},
)
const target = pbxproj
.split('\n')
.find((line) => line.includes('IPHONEOS_DEPLOYMENT_TARGET'))
?.replace(/.*IPHONEOS_DEPLOYMENT_TARGET = (.*?);/u, '$1')
if (!target || !/\d+[.]\d+/u.test(target)) {
console.error(
`Could not find valid IPHONEOS_DEPLOYMENT_TARGET; found ${target}`,
)
process.exit(1)
}
return target
}
const iPhoneSimulatorDevice = 'iPhone 11 Pro'
const currentDeploymentTarget = findCurrentDeploymentTarget()
const codeSigningDisabled = process.env.CODE_SIGNING_DISABLED === 'true'
/**
* @param {Configuration} configuration
* @returns {string}
*/
function generateBuildCommand(configuration) {
const baseCommand = [
'xcodebuild',
'-workspace ios/AllAboutOlaf.xcworkspace',
'-scheme AllAboutOlaf',
`-configuration ${configuration}`,
`-destination 'platform=iOS Simulator,name=${iPhoneSimulatorDevice},OS=${currentDeploymentTarget}'`,
'-derivedDataPath ios/build',
'build',
]
if (codeSigningDisabled) {
baseCommand.push(
'CODE_SIGN_IDENTITY=""',
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGNING_ALLOWED=NO',
)
}
return baseCommand.join(' ')
}
/**
* @param {Configuration} configuration
* @returns {string}
*/
function generateBinaryPath(configuration) {
return path.join(
'ios',
'build',
'Build',
'Products',
`${configuration}-iphonesimulator`,
'AllAboutOlaf.app',
)
}
module.exports = {
testRunner: {
$0: 'jest',
args: {
config: 'e2e/jest.config.js',
_: 'e2e',
},
},
configurations: {
'ios.sim.debug': {
device: 'ios.simulator',
app: 'ios.sim.debug',
},
'ios.sim.release': {
device: 'ios.simulator',
app: 'ios.sim.release',
},
},
apps: {
'ios.sim.debug': {
type: 'ios.app',
binaryPath: generateBinaryPath('Debug'),
build: generateBuildCommand('Debug'),
},
'ios.sim.release': {
type: 'ios.app',
binaryPath: generateBinaryPath('Release'),
build: generateBuildCommand('Release'),
},
},
devices: {
'ios.simulator': {
type: 'ios.simulator',
device: {
type: iPhoneSimulatorDevice,
os: currentDeploymentTarget,
},
},
},
}