detox 19.7.0 → 20.0.0-breaking.new-global-lifecycle.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.7.0/detox-19.7.0-javadoc.jar → 20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.7.0/detox-19.7.0-sources.jar → 20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.7.0/detox-19.7.0.pom → 20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.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/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/android/detox/src/full/java/com/wix/detox/espresso/DetoxAction.java +3 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +23 -16
- package/android/detox/src/main/java/com/wix/detox/common/DetoxErrors.java +1 -0
- package/android/detox/src/main/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +36 -0
- package/android/detox/src/{full → main}/java/com/wix/detox/espresso/action/GetAttributesAction.kt +1 -13
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/AdjustSliderToPositionActionTest.kt +59 -0
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +3 -15
- package/index.d.ts +208 -186
- package/index.js +1 -0
- package/internals.d.ts +129 -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 +0 -1
- package/local-cli/init.js +20 -55
- package/local-cli/templates/jest.js +9 -34
- package/local-cli/test.js +18 -282
- package/local-cli/test.test.js +332 -673
- package/local-cli/testCommand/TestRunnerCommand.js +156 -0
- package/local-cli/{utils/testCommandArgs.js → testCommand/builder.js} +10 -35
- package/local-cli/testCommand/middlewares.js +75 -0
- package/local-cli/{utils → testCommand}/warnings.js +0 -10
- package/local-cli/utils/jestInternals.js +13 -2
- package/local-cli/utils/yargsUtils.js +67 -0
- package/package.json +27 -21
- package/runners/deprecation.js +47 -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/deprecation.js +25 -0
- package/runners/jest/globalSetup.js +1 -0
- package/runners/jest/globalTeardown.js +1 -0
- package/runners/jest/index.js +21 -0
- package/runners/jest/reporter.js +1 -0
- package/runners/jest/reporters/DetoxReporter.js +5 -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 +155 -0
- package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxCoreListener.js +35 -17
- 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 -7
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +34 -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 +56 -0
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +23 -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/{Detox.js → DetoxWorker.js} +130 -164
- package/src/artifacts/ArtifactsManager.js +51 -2
- package/src/artifacts/providers/index.js +0 -4
- package/src/artifacts/utils/buildDefaultArtifactsRootDirpath.js +2 -4
- package/src/artifacts/utils/temporaryPath.js +2 -0
- package/src/client/AsyncWebSocket.js +1 -1
- package/src/client/actions/actions.js +2 -2
- package/src/configuration/collectCliConfig.js +2 -4
- package/src/configuration/composeAppsConfig.js +8 -66
- package/src/configuration/composeArtifactsConfig.js +6 -32
- package/src/configuration/composeBehaviorConfig.js +3 -13
- package/src/configuration/composeDeviceConfig.js +37 -62
- package/src/configuration/composeLoggerConfig.js +50 -0
- package/src/configuration/composeRunnerConfig.js +74 -14
- package/src/configuration/composeSessionConfig.js +1 -3
- package/src/configuration/index.js +24 -23
- package/src/configuration/utils/deviceAppTypes.js +0 -1
- package/src/devices/allocation/DeviceAllocator.js +3 -3
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +2 -6
- 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/ios/tools/AppleSimUtils.js +34 -9
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +1 -1
- package/src/devices/runtime/RuntimeDevice.js +69 -81
- package/src/devices/runtime/drivers/index.js +0 -1
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +3 -2
- 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 +76 -29
- package/src/errors/DetoxError.js +4 -0
- package/src/errors/DetoxRuntimeError.js +5 -5
- package/src/errors/index.js +2 -0
- package/src/ipc/IPCClient.js +117 -0
- package/src/ipc/IPCServer.js +81 -0
- package/src/ipc/state.js +67 -0
- package/src/logger/DetoxLogger.js +244 -0
- package/src/logger/DetoxTraceEventBuilder.js +21 -0
- package/src/logger/DetoxTracer.js +133 -0
- package/src/logger/TraceThreadDispatcher.js +52 -0
- package/src/{utils → logger}/customConsoleLogger.js +1 -1
- package/src/realms/DetoxConstants.js +13 -0
- package/src/realms/DetoxContext.js +170 -0
- package/src/realms/DetoxInternalsFacade.js +35 -0
- package/src/realms/DetoxPrimaryContext.js +228 -0
- package/src/realms/DetoxSecondaryContext.js +93 -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 +1 -1
- package/src/symbols.js +56 -0
- package/src/utils/Timer.js +14 -6
- package/{local-cli/utils/misc.js → src/utils/envUtils.js} +0 -9
- package/src/utils/logger.js +2 -162
- package/src/utils/shellUtils.js +18 -0
- package/src/utils/streamUtils.js +214 -0
- package/src/utils/trace.js +9 -44
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.aar +0 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.pom.sha512 +0 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +0 -22
- package/android/detox/src/full/java/com/wix/detox/espresso/common/SliderHelper.kt +0 -75
- package/android/detox/src/main/java/com/wix/detox/espresso/action/common/ReflectUtils.kt +0 -10
- package/android/detox/src/testFull/java/com/wix/detox/espresso/common/SliderHelperTest.kt +0 -39
- 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/utils/assertJestCircus26.js +0 -39
- package/runners/jest-circus/utils/wrapErrorWithNoopLifecycle.js +0 -14
- package/src/DetoxConstants.js +0 -13
- package/src/DetoxExportWrapper.js +0 -140
- package/src/artifacts/timeline/TimelineArtifactPlugin.js +0 -90
- 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/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
@@ -15,19 +15,13 @@ class RuntimeDriverFactoryIos extends RuntimeDeviceFactory {
|
|
15
15
|
}
|
16
16
|
}
|
17
17
|
|
18
|
-
class Ios extends RuntimeDriverFactoryIos {
|
19
|
-
_createDriver(deviceCookie, deps, configs) { // eslint-disable-line no-unused-vars
|
20
|
-
const { IosRuntimeDriver } = require('../drivers');
|
21
|
-
return new IosRuntimeDriver(deps);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
18
|
class IosSimulator extends RuntimeDriverFactoryIos {
|
26
19
|
_createDriver(deviceCookie, deps, { deviceConfig }) {
|
27
20
|
const props = {
|
28
21
|
udid: deviceCookie.udid,
|
29
22
|
type: deviceConfig.device.type,
|
30
23
|
bootArgs: deviceConfig.bootArgs,
|
24
|
+
headless: deviceConfig.headless
|
31
25
|
};
|
32
26
|
|
33
27
|
const { IosSimulatorRuntimeDriver } = require('../drivers');
|
@@ -36,6 +30,5 @@ class IosSimulator extends RuntimeDriverFactoryIos {
|
|
36
30
|
}
|
37
31
|
|
38
32
|
module.exports = {
|
39
|
-
Ios,
|
40
33
|
IosSimulator,
|
41
34
|
};
|
@@ -1,14 +1,7 @@
|
|
1
1
|
const _ = require('lodash');
|
2
2
|
|
3
|
-
const log = require('../../../utils/logger');
|
4
|
-
|
5
3
|
const ScopedLaunchArgsEditor = require('./ScopedLaunchArgsEditor');
|
6
4
|
|
7
|
-
/**
|
8
|
-
* @typedef {Object} LaunchArgsEditorOptions
|
9
|
-
* @property {boolean} [permanent=false] - Indicates whether the operation should affect the permanent app launch args.
|
10
|
-
*/
|
11
|
-
|
12
5
|
class LaunchArgsEditor {
|
13
6
|
constructor() {
|
14
7
|
this._local = new ScopedLaunchArgsEditor();
|
@@ -19,67 +12,19 @@ class LaunchArgsEditor {
|
|
19
12
|
return this._shared;
|
20
13
|
}
|
21
14
|
|
22
|
-
|
23
|
-
|
24
|
-
*/
|
25
|
-
modify(launchArgs, options) {
|
26
|
-
this._assertNoDeprecatedOptions('modify', options);
|
27
|
-
|
28
|
-
if (!_.isEmpty(launchArgs)) {
|
29
|
-
if (options && options.permanent) {
|
30
|
-
this._shared.modify(launchArgs);
|
31
|
-
} else {
|
32
|
-
this._local.modify(launchArgs);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
15
|
+
modify(launchArgs) {
|
16
|
+
this._local.modify(launchArgs);
|
36
17
|
return this;
|
37
18
|
}
|
38
19
|
|
39
|
-
|
40
|
-
* @param {LaunchArgsEditorOptions} [options] - deprecated
|
41
|
-
*/
|
42
|
-
reset(options) {
|
43
|
-
this._assertNoDeprecatedOptions('reset', options);
|
20
|
+
reset() {
|
44
21
|
this._local.reset();
|
45
|
-
|
46
|
-
if (options && options.permanent) {
|
47
|
-
this._shared.reset();
|
48
|
-
}
|
49
|
-
|
50
22
|
return this;
|
51
23
|
}
|
52
24
|
|
53
|
-
|
54
|
-
* @param {LaunchArgsEditorOptions} [options] - deprecated
|
55
|
-
*/
|
56
|
-
get(options) {
|
57
|
-
this._assertNoDeprecatedOptions('get', options);
|
58
|
-
const permanent = options && options.permanent;
|
59
|
-
|
60
|
-
if (permanent === true) {
|
61
|
-
return this._shared.get();
|
62
|
-
}
|
63
|
-
|
64
|
-
if (permanent === false) {
|
65
|
-
return this._local.get();
|
66
|
-
}
|
67
|
-
|
25
|
+
get() {
|
68
26
|
return _.merge(this._shared.get(), this._local.get());
|
69
27
|
}
|
70
|
-
|
71
|
-
_assertNoDeprecatedOptions(methodName, options) {
|
72
|
-
if (!options) {
|
73
|
-
return;
|
74
|
-
}
|
75
|
-
|
76
|
-
const target = options.permanent ? 'appLaunchArgs.shared' : 'appLaunchArgs';
|
77
|
-
log.warn({ event: 'DEPRECATION' }, [
|
78
|
-
`Detected an attempt to use device.launchArgs.${methodName}(...) with a deprecated 'options' parameter.`,
|
79
|
-
`Please use device.${target}.${methodName}(...) instead.`,
|
80
|
-
`For more details, see the reference at: https://wix.github.io/Detox/docs/api/device-object-api#deviceapplaunchargs\n`,
|
81
|
-
].join('\n'));
|
82
|
-
}
|
83
28
|
}
|
84
29
|
|
85
30
|
module.exports = LaunchArgsEditor;
|
@@ -85,14 +85,6 @@ function _getFactoryClasses(deviceConfig) {
|
|
85
85
|
runtimeDeviceFactoryClass = runtimeDeviceFactories.IosSimulator;
|
86
86
|
break;
|
87
87
|
|
88
|
-
case 'ios.none':
|
89
|
-
envValidatorFactoryClass = envValidationFactories.Noop;
|
90
|
-
deviceAllocatorFactoryClass = deviceAllocationFactories.None;
|
91
|
-
artifactsManagerFactoryClass = artifactsManagerFactories.Ios;
|
92
|
-
matchersFactoryClass = matchersFactories.Ios;
|
93
|
-
runtimeDeviceFactoryClass = runtimeDeviceFactories.Ios;
|
94
|
-
break;
|
95
|
-
|
96
88
|
default: {
|
97
89
|
return null;
|
98
90
|
}
|
@@ -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':
|
@@ -456,7 +501,7 @@ 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:`,
|
460
505
|
debugInfo: this._focusOnAppConfig(appPath),
|
461
506
|
inspectOptions: { depth: 4 },
|
462
507
|
});
|
@@ -464,7 +509,7 @@ Examine your Detox config${this._atPath()}`,
|
|
464
509
|
|
465
510
|
missingAppBinaryPath(appPath) {
|
466
511
|
return new DetoxConfigError({
|
467
|
-
message: `Missing "binaryPath" property
|
512
|
+
message: `Missing "binaryPath" property in the app config.\nExpected a string:`,
|
468
513
|
debugInfo: this._focusOnAppConfig(appPath, this._ensureProperty('binaryPath')),
|
469
514
|
inspectOptions: { depth: 4 },
|
470
515
|
});
|
@@ -538,18 +583,6 @@ Examine your Detox config${this._atPath()}`,
|
|
538
583
|
});
|
539
584
|
}
|
540
585
|
|
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
586
|
ambiguousAppAndApps() {
|
554
587
|
return new DetoxConfigError({
|
555
588
|
message: `You can't have both "app" and "apps" defined in the ${J(this.configurationName)} configuration.`,
|
@@ -622,6 +655,20 @@ Examine your Detox config${this._atPath()}`,
|
|
622
655
|
});
|
623
656
|
}
|
624
657
|
|
658
|
+
invalidTestRunnerProperty(isGlobal) {
|
659
|
+
return new DetoxConfigError({
|
660
|
+
message: `testRunner should be an object, not a string`,
|
661
|
+
hint: `Check that in your Detox config${this._atPath()}`,
|
662
|
+
inspectOptions: { depth: isGlobal ? 0 : 3 },
|
663
|
+
debugInfo: isGlobal ? {
|
664
|
+
testRunner: _.get(this.contents, ['testRunner']),
|
665
|
+
...this.contents,
|
666
|
+
} : {
|
667
|
+
...this._focusOnConfiguration(c => _.pick(c, ['testRunner'])),
|
668
|
+
},
|
669
|
+
});
|
670
|
+
}
|
671
|
+
|
625
672
|
cannotSkipAutostartWithMissingServer() {
|
626
673
|
return new DetoxConfigError({
|
627
674
|
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,
|
@@ -0,0 +1,117 @@
|
|
1
|
+
const { IPC } = require('node-ipc');
|
2
|
+
|
3
|
+
const { DetoxInternalError } = require('../errors');
|
4
|
+
|
5
|
+
class IPCClient {
|
6
|
+
constructor({ id, logger, state }) {
|
7
|
+
this._id = id;
|
8
|
+
/** @type {import('../logger/DetoxLogger')} logger */
|
9
|
+
this._logger = logger.child({ __filename, cat: 'ipc' });
|
10
|
+
/** @type {import('./state').SecondarySessionState} */
|
11
|
+
this._state = state;
|
12
|
+
|
13
|
+
this._client = null;
|
14
|
+
this._serverConnection = null;
|
15
|
+
}
|
16
|
+
|
17
|
+
async init() {
|
18
|
+
this._client = new IPC();
|
19
|
+
|
20
|
+
Object.assign(this._client.config, {
|
21
|
+
id: this._id,
|
22
|
+
appspace: 'detox.',
|
23
|
+
logger: (msg) => this._logger.trace(msg),
|
24
|
+
stopRetrying: 0,
|
25
|
+
maxRetries: 0,
|
26
|
+
});
|
27
|
+
|
28
|
+
await this._connectToServer();
|
29
|
+
await this._registerContext();
|
30
|
+
}
|
31
|
+
|
32
|
+
async dispose() {
|
33
|
+
this._serverConnection = null;
|
34
|
+
|
35
|
+
if (this._client) {
|
36
|
+
this._client.disconnect(this.serverId);
|
37
|
+
this._client = null;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
get sessionState() {
|
42
|
+
return this._state;
|
43
|
+
}
|
44
|
+
|
45
|
+
get serverId() {
|
46
|
+
return this.sessionState.detoxIPCServer;
|
47
|
+
}
|
48
|
+
|
49
|
+
async registerWorker(workerId) {
|
50
|
+
this._state.workerId = workerId;
|
51
|
+
await this._emit('registerWorker', { workerId });
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* @param {string[]} testFilePaths
|
56
|
+
*/
|
57
|
+
async reportFailedTests(testFilePaths) {
|
58
|
+
await this._emit('failedTests', { testFilePaths });
|
59
|
+
}
|
60
|
+
|
61
|
+
async _connectToServer() {
|
62
|
+
const serverId = this.serverId;
|
63
|
+
|
64
|
+
this._serverConnection = await new Promise((resolve, reject) => {
|
65
|
+
this._client.connectTo(serverId, (client) => {
|
66
|
+
client.of[serverId]
|
67
|
+
.on('error', reject)
|
68
|
+
.on('disconnect', () => reject(new DetoxInternalError('IPC server has unexpectedly disconnected.')))
|
69
|
+
.on('connect', () => resolve(client.of[serverId]));
|
70
|
+
});
|
71
|
+
});
|
72
|
+
|
73
|
+
this._serverConnection.on('sessionStateUpdate', this._onSessionStateUpdate);
|
74
|
+
}
|
75
|
+
|
76
|
+
async _registerContext() {
|
77
|
+
const sessionState = await this._emit('registerContext', {
|
78
|
+
id: this._id,
|
79
|
+
logFile: this._logger.file,
|
80
|
+
});
|
81
|
+
|
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,81 @@
|
|
1
|
+
const { IPC } = require('node-ipc');
|
2
|
+
|
3
|
+
class IPCServer {
|
4
|
+
/**
|
5
|
+
* @param {object} options
|
6
|
+
* @param {import('./state').PrimarySessionState} options.sessionState
|
7
|
+
* @param {Detox.Logger} options.logger
|
8
|
+
*/
|
9
|
+
constructor({ sessionState, logger }) {
|
10
|
+
this._sessionState = sessionState;
|
11
|
+
this._logger = logger.child({ __filename, cat: 'ipc' });
|
12
|
+
this._ipc = null;
|
13
|
+
}
|
14
|
+
|
15
|
+
get id() {
|
16
|
+
return this._sessionState.detoxIPCServer;
|
17
|
+
}
|
18
|
+
|
19
|
+
get sessionState() {
|
20
|
+
return this._sessionState;
|
21
|
+
}
|
22
|
+
|
23
|
+
async init() {
|
24
|
+
this._ipc = new IPC();
|
25
|
+
this._ipc.config.id = this.id;
|
26
|
+
this._ipc.config.appspace = 'detox.';
|
27
|
+
this._ipc.config.logger = (msg) => this._logger.trace(msg);
|
28
|
+
|
29
|
+
await new Promise((resolve) => {
|
30
|
+
// TODO: handle reject
|
31
|
+
this._ipc.serve(() => resolve());
|
32
|
+
this._ipc.server.on('registerContext', this.onRegisterContext.bind(this));
|
33
|
+
this._ipc.server.on('registerWorker', this.onRegisterWorker.bind(this));
|
34
|
+
this._ipc.server.on('failedTests', this.onFailedTests.bind(this));
|
35
|
+
this._ipc.server.start();
|
36
|
+
});
|
37
|
+
}
|
38
|
+
|
39
|
+
async dispose() {
|
40
|
+
if (!this._ipc) {
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
|
44
|
+
return new Promise((resolve, reject) =>{
|
45
|
+
// @ts-ignore
|
46
|
+
this._ipc.server.server.close(e => e ? reject(e) : resolve());
|
47
|
+
this._ipc.server.stop();
|
48
|
+
});
|
49
|
+
}
|
50
|
+
|
51
|
+
onRegisterContext({ id, logFile }, socket) {
|
52
|
+
this._sessionState.contexts.push(id);
|
53
|
+
|
54
|
+
if (logFile && !this._sessionState.logFiles.includes(logFile)) {
|
55
|
+
this._sessionState.logFiles.push(logFile);
|
56
|
+
}
|
57
|
+
|
58
|
+
this._ipc.server.emit(socket, 'registerContextDone', {});
|
59
|
+
}
|
60
|
+
|
61
|
+
onRegisterWorker({ workerId }, socket) {
|
62
|
+
if (socket) {
|
63
|
+
this._ipc.server.emit(socket, 'registerWorkerDone', {});
|
64
|
+
}
|
65
|
+
|
66
|
+
if (workerId > this._sessionState.workersCount) {
|
67
|
+
const workersCount = this._sessionState.workersCount = workerId;
|
68
|
+
this._ipc.server.broadcast('sessionStateUpdate', { workersCount });
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
onFailedTests({ testFilePaths }, socket) {
|
73
|
+
this._sessionState.failedTestFiles.push(...testFilePaths);
|
74
|
+
|
75
|
+
if (socket) {
|
76
|
+
this._ipc.server.emit(socket, 'failedTestsDone', {});
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
module.exports = IPCServer;
|
package/src/ipc/state.js
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
const cycle = require('json-cycle');
|
2
|
+
|
3
|
+
const uuid = require('../utils/uuid');
|
4
|
+
|
5
|
+
class SessionState {
|
6
|
+
patch(state) {
|
7
|
+
Object.assign(this, state);
|
8
|
+
}
|
9
|
+
|
10
|
+
stringify() {
|
11
|
+
return cycle.stringify(this, SessionState.stringifier);
|
12
|
+
}
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @return {*}
|
16
|
+
*/
|
17
|
+
static parse(stringified) {
|
18
|
+
const Class = this; // eslint-disable-line unicorn/no-this-assignment
|
19
|
+
// @ts-ignore
|
20
|
+
return new Class(cycle.parse(stringified, SessionState.reviver));
|
21
|
+
}
|
22
|
+
|
23
|
+
static reviver(key, val) {
|
24
|
+
if (typeof val === 'object' && typeof val.$fn == 'string') {
|
25
|
+
return eval(val.$fn);
|
26
|
+
} else {
|
27
|
+
return val;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
static stringifier(key, val) {
|
32
|
+
if (typeof val === 'function') {
|
33
|
+
return { $fn: `(${val})` };
|
34
|
+
} else {
|
35
|
+
return val;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
class SecondarySessionState extends SessionState {
|
41
|
+
constructor({ id = uuid.UUID(), detoxConfigSnapshotPath = '', detoxConfig = null, detoxIPCServer = '', workerId = undefined, workersCount = 0 }) {
|
42
|
+
super();
|
43
|
+
|
44
|
+
this.id = id;
|
45
|
+
this.detoxConfigSnapshotPath = detoxConfigSnapshotPath;
|
46
|
+
this.detoxConfig = detoxConfig;
|
47
|
+
this.detoxIPCServer = detoxIPCServer;
|
48
|
+
this.workerId = workerId;
|
49
|
+
this.workersCount = workersCount;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
class PrimarySessionState extends SecondarySessionState {
|
54
|
+
constructor({ contexts = [], failedTestFiles = [], logFiles = [], ...baseOpts }) {
|
55
|
+
super(baseOpts);
|
56
|
+
|
57
|
+
this.contexts = contexts;
|
58
|
+
this.failedTestFiles = failedTestFiles;
|
59
|
+
this.logFiles = logFiles;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
module.exports = {
|
64
|
+
SessionState,
|
65
|
+
PrimarySessionState,
|
66
|
+
SecondarySessionState,
|
67
|
+
};
|