forked from wix/Detox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetoxConfigErrorComposer.js
More file actions
745 lines (654 loc) · 24.2 KB
/
Copy pathDetoxConfigErrorComposer.js
File metadata and controls
745 lines (654 loc) · 24.2 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
const _ = require('lodash');
const deviceAppTypes = require('../configuration/utils/deviceAppTypes');
const DetoxConfigError = require('./DetoxConfigError');
const DetoxInternalError = require('./DetoxInternalError');
const J = s => JSON.stringify(s);
class DetoxConfigErrorComposer {
constructor() {
this.setConfigurationName();
this.setDetoxConfigPath();
this.setDetoxConfig();
this.setExtends();
}
clone() {
return new DetoxConfigErrorComposer()
.setConfigurationName(this.configurationName)
.setDetoxConfigPath(this.filepath)
.setDetoxConfig(this.contents)
.setExtends(this._extends);
}
_atPath() {
return this.filepath ? ` at path:\n${this.filepath}` : '.';
}
_getSelectedConfiguration() {
return _.get(this.contents, ['configurations', this.configurationName]);
}
_focusOnConfiguration(postProcess = _.identity) {
const configuration = _.get(this.contents, ['configurations', this.configurationName]);
if (configuration === undefined) {
return;
}
return {
configurations: {
[this.configurationName]: postProcess(configuration)
},
};
}
_getDeviceConfig(deviceAlias) {
let config = undefined;
this._focusOnDeviceConfig(deviceAlias, (value) => {
config = value;
return value;
});
return config;
}
_focusOnDeviceConfig(deviceAlias, postProcess = _.identity) {
const { device } = this._getSelectedConfiguration();
if (!deviceAlias) {
// istanbul ignore next
if (!device) {
return this._focusOnConfiguration(postProcess);
} else {
return this._focusOnConfiguration(c => {
postProcess(c.device);
return _.pick(c, 'device');
});
}
}
return {
devices: {
[device]: postProcess(this.contents.devices[device]),
},
};
}
_focusOnAppConfig(appPath, postProcess = _.identity) {
const value = _.get(this.contents, appPath);
return _.set({}, appPath, postProcess(value));
}
_resolveSelectedDeviceConfig(alias) {
if (alias) {
return this.contents.devices[alias];
} else {
return this._getSelectedConfiguration().device;
}
}
_ensureProperty(...names) {
return obj => {
for (const name of names) {
return _.set(obj, name, _.get(obj, name));
}
};
}
// region setters
setConfigurationName(configurationName) {
this.configurationName = configurationName || '';
return this;
}
setDetoxConfigPath(filepath) {
this.filepath = filepath || '';
return this;
}
setDetoxConfig(contents) {
this.contents = contents || null;
return this;
}
setExtends(value) {
this._extends = !!value;
return this;
}
// endregion
// region CLI options validation
mutuallyExclusiveCliOptions(option1, option2) {
return new DetoxConfigError({
message: `The ${J(option1)} and ${J(option2)} options cannot be used together`,
hint: `These options are mutually exclusive. Please use either ${option1} or ${option2}, but not both.`
});
}
// endregion
// region configuration/index
noConfigurationSpecified() {
return new DetoxConfigError({
message: 'Cannot run Detox without a configuration file.',
hint: _.endsWith(this.filepath, 'package.json')
? `Create an external .detoxrc.json configuration, or add "detox" configuration section to your package.json at:\n${this.filepath}`
: 'Make sure to create external .detoxrc.json configuration in the working directory before you run Detox.'
});
}
noConfigurationAtGivenPath(givenPath) {
const message = this._extends
? `Failed to find the base Detox config specified in:\n{\n "extends": ${J(givenPath)}\n}`
: `Failed to find Detox config at ${J(givenPath)}`;
const hint = this._extends
? `Check your Detox config${this._atPath()}`
: 'Make sure the specified path is correct.';
return new DetoxConfigError({ message, hint });
}
failedToReadConfiguration(unknownError) {
return new DetoxConfigError({
message: 'An error occurred while trying to load Detox config from:\n' + this.filepath,
debugInfo: unknownError,
});
}
noConfigurationsInside() {
return new DetoxConfigError({
message: `There are no configurations in the given Detox config${this._atPath()}`,
hint: `Examine the config:`,
debugInfo: this.contents ? {
configurations: undefined,
...this.contents,
} : {},
inspectOptions: { depth: 1 },
});
}
cantChooseConfiguration() {
const configurations = this.contents.configurations;
return new DetoxConfigError({
message: `Cannot determine which configuration to use from Detox config${this._atPath()}`,
hint: 'Use --configuration to choose one of the following:\n' + hintList(configurations),
});
}
noConfigurationWithGivenName() {
const configurations = this.contents.configurations;
return new DetoxConfigError({
message: `Failed to find a configuration named ${J(this.configurationName)} in Detox config${this._atPath()}`,
hint: 'Below are the configurations Detox was able to find:\n' + hintList(configurations),
});
}
configurationShouldNotBeEmpty() {
const name = this.configurationName;
const configurations = this.contents.configurations;
return new DetoxConfigError({
message: `Cannot use an empty configuration ${J(name)}.`,
hint: `A valid configuration should have "device" and "app" properties defined, e.g.:\n
{
"apps": {
*-->"myApp.ios": {
| "type": "ios.app",
| "binaryPath": "path/to/app"
| },
| },
| "devices": {
|*->"simulator": {
|| "type": "ios.simulator",
|| "device": { type: "iPhone 12" }
|| },
||},
||"configurations": {
|| ${J(name)}: {
|*--- "device": "simulator",
*---- "app": "myApp.ios"
}
}
}
Examine your Detox config${this._atPath()}`,
debugInfo: {
configurations: {
[name]: configurations[name],
...configurations,
}
},
inspectOptions: { depth: 1 }
});
}
configurationShouldNotUseLegacyFormat() {
const name = this.configurationName;
const localConfig = this._getSelectedConfiguration();
/* istanbul ignore next */
const deviceType = localConfig.type || '';
const isAndroid = deviceType.startsWith('android.');
const isIOS = deviceType.startsWith('ios.');
const appName = 'myApp' + (isIOS ? '.ios' : '') + (isAndroid ? '.android' : '');
const deviceName = isIOS ? 'simulator' : isAndroid ? 'emulator' : 'myDevice';
const appType = isIOS ? 'ios.app' : isAndroid ? 'android.apk' : '<optional property>';
const binaryPath = isIOS || isAndroid ? localConfig.binaryPath : (localConfig.binaryPath || '<optional property>');
const deviceQuery = isIOS || isAndroid ? localConfig.device : (localConfig.device || '<optional property>');
return new DetoxConfigError({
message: `The ${J(name)} configuration utilizes a deprecated all-in-one schema, that is not supported ` +
`by the current version of Detox.`,
hint: `Remove the "type" property. A valid configuration is expected to have both the "device" and "app" aliases ` +
`pointing to the corresponding keys in the 'devices' and 'apps' config sections. For example:\n
{
"apps": {
*-->${J(appName)}: {
| "type": ${J(appType)},
| "binaryPath": ${J(binaryPath)},
| },
| },
| "devices": {
|*->${J(deviceName)}: {
|| "type": ${J(deviceType)},
|| "device": ${J(deviceQuery)}
|| },
||},
||"configurations": {
|| ${J(name)}: {
|| /* REMOVE (!) "type": ${J(deviceType)} */
|*--- "device": ${J(deviceName)},
*---- "app": ${J(appName)},
...
}
}
}
Examine your Detox config${this._atPath()}`,
debugInfo: {
apps: this.contents.apps
? _.mapValues(this.contents.apps, _.constant({}))
: undefined,
devices: this.contents.devices
? _.mapValues(this.contents.devices, _.constant({}))
: undefined,
...this._focusOnConfiguration(),
},
inspectOptions: { depth: 2 }
});
}
// endregion
// region composeDeviceConfig
thereAreNoDeviceConfigs(deviceAlias) {
return new DetoxConfigError({
message: `Cannot use device alias ${J(deviceAlias)} since there is no "devices" config in Detox config${this._atPath()}`,
hint: `\
You should create a dictionary of device configurations in Detox config, e.g.:
{
"devices": {
*-> ${J(deviceAlias)}: {
| "type": "ios.simulator", // or "android.emulator", or etc...
| "device": { "type": "iPhone 12" }, // or e.g.: { "avdName": "Pixel_API_29" }
| }
| },
| "configurations": {
| ${J(this.configurationName)}: {
*---- "device": ${J(deviceAlias)},
...
}
}
}\n`,
});
}
cantResolveDeviceAlias(alias) {
return new DetoxConfigError({
message: `Failed to find a device config ${J(alias)} in the "devices" dictionary of Detox config${this._atPath()}`,
hint: 'Below are the device configurations Detox was able to find:\n'
+ hintList(this.contents.devices) + '\n\n'
+ `Check your configuration ${J(this.configurationName)}:`,
debugInfo: this._getSelectedConfiguration(),
inspectOptions: { depth: 0 },
});
}
deviceConfigIsUndefined() {
return new DetoxConfigError({
message: `Missing "device" property in the selected configuration ${J(this.configurationName)}:`,
hint: `It should be an alias to the device config, or the device config itself, e.g.:
{
...
"devices": {
*-> "myDevice": {
| "type": "ios.simulator", // or "android.emulator", or etc...
| "device": { "type": "iPhone 12" }, // or e.g.: { "avdName": "Pixel_API_29" }
| }
| },
| "configurations": {
| ${J(this.configurationName)}: {
*---- "device": "myDevice", // or { type: 'ios.simulator', ... }
...
},
...
}
}
Examine your Detox config${this._atPath()}`,
});
}
missingDeviceType(deviceAlias) {
return new DetoxConfigError({
message: `Missing "type" inside the device configuration.`,
hint: `Usually, "type" property should hold the device type to test on (e.g. "ios.simulator" or "android.emulator").\n` +
`Check that in your Detox config${this._atPath()}`,
debugInfo: this._focusOnDeviceConfig(deviceAlias, this._ensureProperty('type')),
inspectOptions: { depth: 3 },
});
}
invalidDeviceType(deviceAlias, deviceConfig, innerError) {
return new DetoxConfigError({
message: `Invalid device type ${J(deviceConfig.type)} inside your configuration.`,
hint: `Did you mean to use one of these?
${hintList(deviceAppTypes)}
P.S. If you intended to use a third-party driver, please resolve this error:
${innerError.message}
Please check your Detox config${this._atPath()}`,
debugInfo: this._focusOnDeviceConfig(deviceAlias, this._ensureProperty('type')),
inspectOptions: { depth: 3 },
});
}
_invalidPropertyType(propertyName, expectedType, deviceAlias) {
return new DetoxConfigError({
message: `Invalid type of ${J(propertyName)} inside the device configuration.\n`
+ `Expected ${expectedType}.`,
hint: `Check that in your Detox config${this._atPath()}`,
debugInfo: this._focusOnDeviceConfig(deviceAlias),
inspectOptions: { depth: 3 },
});
}
_unsupportedPropertyByDeviceType(propertyName, supportedDeviceTypes, deviceAlias) {
const { type } = this._getDeviceConfig(deviceAlias);
return new DetoxConfigError({
message: `The current device type ${J(type)} does not support ${J(propertyName)} property.`,
hint: `You can use this property only with the following device types:\n` +
hintList(supportedDeviceTypes) + '\n\n' +
`Please fix your Detox config${this._atPath()}`,
debugInfo: this._focusOnDeviceConfig(deviceAlias),
inspectOptions: { depth: 4 },
});
}
malformedDeviceProperty(deviceAlias, propertyName) {
switch (propertyName) {
case 'bootArgs':
return this._invalidPropertyType('bootArgs', 'a string', deviceAlias);
case 'utilBinaryPaths':
return this._invalidPropertyType('utilBinaryPaths', 'an array of strings', deviceAlias);
case 'forceAdbInstall':
return this._invalidPropertyType('forceAdbInstall', 'a boolean value', deviceAlias);
case 'gpuMode':
return this._invalidPropertyType('gpuMode', "'auto' | 'host' | 'swiftshader_indirect' | 'angle_indirect' | 'guest' | 'off'", deviceAlias);
case 'headless':
return this._invalidPropertyType('headless', 'a boolean value', deviceAlias);
case 'readonly':
return this._invalidPropertyType('readonly', 'a boolean value', deviceAlias);
case 'systemUI':
return this._invalidPropertyType('systemUI', "'minimal', 'genymotion' or an object", deviceAlias);
default:
throw new DetoxInternalError(`Composing .malformedDeviceProperty(${propertyName}) is not implemented`);
}
}
unsupportedDeviceProperty(deviceAlias, propertyName) {
switch (propertyName) {
case 'bootArgs':
return this._unsupportedPropertyByDeviceType('bootArgs', ['ios.simulator', 'android.emulator'], deviceAlias);
case 'forceAdbInstall':
return this._unsupportedPropertyByDeviceType('forceAdbInstall', ['android.attached', 'android.emulator', 'android.genycloud'], deviceAlias);
case 'gpuMode':
return this._unsupportedPropertyByDeviceType('gpuMode', ['android.emulator'], deviceAlias);
case 'headless':
return this._unsupportedPropertyByDeviceType('headless', ['ios.simulator', 'android.emulator'], deviceAlias);
case 'readonly':
return this._unsupportedPropertyByDeviceType('readonly', ['android.emulator'], deviceAlias);
case 'utilBinaryPaths':
return this._unsupportedPropertyByDeviceType('utilBinaryPaths', ['android.attached', 'android.emulator', 'android.genycloud'], deviceAlias);
case 'systemUI':
return this._unsupportedPropertyByDeviceType('systemUI', ['android.emulator', 'android.genycloud', 'android.attached'], deviceAlias);
default:
throw new DetoxInternalError(`Composing .unsupportedDeviceProperty(${propertyName}) is not implemented`);
}
}
missingDeviceMatcherProperties(deviceAlias, expectedProperties) {
const { type } = this._resolveSelectedDeviceConfig(deviceAlias);
return new DetoxConfigError({
message: `Invalid or empty "device" matcher inside the device config.`,
hint: `It should have the device query to run on, e.g.:\n
{
"type": ${J(type)},
"device": ${expectedProperties.map(p => `{ ${J(p)}: ... }`).join('\n // or ')}
}
Check that in your Detox config${this._atPath()}`,
debugInfo: this._focusOnDeviceConfig(deviceAlias),
inspectOptions: { depth: 4 },
});
}
// endregion
// region composeAppsConfig
thereAreNoAppConfigs(appAlias) {
return new DetoxConfigError({
message: `Cannot use app alias ${J(appAlias)} since there is no "apps" config in Detox config${this._atPath()}`,
hint: `\
You should create a dictionary of app configurations in Detox config, e.g.:
{
"apps": {
*-> ${J(appAlias)}: {
| "type": "ios.app", // or "android.apk", or etc...
| "binaryPath": "path/to/your/app", // ... and so on
| }
| },
| "configurations": {
| ${J(this.configurationName)}: {
*---- "app": ${J(appAlias)},
...
}
}
}\n`,
});
}
cantResolveAppAlias(appAlias) {
return new DetoxConfigError({
message: `Failed to find an app config ${J(appAlias)} in the "apps" dictionary of Detox config${this._atPath()}`,
hint: 'Below are the app configurations Detox was able to find:\n' + hintList(this.contents.apps) +
`\n\nCheck your configuration ${J(this.configurationName)}:`,
debugInfo: this._getSelectedConfiguration(),
inspectOptions: { depth: 1 },
});
}
appConfigIsUndefined(appPath) {
const appProperty = appPath[2] === 'apps'
? `"apps": [..., "myApp", ...]`
: `"app": "myApp"`;
return new DetoxConfigError({
message: `Undefined or empty app config in the selected ${J(this.configurationName)} configuration:`,
hint: `\
It should be an alias to an existing app config in "apps" dictionary, or the config object itself, e.g.:
{
"apps": {
*-> "myApp": {
| "type": "ios.app", // or "android.apk", or etc...
| "binaryPath": "path/to/your/app", // ... and so on
| }
| },
| "configurations": {
| ${J(this.configurationName)}: {
*---- ${appProperty}
...
}
}
Examine your Detox config${this._atPath()}`,
debugInfo: this._focusOnConfiguration(),
inspectOptions: { depth: 2 }
});
}
malformedAppLaunchArgs(appPath) {
return new DetoxConfigError({
message: `Invalid type of "launchArgs" property in the app config.\nExpected an object:`,
debugInfo: this._focusOnAppConfig(appPath),
inspectOptions: { depth: 4 },
});
}
unsupportedReversePorts(appPath) {
return new DetoxConfigError({
message: `Non-Android app configs cannot have "reversePorts" property:`,
debugInfo: this._focusOnAppConfig(appPath),
inspectOptions: { depth: 4 },
});
}
missingAppBinaryPath(appPath) {
return new DetoxConfigError({
message: `Missing "binaryPath" property in the app config.\nExpected a string:`,
debugInfo: this._focusOnAppConfig(appPath, this._ensureProperty('binaryPath')),
inspectOptions: { depth: 4 },
});
}
invalidAppType({ appPath, allowedAppTypes, deviceType }) {
return new DetoxConfigError({
message: `Invalid app "type" property in the app config.\nExpected ${allowedAppTypes.map(J).join(' or ')}.`,
hint: `\
You have a few options:
1. Replace the value with the suggestion.
2. Use a correct device type with this app config. Currently you have ${J(deviceType)}.`,
debugInfo: this._focusOnAppConfig(appPath),
inspectOptions: { depth: 4 },
});
}
duplicateAppConfig({ appName, appPath, preExistingAppPath }) {
const config1 = { ..._.get(this.contents, preExistingAppPath) };
config1.name = config1.name || '<GIVE IT A NAME>';
const config2 = { ..._.get(this.contents, appPath) };
config2.name = '<GIVE IT ANOTHER NAME>';
const name = this.configurationName;
const hintMessage = appName
? `Both apps use the same name ${J(appName)} — try giving each app a unique name.`
: `The app configs are missing "name" property that serves to distinct them.`;
return new DetoxConfigError({
message: `App collision detected in the selected configuration ${J(name)}.`,
hint: `\
${hintMessage}
detox → ${preExistingAppPath.join(' → ')}:
${DetoxConfigError.inspectObj(config1, { depth: 0 })}
detox → ${appPath.join(' → ')}:
${DetoxConfigError.inspectObj(config2, { depth: 0 })}
Examine your Detox config${this._atPath()}`,
});
}
noAppIsDefined(deviceType) {
const name = this.configurationName;
const [appType] = deviceAppTypes[deviceType] || [''];
const [appPlatform] = appType.split('.');
const appAlias = appType ? `myApp.${appPlatform}` : 'myApp';
return new DetoxConfigError({
message: `The ${J(name)} configuration has no defined "app" config.`,
hint: `There should be an inlined object or an alias to the app config, e.g.:\n
{
"apps": {
*-->"${appAlias}": {
| "type": "${appType || 'someAppType'}",
| "binaryPath": "path/to/app"
| },
| },
| "configurations": {
| ${J(name)}: {
*---- "app": "${appAlias}"
...
}
}
}
Examine your Detox config${this._atPath()}`,
debugInfo: this._focusOnConfiguration(),
inspectOptions: { depth: 0 }
});
}
ambiguousAppAndApps() {
return new DetoxConfigError({
message: `You can't have both "app" and "apps" defined in the ${J(this.configurationName)} configuration.`,
hint: 'Use "app" if you have a single app to test.' +
'\nUse "apps" if you have multiple apps to test.' +
`\n\nCheck your Detox config${this._atPath()}`,
debugInfo: this._focusOnConfiguration(this._ensureProperty('app', 'apps')),
inspectOptions: { depth: 2 },
});
}
multipleAppsConfigArrayTypo() {
return new DetoxConfigError({
message: `Invalid type of the "app" property in the selected configuration ${J(this.configurationName)}.`,
hint: 'Rename "app" to "apps" if you plan to work with multiple apps.' +
`\n\nCheck your Detox config${this._atPath()}`,
debugInfo: this._focusOnConfiguration(this._ensureProperty('app')),
inspectOptions: { depth: 2 },
});
}
multipleAppsConfigShouldBeArray() {
return new DetoxConfigError({
message: `Expected an array in "apps" property in the selected configuration ${J(this.configurationName)}.`,
hint: 'Rename "apps" to "app" if you plan to work with a single app.' +
'\nOtherwise, make sure "apps" contains a valid array of app aliases or inlined app configs.' +
`\n\nCheck your Detox config${this._atPath()}`,
debugInfo: this._focusOnConfiguration(this._ensureProperty('apps')),
inspectOptions: { depth: 3 },
});
}
// endregion
// region composeSessionConfig
invalidServerProperty() {
return new DetoxConfigError({
message: `session.server property is not a valid WebSocket URL`,
hint: `Expected something like "ws://localhost:8099".\nCheck that in your Detox config${this._atPath()}`,
inspectOptions: { depth: 3 },
debugInfo: _.omitBy({
session: _.get(this.contents, ['session']),
...this._focusOnConfiguration(c => _.pick(c, ['session'])),
}, _.isEmpty),
});
}
invalidSessionIdProperty() {
return new DetoxConfigError({
message: `session.sessionId property should be a non-empty string`,
hint: `Check that in your Detox config${this._atPath()}`,
inspectOptions: { depth: 3 },
debugInfo: _.omitBy({
session: _.get(this.contents, ['session']),
...this._focusOnConfiguration(c => _.pick(c, ['session'])),
}, _.isEmpty),
});
}
invalidDebugSynchronizationProperty() {
return new DetoxConfigError({
message: `session.debugSynchronization should be a positive number`,
hint: `Check that in your Detox config${this._atPath()}`,
inspectOptions: { depth: 3 },
debugInfo: _.omitBy({
session: _.get(this.contents, ['session']),
...this._focusOnConfiguration(c => _.pick(c, ['session'])),
}, _.isEmpty),
});
}
invalidIgnoreUnexpectedMessagesProperty() {
return new DetoxConfigError({
message: `session.ignoreUnexpectedMessages should be a boolean value`,
hint: `Check that in your Detox config${this._atPath()}`,
inspectOptions: { depth: 3 },
debugInfo: _.omitBy({
session: _.get(this.contents, ['session']),
...this._focusOnConfiguration(c => _.pick(c, ['session'])),
}, _.isEmpty),
});
}
invalidTestRunnerProperty(isGlobal) {
const testRunner = _.get(
isGlobal
? this.contents
: this._getSelectedConfiguration(),
['testRunner']
);
return new DetoxConfigError({
message: `testRunner should be an object, not a ${typeof testRunner}`,
hint: `Check that in your Detox config${this._atPath()}`,
inspectOptions: { depth: isGlobal ? 0 : 3 },
debugInfo: isGlobal ? {
testRunner,
...this.contents,
} : {
...this._focusOnConfiguration(c => _.pick(c, ['testRunner'])),
},
});
}
cannotSkipAutostartWithMissingServer() {
return new DetoxConfigError({
message: `Cannot have both an undefined session.server URL and session.autoStart set to false`,
hint: `Check that in your Detox config${this._atPath()}`,
inspectOptions: { depth: 3 },
debugInfo: _.omitBy({
session: _.get(this.contents, ['session']),
...this._focusOnConfiguration(c => _.pick(c, ['session'])),
}, _.isEmpty),
});
}
// endregion
missingBuildScript(appConfig) {
return new DetoxConfigError({
message: `\
Failed to build the app for the configuration ${J(this.configurationName)}, because \
there was no "build" script inside.
Check contents of your Detox config${this._atPath()}`,
debugInfo: { build: undefined, ...appConfig },
inspectOptions: { depth: 0 },
});
}
}
function hintList(items) {
const values = Array.isArray(items) ? items : _.keys(items);
return values.map(c => `* ${c}`).join('\n');
}
module.exports = DetoxConfigErrorComposer;