detox 19.13.0 → 20.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/Detox-android/com/wix/detox/{19.13.0/detox-19.13.0-javadoc.jar → 20.0.0/detox-20.0.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.13.0/detox-19.13.0-sources.jar → 20.0.0/detox-20.0.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.13.0/detox-19.13.0.pom → 20.0.0/detox-20.0.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.sha512 +1 -0
- package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
- package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
- package/Detox-ios-src.tbz +0 -0
- package/Detox-ios.tbz +0 -0
- package/README.md +1 -1
- package/android/detox/src/full/java/com/wix/detox/Detox.java +2 -59
- package/android/detox/src/full/java/com/wix/detox/NotificationDataParser.kt +3 -3
- package/index.d.ts +354 -191
- package/index.js +1 -0
- package/internals.d.ts +298 -0
- package/internals.js +4 -0
- package/local-cli/build-framework-cache.js +2 -2
- package/local-cli/build.js +7 -8
- package/local-cli/build.test.js +46 -40
- package/local-cli/clean-framework-cache.js +3 -3
- package/local-cli/cli.js +8 -7
- package/local-cli/init.js +73 -68
- package/local-cli/rebuild-framework-cache.js +1 -1
- package/local-cli/reset-lock-file.js +16 -0
- package/local-cli/templates/jest.js +14 -36
- package/local-cli/test.js +24 -282
- package/local-cli/test.test.js +394 -648
- package/local-cli/testCommand/TestRunnerCommand.js +163 -0
- package/local-cli/{utils/testCommandArgs.js → testCommand/builder.js} +10 -36
- package/local-cli/testCommand/middlewares.js +66 -0
- package/local-cli/{utils → testCommand}/warnings.js +0 -13
- package/local-cli/utils/jestInternals.js +13 -2
- package/local-cli/utils/yargsUtils.js +67 -0
- package/package.json +32 -19
- package/runners/deprecation.js +45 -0
- package/runners/jest/JestCircusEnvironment.js +3 -38
- package/runners/jest/adapter.d.ts +4 -10
- package/runners/jest/adapter.js +3 -6
- package/runners/jest/assignReporter.d.ts +4 -1
- package/runners/jest/assignReporter.js +3 -6
- package/runners/jest/globalSetup.js +1 -0
- package/runners/jest/globalTeardown.js +1 -0
- package/runners/jest/index.d.ts +60 -0
- package/runners/jest/index.js +16 -0
- package/runners/jest/index.test.js +13 -0
- package/runners/jest/reporter.js +1 -0
- package/runners/jest/reporters/DetoxReporter.js +36 -0
- package/runners/jest/specReporter.d.ts +4 -9
- package/runners/jest/specReporter.js +3 -10
- package/runners/jest/streamlineReporter.js +3 -22
- package/runners/jest/testEnvironment/index.js +205 -0
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +166 -0
- package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxInitErrorListener.js +1 -1
- package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +27 -0
- package/runners/jest/{SpecReporterImpl.js → testEnvironment/listeners/SpecReporter.js} +61 -9
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +30 -0
- package/runners/jest/testEnvironment/listeners/index.js +13 -0
- package/runners/{jest-circus → jest/testEnvironment}/utils/assertExistingContext.js +2 -2
- package/runners/jest/testEnvironment/utils/assertJestCircus27.js +70 -0
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +22 -0
- package/runners/jest/{utils → testEnvironment/utils}/getFullTestName.js +0 -0
- package/runners/jest/{utils → testEnvironment/utils}/hasTimedOut.js +0 -0
- package/runners/jest/{utils → testEnvironment/utils}/index.js +0 -0
- package/runners/jest/{utils → testEnvironment/utils}/stdout.js +0 -0
- package/runners/jest-circus/environment/index.js +6 -0
- package/runners/jest-circus/index.js +1 -10
- package/runners/jest-circus/reporter.js +1 -0
- package/runners/migration.js +37 -0
- package/runners/mocha/DetoxMochaAdapter.js +3 -35
- package/runners/mocha/adapter.d.ts +4 -7
- package/runners/mocha/adapter.js +3 -5
- package/src/DetoxWorker.js +327 -0
- package/src/android/interactions/native.js +2 -1
- package/src/artifacts/ArtifactsManager.js +51 -35
- package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
- package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
- package/src/artifacts/providers/index.js +0 -4
- package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
- package/src/artifacts/templates/artifact/Artifact.js +1 -1
- package/src/artifacts/templates/plugin/ArtifactPlugin.js +1 -1
- package/src/artifacts/utils/buildDefaultArtifactsRootDirpath.js +2 -4
- package/src/artifacts/utils/temporaryPath.js +18 -5
- package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
- package/src/client/AsyncWebSocket.js +8 -17
- package/src/client/Client.js +1 -1
- package/src/client/actions/actions.js +2 -2
- package/src/configuration/collectCliConfig.js +3 -16
- package/src/configuration/composeAppsConfig.js +12 -66
- package/src/configuration/composeArtifactsConfig.js +6 -32
- package/src/configuration/composeBehaviorConfig.js +3 -13
- package/src/configuration/composeDeviceConfig.js +38 -63
- package/src/configuration/composeLoggerConfig.js +59 -0
- package/src/configuration/composeRunnerConfig.js +127 -14
- package/src/configuration/composeSessionConfig.js +1 -3
- package/src/configuration/index.js +36 -30
- package/src/configuration/loadExternalConfig.js +1 -1
- package/src/configuration/utils/deviceAppTypes.js +0 -1
- package/src/devices/allocation/DeviceAllocator.js +4 -2
- package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +5 -3
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -5
- package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +1 -1
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +1 -1
- package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +3 -3
- package/src/devices/allocation/factories/index.js +0 -1
- package/src/devices/common/drivers/DeviceLauncher.js +2 -2
- package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +1 -1
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +4 -9
- package/src/devices/common/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
- package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
- package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +35 -10
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
- package/src/devices/runtime/RuntimeDevice.js +85 -86
- package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
- package/src/devices/runtime/drivers/android/AndroidDriver.js +3 -3
- package/src/devices/runtime/drivers/index.js +0 -1
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +4 -3
- package/src/devices/runtime/factories/ios.js +1 -8
- package/src/devices/runtime/utils/LaunchArgsEditor.js +4 -59
- package/src/devices/runtime/utils/Storage.js +4 -0
- package/src/environmentFactory.js +0 -8
- package/src/errors/DetoxConfigErrorComposer.js +92 -30
- package/src/errors/DetoxError.js +4 -0
- package/src/errors/DetoxRuntimeError.js +5 -5
- package/src/errors/index.js +2 -0
- package/src/ios/expectTwo.js +2 -1
- package/src/ipc/IPCClient.js +117 -0
- package/src/ipc/IPCServer.js +98 -0
- package/src/ipc/SessionState.js +62 -0
- package/src/logger/DetoxLogger.js +348 -0
- package/src/logger/index.js +5 -0
- package/src/logger/utils/BunyanLogger.js +76 -0
- package/src/logger/utils/CategoryThreadDispatcher.js +36 -0
- package/src/logger/utils/DetoxLogFinalizer.js +140 -0
- package/src/logger/utils/MessageStack.js +24 -0
- package/src/logger/utils/ThreadDispatcher.js +61 -0
- package/src/{utils → logger/utils}/customConsoleLogger.js +5 -4
- package/src/logger/utils/sanitizeBunyanContext.js +30 -0
- package/src/logger/utils/streamUtils.js +248 -0
- package/src/logger/utils/tracerLegacy.js +37 -0
- package/src/realms/DetoxConstants.js +13 -0
- package/src/realms/DetoxContext.js +183 -0
- package/src/realms/DetoxInternalsFacade.js +31 -0
- package/src/realms/DetoxPrimaryContext.js +261 -0
- package/src/realms/DetoxSecondaryContext.js +91 -0
- package/src/realms/index.js +10 -0
- package/src/realms/primary.js +3 -0
- package/src/realms/secondary.js +3 -0
- package/src/server/DetoxConnection.js +18 -23
- package/src/server/DetoxServer.js +7 -10
- package/src/server/DetoxSession.js +6 -6
- package/src/server/DetoxSessionManager.js +1 -1
- package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
- package/src/symbols.js +50 -0
- package/src/utils/Timer.js +58 -33
- package/src/utils/argparse.js +11 -0
- package/src/utils/childProcess/exec.js +1 -1
- package/src/utils/childProcess/spawn.js +1 -1
- package/{local-cli/utils/misc.js → src/utils/envUtils.js} +0 -9
- package/src/utils/errorUtils.js +20 -0
- package/src/utils/logger.js +2 -162
- package/src/utils/shellUtils.js +18 -0
- package/src/utils/traceInvocationCall.js +21 -0
- package/src/utils/traceMethods.js +15 -0
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar +0 -0
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.sha512 +0 -1
- package/local-cli/templates/mocha.js +0 -32
- package/local-cli/utils/splitArgv.js +0 -107
- package/runners/integration.js +0 -16
- package/runners/jest/DetoxAdapterCircus.js +0 -60
- package/runners/jest/DetoxAdapterImpl.js +0 -81
- package/runners/jest/DetoxAdapterJasmine.js +0 -67
- package/runners/jest/DetoxStreamlineJestReporter.js +0 -98
- package/runners/jest/FailingTestsReporter.js +0 -16
- package/runners/jest/SpecReporterCircus.js +0 -51
- package/runners/jest/SpecReporterJasmine.js +0 -39
- package/runners/jest/WorkerAssignReporterCircus.js +0 -17
- package/runners/jest/WorkerAssignReporterImpl.js +0 -21
- package/runners/jest/WorkerAssignReporterJasmine.js +0 -15
- package/runners/jest/runnerInfo.js +0 -9
- package/runners/jest-circus/environment.js +0 -206
- package/runners/jest-circus/listeners/DetoxCoreListener.js +0 -113
- package/runners/jest-circus/utils/assertJestCircus26.js +0 -39
- package/runners/jest-circus/utils/wrapErrorWithNoopLifecycle.js +0 -14
- package/src/Detox.js +0 -317
- package/src/DetoxConstants.js +0 -13
- package/src/DetoxExportWrapper.js +0 -140
- package/src/artifacts/timeline/TimelineArtifactPlugin.js +0 -92
- package/src/configuration/utils/warnings.js +0 -12
- package/src/devices/allocation/drivers/NoneAllocDriver.js +0 -10
- package/src/devices/allocation/factories/none.js +0 -11
- package/src/index.js +0 -6
- package/src/utils/ChromeTracingExporter.js +0 -54
- package/src/utils/MissingDetox.js +0 -78
- package/src/utils/fakeTimestampsProvider.js +0 -9
- package/src/utils/getWorkerId.js +0 -5
- package/src/utils/lastFailedTests.js +0 -38
- package/src/utils/sh.js +0 -18
- package/src/utils/trace.js +0 -96
@@ -25,16 +25,6 @@ class DetoxConfigErrorComposer {
|
|
25
25
|
_atPath() {
|
26
26
|
return this.filepath ? ` at path:\n${this.filepath}` : '.';
|
27
27
|
}
|
28
|
-
|
29
|
-
_inTheAppConfig() {
|
30
|
-
const { type } = this._getSelectedConfiguration();
|
31
|
-
if (type) {
|
32
|
-
return `in configuration ${J(this.configurationName)}`;
|
33
|
-
}
|
34
|
-
|
35
|
-
return `in the app config`;
|
36
|
-
}
|
37
|
-
|
38
28
|
_getSelectedConfiguration() {
|
39
29
|
return _.get(this.contents, ['configurations', this.configurationName]);
|
40
30
|
}
|
@@ -64,9 +54,10 @@ class DetoxConfigErrorComposer {
|
|
64
54
|
}
|
65
55
|
|
66
56
|
_focusOnDeviceConfig(deviceAlias, postProcess = _.identity) {
|
67
|
-
const {
|
57
|
+
const { device } = this._getSelectedConfiguration();
|
68
58
|
if (!deviceAlias) {
|
69
|
-
|
59
|
+
// istanbul ignore next
|
60
|
+
if (!device) {
|
70
61
|
return this._focusOnConfiguration(postProcess);
|
71
62
|
} else {
|
72
63
|
return this._focusOnConfiguration(c => {
|
@@ -92,8 +83,7 @@ class DetoxConfigErrorComposer {
|
|
92
83
|
if (alias) {
|
93
84
|
return this.contents.devices[alias];
|
94
85
|
} else {
|
95
|
-
|
96
|
-
return config.type ? config : config.device;
|
86
|
+
return this._getSelectedConfiguration().device;
|
97
87
|
}
|
98
88
|
}
|
99
89
|
|
@@ -225,6 +215,61 @@ Examine your Detox config${this._atPath()}`,
|
|
225
215
|
});
|
226
216
|
}
|
227
217
|
|
218
|
+
configurationShouldNotUseLegacyFormat() {
|
219
|
+
const name = this.configurationName;
|
220
|
+
const localConfig = this._getSelectedConfiguration();
|
221
|
+
/* istanbul ignore next */
|
222
|
+
const deviceType = localConfig.type || '';
|
223
|
+
const isAndroid = deviceType.startsWith('android.');
|
224
|
+
const isIOS = deviceType.startsWith('ios.');
|
225
|
+
const appName = 'myApp' + (isIOS ? '.ios' : '') + (isAndroid ? '.android' : '');
|
226
|
+
const deviceName = isIOS ? 'simulator' : isAndroid ? 'emulator' : 'myDevice';
|
227
|
+
const appType = isIOS ? 'ios.app' : isAndroid ? 'android.apk' : '<optional property>';
|
228
|
+
const binaryPath = isIOS || isAndroid ? localConfig.binaryPath : (localConfig.binaryPath || '<optional property>');
|
229
|
+
const deviceQuery = isIOS || isAndroid ? localConfig.device : (localConfig.device || '<optional property>');
|
230
|
+
|
231
|
+
return new DetoxConfigError({
|
232
|
+
message: `The ${J(name)} configuration utilizes a deprecated all-in-one schema, that is not supported ` +
|
233
|
+
`by the current version of Detox.`,
|
234
|
+
hint: `Remove the "type" property. A valid configuration is expected to have both the "device" and "app" aliases ` +
|
235
|
+
`pointing to the corresponding keys in the 'devices' and 'apps' config sections. For example:\n
|
236
|
+
{
|
237
|
+
"apps": {
|
238
|
+
*-->${J(appName)}: {
|
239
|
+
| "type": ${J(appType)},
|
240
|
+
| "binaryPath": ${J(binaryPath)},
|
241
|
+
| },
|
242
|
+
| },
|
243
|
+
| "devices": {
|
244
|
+
|*->${J(deviceName)}: {
|
245
|
+
|| "type": ${J(deviceType)},
|
246
|
+
|| "device": ${J(deviceQuery)}
|
247
|
+
|| },
|
248
|
+
||},
|
249
|
+
||"configurations": {
|
250
|
+
|| ${J(name)}: {
|
251
|
+
|| /* REMOVE (!) "type": ${J(deviceType)} */
|
252
|
+
|*--- "device": ${J(deviceName)},
|
253
|
+
*---- "app": ${J(appName)},
|
254
|
+
...
|
255
|
+
}
|
256
|
+
}
|
257
|
+
}
|
258
|
+
Examine your Detox config${this._atPath()}`,
|
259
|
+
debugInfo: {
|
260
|
+
apps: this.contents.apps
|
261
|
+
? _.mapValues(this.contents.apps, _.constant({}))
|
262
|
+
: undefined,
|
263
|
+
devices: this.contents.devices
|
264
|
+
? _.mapValues(this.contents.devices, _.constant({}))
|
265
|
+
: undefined,
|
266
|
+
|
267
|
+
...this._focusOnConfiguration(),
|
268
|
+
},
|
269
|
+
inspectOptions: { depth: 2 }
|
270
|
+
});
|
271
|
+
}
|
272
|
+
|
228
273
|
// endregion
|
229
274
|
|
230
275
|
// region composeDeviceConfig
|
@@ -345,7 +390,7 @@ Please check your Detox config${this._atPath()}`,
|
|
345
390
|
case 'forceAdbInstall':
|
346
391
|
return this._invalidPropertyType('forceAdbInstall', 'a boolean value', deviceAlias);
|
347
392
|
case 'gpuMode':
|
348
|
-
return this._invalidPropertyType('gpuMode', "'auto' | 'host' | 'swiftshader_indirect' | 'angle_indirect' | 'guest'", deviceAlias);
|
393
|
+
return this._invalidPropertyType('gpuMode', "'auto' | 'host' | 'swiftshader_indirect' | 'angle_indirect' | 'guest' | 'off'", deviceAlias);
|
349
394
|
case 'headless':
|
350
395
|
return this._invalidPropertyType('headless', 'a boolean value', deviceAlias);
|
351
396
|
case 'readonly':
|
@@ -364,7 +409,7 @@ Please check your Detox config${this._atPath()}`,
|
|
364
409
|
case 'gpuMode':
|
365
410
|
return this._unsupportedPropertyByDeviceType('gpuMode', ['android.emulator'], deviceAlias);
|
366
411
|
case 'headless':
|
367
|
-
return this._unsupportedPropertyByDeviceType('headless', ['android.emulator'], deviceAlias);
|
412
|
+
return this._unsupportedPropertyByDeviceType('headless', ['ios.simulator', 'android.emulator'], deviceAlias);
|
368
413
|
case 'readonly':
|
369
414
|
return this._unsupportedPropertyByDeviceType('readonly', ['android.emulator'], deviceAlias);
|
370
415
|
case 'utilBinaryPaths':
|
@@ -456,7 +501,15 @@ Examine your Detox config${this._atPath()}`,
|
|
456
501
|
|
457
502
|
malformedAppLaunchArgs(appPath) {
|
458
503
|
return new DetoxConfigError({
|
459
|
-
message: `Invalid type of "launchArgs" property
|
504
|
+
message: `Invalid type of "launchArgs" property in the app config.\nExpected an object:`,
|
505
|
+
debugInfo: this._focusOnAppConfig(appPath),
|
506
|
+
inspectOptions: { depth: 4 },
|
507
|
+
});
|
508
|
+
}
|
509
|
+
|
510
|
+
unsupportedReversePorts(appPath) {
|
511
|
+
return new DetoxConfigError({
|
512
|
+
message: `Non-Android app configs cannot have "reversePorts" property:`,
|
460
513
|
debugInfo: this._focusOnAppConfig(appPath),
|
461
514
|
inspectOptions: { depth: 4 },
|
462
515
|
});
|
@@ -464,7 +517,7 @@ Examine your Detox config${this._atPath()}`,
|
|
464
517
|
|
465
518
|
missingAppBinaryPath(appPath) {
|
466
519
|
return new DetoxConfigError({
|
467
|
-
message: `Missing "binaryPath" property
|
520
|
+
message: `Missing "binaryPath" property in the app config.\nExpected a string:`,
|
468
521
|
debugInfo: this._focusOnAppConfig(appPath, this._ensureProperty('binaryPath')),
|
469
522
|
inspectOptions: { depth: 4 },
|
470
523
|
});
|
@@ -538,18 +591,6 @@ Examine your Detox config${this._atPath()}`,
|
|
538
591
|
});
|
539
592
|
}
|
540
593
|
|
541
|
-
oldSchemaHasAppAndApps() {
|
542
|
-
return new DetoxConfigError({
|
543
|
-
message: `Your configuration ${J(this.configurationName)} appears to be in a legacy format, which can’t contain "app" or "apps".`,
|
544
|
-
hint: `Remove "type" property from configuration and use "device" property instead:\n` +
|
545
|
-
`a) "device": { "type": ${J(this._getSelectedConfiguration().type)}, ... }\n` +
|
546
|
-
`b) "device": "<alias-to-device>" // you should add that device configuration to "devices" with the same key` +
|
547
|
-
`\n\nCheck your Detox config${this._atPath()}`,
|
548
|
-
debugInfo: this._focusOnConfiguration(this._ensureProperty('type', 'device')),
|
549
|
-
inspectOptions: { depth: 2 },
|
550
|
-
});
|
551
|
-
}
|
552
|
-
|
553
594
|
ambiguousAppAndApps() {
|
554
595
|
return new DetoxConfigError({
|
555
596
|
message: `You can't have both "app" and "apps" defined in the ${J(this.configurationName)} configuration.`,
|
@@ -622,6 +663,27 @@ Examine your Detox config${this._atPath()}`,
|
|
622
663
|
});
|
623
664
|
}
|
624
665
|
|
666
|
+
invalidTestRunnerProperty(isGlobal) {
|
667
|
+
const testRunner = _.get(
|
668
|
+
isGlobal
|
669
|
+
? this.contents
|
670
|
+
: this._getSelectedConfiguration(),
|
671
|
+
['testRunner']
|
672
|
+
);
|
673
|
+
|
674
|
+
return new DetoxConfigError({
|
675
|
+
message: `testRunner should be an object, not a ${typeof testRunner}`,
|
676
|
+
hint: `Check that in your Detox config${this._atPath()}`,
|
677
|
+
inspectOptions: { depth: isGlobal ? 0 : 3 },
|
678
|
+
debugInfo: isGlobal ? {
|
679
|
+
testRunner,
|
680
|
+
...this.contents,
|
681
|
+
} : {
|
682
|
+
...this._focusOnConfiguration(c => _.pick(c, ['testRunner'])),
|
683
|
+
},
|
684
|
+
});
|
685
|
+
}
|
686
|
+
|
625
687
|
cannotSkipAutostartWithMissingServer() {
|
626
688
|
return new DetoxConfigError({
|
627
689
|
message: `Cannot have both an undefined session.server URL and session.autoStart set to false`,
|
package/src/errors/DetoxError.js
CHANGED
@@ -12,6 +12,10 @@ class DetoxError extends Error {
|
|
12
12
|
return 'Please report this issue on our GitHub tracker:\nhttps://github.com/wix/Detox/issues';
|
13
13
|
}
|
14
14
|
|
15
|
+
static get reportIssueIfJest() {
|
16
|
+
return `If you are using Detox with Jest according to the latest guide, ${_.lowerFirst(this.reportIssue)}`;
|
17
|
+
}
|
18
|
+
|
15
19
|
static inspectObj(obj, options) {
|
16
20
|
return util.inspect(obj, {
|
17
21
|
colors: false,
|
@@ -4,23 +4,23 @@ const DetoxError = require('./DetoxError');
|
|
4
4
|
|
5
5
|
/**
|
6
6
|
* @typedef DetoxRuntimeErrorOptions
|
7
|
-
* @property message { String }
|
7
|
+
* @property [message] { String }
|
8
8
|
* @property [hint] { String }
|
9
|
-
* @property [debugInfo] {
|
9
|
+
* @property [debugInfo] { * }
|
10
10
|
* @property [noStack] { Boolean }
|
11
11
|
* @property [inspectOptions] { Object }
|
12
12
|
*/
|
13
13
|
|
14
14
|
class DetoxRuntimeError extends DetoxError {
|
15
15
|
/**
|
16
|
-
* @param options { DetoxRuntimeErrorOptions }
|
16
|
+
* @param [options] { String | DetoxRuntimeErrorOptions }
|
17
17
|
*/
|
18
18
|
constructor(options) {
|
19
19
|
super(formatOptions(options));
|
20
20
|
this.name = 'DetoxRuntimeError';
|
21
21
|
|
22
|
-
if (options && options.noStack) {
|
23
|
-
|
22
|
+
if (options && typeof options !== 'string' && options.noStack) {
|
23
|
+
this.stack = '';
|
24
24
|
}
|
25
25
|
}
|
26
26
|
}
|
package/src/errors/index.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
const DetoxConfigError = require('./DetoxConfigError');
|
2
|
+
const DetoxConfigErrorComposer = require('./DetoxConfigErrorComposer');
|
2
3
|
const DetoxError = require('./DetoxError');
|
3
4
|
const DetoxInternalError = require('./DetoxInternalError');
|
4
5
|
const DetoxRuntimeError = require('./DetoxRuntimeError');
|
@@ -7,6 +8,7 @@ const DetoxRuntimeErrorComposer = require('./DetoxRuntimeErrorComposer');
|
|
7
8
|
module.exports = {
|
8
9
|
DetoxError,
|
9
10
|
DetoxConfigError,
|
11
|
+
DetoxConfigErrorComposer,
|
10
12
|
DetoxInternalError,
|
11
13
|
DetoxRuntimeError,
|
12
14
|
DetoxRuntimeErrorComposer,
|
package/src/ios/expectTwo.js
CHANGED
@@ -8,7 +8,8 @@ const tempfile = require('tempfile');
|
|
8
8
|
|
9
9
|
const { assertEnum, assertNormalized } = require('../utils/assertArgument');
|
10
10
|
const { actionDescription, expectDescription } = require('../utils/invocationTraceDescriptions');
|
11
|
-
const
|
11
|
+
const log = require('../utils/logger').child({ cat: 'ws-client, ws' });
|
12
|
+
const traceInvocationCall = require('../utils/traceInvocationCall').bind(null, log);
|
12
13
|
|
13
14
|
const assertDirection = assertEnum(['left', 'right', 'up', 'down']);
|
14
15
|
const assertSpeed = assertEnum(['fast', 'slow']);
|
@@ -0,0 +1,117 @@
|
|
1
|
+
const { IPC } = require('node-ipc');
|
2
|
+
|
3
|
+
const { DetoxInternalError } = require('../errors');
|
4
|
+
const { serializeObjectWithError } = require('../utils/errorUtils');
|
5
|
+
|
6
|
+
class IPCClient {
|
7
|
+
constructor({ id, logger, state }) {
|
8
|
+
this._id = id;
|
9
|
+
/** @type {import('../logger/DetoxLogger')} logger */
|
10
|
+
this._logger = logger.child({ cat: 'ipc' });
|
11
|
+
/** @type {import('./SessionState')} */
|
12
|
+
this._state = state;
|
13
|
+
|
14
|
+
this._client = null;
|
15
|
+
this._serverConnection = null;
|
16
|
+
}
|
17
|
+
|
18
|
+
async init() {
|
19
|
+
this._client = new IPC();
|
20
|
+
|
21
|
+
Object.assign(this._client.config, {
|
22
|
+
id: this._id,
|
23
|
+
appspace: 'detox.',
|
24
|
+
logger: (msg) => this._logger.trace(msg),
|
25
|
+
stopRetrying: 0,
|
26
|
+
maxRetries: 0,
|
27
|
+
});
|
28
|
+
|
29
|
+
await this._connectToServer();
|
30
|
+
await this._registerContext();
|
31
|
+
}
|
32
|
+
|
33
|
+
async dispose() {
|
34
|
+
this._serverConnection = null;
|
35
|
+
|
36
|
+
if (this._client) {
|
37
|
+
this._client.disconnect(this.serverId);
|
38
|
+
this._client = null;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
get sessionState() {
|
43
|
+
return this._state;
|
44
|
+
}
|
45
|
+
|
46
|
+
get serverId() {
|
47
|
+
return this.sessionState.detoxIPCServer;
|
48
|
+
}
|
49
|
+
|
50
|
+
async registerWorker(workerId) {
|
51
|
+
const sessionState = await this._emit('registerWorker', { workerId });
|
52
|
+
this._state.patch(sessionState);
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* @param {DetoxInternals.DetoxTestFileReport[]} testResults
|
57
|
+
*/
|
58
|
+
async reportTestResults(testResults) {
|
59
|
+
const sessionState = await this._emit('reportTestResults', {
|
60
|
+
testResults: testResults.map(r => serializeObjectWithError(r, 'testExecError')),
|
61
|
+
});
|
62
|
+
this._state.patch(sessionState);
|
63
|
+
}
|
64
|
+
|
65
|
+
async _connectToServer() {
|
66
|
+
const serverId = this.serverId;
|
67
|
+
|
68
|
+
this._serverConnection = await new Promise((resolve, reject) => {
|
69
|
+
this._client.connectTo(serverId, (client) => {
|
70
|
+
client.of[serverId]
|
71
|
+
.on('error', reject)
|
72
|
+
.on('disconnect', () => reject(new DetoxInternalError('IPC server has unexpectedly disconnected.')))
|
73
|
+
.on('connect', () => resolve(client.of[serverId]));
|
74
|
+
});
|
75
|
+
});
|
76
|
+
|
77
|
+
this._serverConnection.on('sessionStateUpdate', this._onSessionStateUpdate);
|
78
|
+
}
|
79
|
+
|
80
|
+
async _registerContext() {
|
81
|
+
const sessionState = await this._emit('registerContext', { id: this._id });
|
82
|
+
this._state.patch(sessionState);
|
83
|
+
}
|
84
|
+
|
85
|
+
async _emit(event, payload) {
|
86
|
+
if (!this._serverConnection) {
|
87
|
+
throw new DetoxInternalError(`IPC server ${this.serverId} has unexpectedly disconnected.`);
|
88
|
+
}
|
89
|
+
|
90
|
+
return new Promise((resolve, reject) => {
|
91
|
+
const server = this._serverConnection;
|
92
|
+
|
93
|
+
function onError(err) {
|
94
|
+
server.off('error', onError);
|
95
|
+
server.off(`${event}Done`, onDone);
|
96
|
+
reject(err);
|
97
|
+
}
|
98
|
+
|
99
|
+
function onDone(response) {
|
100
|
+
server.off(`${event}Done`, onDone);
|
101
|
+
server.off('error', onError);
|
102
|
+
resolve(response);
|
103
|
+
}
|
104
|
+
|
105
|
+
server
|
106
|
+
.on('error', onError)
|
107
|
+
.on(`${event}Done`, onDone)
|
108
|
+
.emit(event, payload);
|
109
|
+
});
|
110
|
+
}
|
111
|
+
|
112
|
+
_onSessionStateUpdate = (payload) => {
|
113
|
+
this._state.patch(payload);
|
114
|
+
};
|
115
|
+
}
|
116
|
+
|
117
|
+
module.exports = IPCClient;
|
@@ -0,0 +1,98 @@
|
|
1
|
+
const { uniqBy } = require('lodash');
|
2
|
+
const { IPC } = require('node-ipc');
|
3
|
+
|
4
|
+
const { serializeObjectWithError } = require('../utils/errorUtils');
|
5
|
+
|
6
|
+
class IPCServer {
|
7
|
+
/**
|
8
|
+
* @param {object} options
|
9
|
+
* @param {import('./SessionState')} options.sessionState
|
10
|
+
* @param {Detox.Logger} options.logger
|
11
|
+
*/
|
12
|
+
constructor({ sessionState, logger }) {
|
13
|
+
this._sessionState = sessionState;
|
14
|
+
this._logger = logger.child({ cat: 'ipc,ipc-server' });
|
15
|
+
this._ipc = null;
|
16
|
+
this._workers = new Set();
|
17
|
+
}
|
18
|
+
|
19
|
+
get id() {
|
20
|
+
return this._sessionState.detoxIPCServer;
|
21
|
+
}
|
22
|
+
|
23
|
+
get sessionState() {
|
24
|
+
return this._sessionState;
|
25
|
+
}
|
26
|
+
|
27
|
+
async init() {
|
28
|
+
this._ipc = new IPC();
|
29
|
+
this._ipc.config.id = this.id;
|
30
|
+
this._ipc.config.appspace = 'detox.';
|
31
|
+
this._ipc.config.logger = (msg) => this._logger.trace(msg);
|
32
|
+
|
33
|
+
await new Promise((resolve) => {
|
34
|
+
// TODO: handle reject
|
35
|
+
this._ipc.serve(() => resolve());
|
36
|
+
this._ipc.server.on('registerContext', this.onRegisterContext.bind(this));
|
37
|
+
this._ipc.server.on('registerWorker', this.onRegisterWorker.bind(this));
|
38
|
+
this._ipc.server.on('reportTestResults', this.onReportTestResults.bind(this));
|
39
|
+
this._ipc.server.start();
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
async dispose() {
|
44
|
+
if (!this._ipc) {
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
|
48
|
+
return new Promise((resolve, reject) =>{
|
49
|
+
// @ts-ignore
|
50
|
+
this._ipc.server.server.close(e => e ? reject(e) : resolve());
|
51
|
+
this._ipc.server.stop();
|
52
|
+
});
|
53
|
+
}
|
54
|
+
|
55
|
+
onRegisterContext({ id }, socket) {
|
56
|
+
this._sessionState.contexts.push(id);
|
57
|
+
|
58
|
+
this._ipc.server.emit(socket, 'registerContextDone', {
|
59
|
+
testResults: this._sessionState.testResults,
|
60
|
+
testSessionIndex: this._sessionState.testSessionIndex,
|
61
|
+
});
|
62
|
+
}
|
63
|
+
|
64
|
+
onRegisterWorker({ workerId }, socket = null) {
|
65
|
+
const workersCount = this._workers.add(workerId).size;
|
66
|
+
const shouldBroadcast = workersCount > this._sessionState.workersCount;
|
67
|
+
this._sessionState.workersCount = workersCount;
|
68
|
+
|
69
|
+
if (socket) {
|
70
|
+
this._ipc.server.emit(socket, 'registerWorkerDone', { workersCount });
|
71
|
+
}
|
72
|
+
|
73
|
+
if (shouldBroadcast) {
|
74
|
+
this._ipc.server.broadcast('sessionStateUpdate', { workersCount });
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
onReportTestResults({ testResults }, socket = null) {
|
79
|
+
const merged = uniqBy([
|
80
|
+
...testResults.map(r => serializeObjectWithError(r, 'testExecError')),
|
81
|
+
...this._sessionState.testResults
|
82
|
+
], 'testFilePath');
|
83
|
+
|
84
|
+
this._sessionState.testResults.splice(0, Infinity, ...merged);
|
85
|
+
|
86
|
+
if (socket) {
|
87
|
+
this._ipc.server.emit(socket, 'reportTestResultsDone', {
|
88
|
+
testResults: this._sessionState.testResults,
|
89
|
+
});
|
90
|
+
}
|
91
|
+
|
92
|
+
this._ipc.server.broadcast('sessionStateUpdate', {
|
93
|
+
testResults: this._sessionState.testResults,
|
94
|
+
});
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
module.exports = IPCServer;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
const vm = require('vm');
|
2
|
+
|
3
|
+
const cycle = require('json-cycle');
|
4
|
+
|
5
|
+
const context = vm.createContext({ require }, {
|
6
|
+
name: 'VM User Context',
|
7
|
+
});
|
8
|
+
|
9
|
+
class SessionState {
|
10
|
+
constructor({
|
11
|
+
id = '',
|
12
|
+
contexts = [],
|
13
|
+
detoxConfig = null,
|
14
|
+
detoxIPCServer = '',
|
15
|
+
testResults = [],
|
16
|
+
testSessionIndex = 0,
|
17
|
+
workersCount = 0
|
18
|
+
}) {
|
19
|
+
this.id = id;
|
20
|
+
this.contexts = contexts;
|
21
|
+
this.detoxConfig = detoxConfig;
|
22
|
+
this.detoxIPCServer = detoxIPCServer;
|
23
|
+
this.testResults = testResults;
|
24
|
+
this.testSessionIndex = testSessionIndex;
|
25
|
+
this.workersCount = workersCount;
|
26
|
+
}
|
27
|
+
|
28
|
+
patch(state) {
|
29
|
+
Object.assign(this, state);
|
30
|
+
}
|
31
|
+
|
32
|
+
stringify() {
|
33
|
+
return cycle.stringify(this, SessionState.stringifier);
|
34
|
+
}
|
35
|
+
|
36
|
+
/**
|
37
|
+
* @return {*}
|
38
|
+
*/
|
39
|
+
static parse(stringified) {
|
40
|
+
const Class = this; // eslint-disable-line unicorn/no-this-assignment
|
41
|
+
// @ts-ignore
|
42
|
+
return new Class(cycle.parse(stringified, SessionState.reviver));
|
43
|
+
}
|
44
|
+
|
45
|
+
static reviver(key, val) {
|
46
|
+
if (typeof val === 'object' && val !== null && typeof val.$fn == 'string') {
|
47
|
+
return vm.runInContext(val.$fn, context);
|
48
|
+
} else {
|
49
|
+
return val;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
static stringifier(key, val) {
|
54
|
+
if (typeof val === 'function') {
|
55
|
+
return { $fn: `(${val})` };
|
56
|
+
} else {
|
57
|
+
return val;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
module.exports = SessionState;
|