detox 20.0.3-breaking.new-global-lifecycle.0 → 20.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar → 20.0.3/detox-20.0.3-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar → 20.0.3/detox-20.0.3-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom → 20.0.3/detox-20.0.3.pom} +1 -7
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.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/build.gradle +12 -7
- package/android/detox/build.gradle +13 -9
- package/android/detox/proguard-rules-app.pro +6 -0
- package/android/detox/proguard-rules.pro +3 -0
- package/android/detox/publishing.gradle +27 -27
- package/android/detox/src/full/java/com/wix/detox/DetoxCrashHandler.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/LaunchArgs.java +9 -0
- package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +15 -2
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeIdlingResources.kt +43 -38
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/IdlingResourceDescription.kt +19 -13
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +33 -30
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategy.kt +7 -27
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/IdleInterrogationStrategy.kt +1 -11
- package/android/detox/src/main/java/com/wix/detox/common/TextFileReader.kt +1 -1
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/DetoxMultiTapSpec.kt +4 -3
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +61 -0
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategySpec.kt +3 -11
- package/index.d.ts +195 -59
- package/internals.d.ts +205 -43
- package/local-cli/build.js +1 -1
- package/local-cli/cli.js +11 -6
- package/local-cli/init.js +61 -21
- package/local-cli/rebuild-framework-cache.js +1 -1
- package/local-cli/reset-lock-file.js +16 -0
- package/local-cli/templates/jest.js +13 -10
- package/local-cli/test.js +14 -8
- package/local-cli/test.test.js +142 -61
- package/local-cli/testCommand/TestRunnerCommand.js +97 -77
- package/local-cli/testCommand/TestRunnerError.js +17 -0
- package/local-cli/testCommand/TestRunnerError.test.js +25 -0
- package/local-cli/testCommand/builder.js +0 -1
- package/local-cli/testCommand/middlewares.js +4 -13
- package/local-cli/testCommand/warnings.js +0 -3
- package/local-cli/utils/jestInternals.js +4 -1
- package/package.json +23 -18
- package/runners/deprecation.js +42 -44
- package/runners/jest/globalSetup.js +1 -1
- package/runners/jest/globalTeardown.js +1 -1
- package/runners/jest/index.d.ts +60 -0
- package/runners/jest/index.js +3 -8
- package/runners/jest/index.test.js +13 -0
- package/runners/jest/reporters/DetoxReporter.js +33 -2
- package/runners/jest/testEnvironment/index.js +119 -69
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +93 -46
- package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +1 -1
- package/runners/jest/testEnvironment/listeners/SpecReporter.js +13 -15
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -5
- package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -1
- package/src/DetoxWorker.js +99 -62
- package/src/android/core/NativeElement.js +56 -20
- package/src/android/core/NativeExpect.js +28 -9
- package/src/android/interactions/native.js +25 -18
- package/src/artifacts/ArtifactsManager.js +14 -47
- package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
- package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
- 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/timeline/TimelineContextTypes.js +7 -0
- package/src/artifacts/utils/temporaryPath.js +49 -8
- package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
- package/src/client/AsyncWebSocket.js +8 -17
- package/src/client/Client.js +19 -2
- package/src/client/actions/formatters/sync-resources/NetworkFormatter.js +1 -1
- package/src/configuration/collectCliConfig.js +1 -12
- package/src/configuration/composeAppsConfig.js +4 -0
- package/src/configuration/composeDeviceConfig.js +1 -1
- package/src/configuration/composeLoggerConfig.js +19 -10
- package/src/configuration/composeRunnerConfig.js +14 -9
- package/src/configuration/index.js +5 -1
- package/src/configuration/loadExternalConfig.js +1 -1
- package/src/devices/allocation/DeviceAllocator.js +3 -2
- package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +5 -5
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +6 -5
- package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +4 -17
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
- package/src/devices/common/drivers/android/exec/ADB.js +4 -0
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +3 -3
- 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/android/tools/MonitoredInstrumentation.js +1 -1
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +29 -3
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
- package/src/devices/runtime/RuntimeDevice.js +19 -12
- package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
- package/src/devices/runtime/drivers/android/AndroidDriver.js +10 -2
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +1 -1
- package/src/errors/DetoxConfigErrorComposer.js +14 -1
- package/src/errors/DetoxError.js +5 -1
- package/src/ios/expectTwo.js +153 -67
- package/src/ipc/IPCClient.js +12 -13
- package/src/ipc/IPCServer.js +28 -24
- package/src/ipc/{state.js → SessionState.js} +26 -53
- package/src/logger/DetoxLogger.js +287 -154
- package/src/logger/index.js +5 -0
- package/src/logger/utils/BunyanLogger.js +115 -0
- package/src/logger/utils/CategoryThreadDispatcher.js +37 -0
- package/src/logger/utils/DetoxLogFinalizer.js +162 -0
- package/src/logger/utils/MessageStack.js +35 -0
- package/src/logger/utils/ThreadDispatcher.js +61 -0
- package/src/logger/{customConsoleLogger.js → utils/customConsoleLogger.js} +23 -6
- package/src/logger/utils/getMainCategory.js +5 -0
- package/src/logger/utils/sanitizeBunyanContext.js +30 -0
- package/src/logger/utils/streams/BunyanTransformer.js +72 -0
- package/src/logger/utils/streams/ChromeTraceTransformer.js +127 -0
- package/src/logger/utils/streams/DetoxJSONLParser.js +31 -0
- package/src/logger/utils/streams/JSONLStringer.js +55 -0
- package/src/logger/utils/streams/index.js +7 -0
- package/src/logger/utils/streams/transformers.js +39 -0
- package/src/logger/utils/tracerLegacy.js +37 -0
- package/src/realms/DetoxContext.js +79 -65
- package/src/realms/DetoxInternalsFacade.js +8 -12
- package/src/realms/DetoxPrimaryContext.js +104 -70
- package/src/realms/DetoxSecondaryContext.js +29 -32
- 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 +16 -22
- package/src/utils/Timer.js +55 -38
- package/src/utils/argparse.js +11 -0
- package/src/utils/childProcess/exec.js +1 -1
- package/src/utils/childProcess/spawn.js +1 -1
- package/src/utils/errorUtils.js +24 -3
- package/src/utils/invocationTraceDescriptions.js +43 -0
- package/src/utils/logger.js +1 -1
- package/src/utils/pathUtils.js +11 -0
- package/src/utils/shellUtils.js +17 -0
- package/src/utils/traceInvocationCall.js +21 -0
- package/src/utils/traceMethods.js +15 -0
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.sha512 +0 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategy.kt +0 -84
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategySpec.kt +0 -115
- package/runners/jest/deprecation.js +0 -25
- package/src/configuration/utils/warnings.js +0 -12
- package/src/logger/DetoxTraceEventBuilder.js +0 -21
- package/src/logger/DetoxTracer.js +0 -133
- package/src/logger/TraceThreadDispatcher.js +0 -52
- package/src/utils/ChromeTracingExporter.js +0 -54
- package/src/utils/streamUtils.js +0 -214
- package/src/utils/trace.js +0 -19
package/src/symbols.js
CHANGED
@@ -1,56 +1,50 @@
|
|
1
1
|
/**
|
2
2
|
* @type {{
|
3
|
+
* readonly cleanup: unique symbol;
|
3
4
|
* readonly config: unique symbol;
|
4
|
-
* readonly
|
5
|
-
* readonly
|
5
|
+
* readonly getStatus: unique symbol;
|
6
|
+
* readonly init: unique symbol;
|
7
|
+
* readonly installWorker: unique symbol;
|
8
|
+
* readonly logger: unique symbol;
|
6
9
|
* readonly onHookFailure: unique symbol;
|
7
|
-
* readonly onHookStart: unique symbol;
|
8
|
-
* readonly onHookSuccess: unique symbol;
|
9
10
|
* readonly onRunDescribeFinish: unique symbol;
|
10
11
|
* readonly onRunDescribeStart: unique symbol;
|
11
|
-
* readonly onRunFinish: unique symbol;
|
12
|
-
* readonly onRunStart: unique symbol;
|
13
12
|
* readonly onTestDone: unique symbol;
|
14
13
|
* readonly onTestFnFailure: unique symbol;
|
15
|
-
* readonly onTestFnStart: unique symbol;
|
16
|
-
* readonly onTestFnSuccess: unique symbol;
|
17
14
|
* readonly onTestStart: unique symbol;
|
18
|
-
* readonly
|
15
|
+
* readonly reportTestResults: unique symbol;
|
19
16
|
* readonly resolveConfig: unique symbol;
|
20
17
|
* readonly session: unique symbol;
|
21
|
-
* readonly
|
22
|
-
* readonly
|
18
|
+
* readonly tracing: unique symbol;
|
19
|
+
* readonly uninstallWorker: unique symbol;
|
23
20
|
* readonly worker: unique symbol;
|
24
21
|
* }}
|
25
22
|
*/
|
26
23
|
module.exports = {
|
27
24
|
//#region Lifecycle
|
28
|
-
onRunStart: Symbol('run_start'),
|
29
25
|
onRunDescribeStart: Symbol('run_describe_start'),
|
30
26
|
onTestStart: Symbol('test_start'),
|
31
|
-
onHookStart: Symbol('hook_start'),
|
32
27
|
onHookFailure: Symbol('hook_failure'),
|
33
|
-
onHookSuccess: Symbol('hook_success'),
|
34
|
-
onTestFnStart: Symbol('test_fn_start'),
|
35
28
|
onTestFnFailure: Symbol('test_fn_failure'),
|
36
|
-
onTestFnSuccess: Symbol('test_fn_success'),
|
37
29
|
onTestDone: Symbol('test_done'),
|
38
30
|
onRunDescribeFinish: Symbol('run_describe_finish'),
|
39
|
-
onRunFinish: Symbol('run_finish'),
|
40
31
|
//#endregion
|
41
32
|
|
42
33
|
//#region IPC
|
43
|
-
|
34
|
+
reportTestResults: Symbol('reportTestResults'),
|
44
35
|
//#endregion
|
45
36
|
|
46
37
|
//#region Main
|
38
|
+
cleanup: Symbol('cleanup'),
|
47
39
|
config: Symbol('config'),
|
48
|
-
|
49
|
-
|
40
|
+
getStatus: Symbol('getStatus'),
|
41
|
+
init: Symbol('init'),
|
42
|
+
installWorker: Symbol('installWorker'),
|
43
|
+
logger: Symbol('logger'),
|
50
44
|
resolveConfig: Symbol('resolveConfig'),
|
51
45
|
session: Symbol('session'),
|
52
|
-
|
53
|
-
|
46
|
+
tracing: Symbol('tracing'),
|
47
|
+
uninstallWorker: Symbol('uninstallWorker'),
|
54
48
|
worker: Symbol('worker'),
|
55
49
|
//#endregion
|
56
50
|
};
|
package/src/utils/Timer.js
CHANGED
@@ -1,65 +1,82 @@
|
|
1
|
-
|
2
|
-
const DetoxRuntimeError = require('../errors/DetoxRuntimeError');
|
1
|
+
const { DetoxRuntimeError, DetoxInternalError } = require('../errors');
|
3
2
|
|
4
3
|
const Deferred = require('./Deferred');
|
5
4
|
|
6
5
|
class Timer {
|
6
|
+
constructor() {
|
7
|
+
/** @private */
|
8
|
+
this._eta = NaN;
|
9
|
+
/** @private */
|
10
|
+
this._timeout = NaN;
|
11
|
+
/** @type {NodeJS.Timer | null} */
|
12
|
+
this._timeoutHandle = null;
|
13
|
+
/** @type {Deferred | null} */
|
14
|
+
this._timeoutDeferred = null;
|
15
|
+
}
|
16
|
+
|
17
|
+
clear() {
|
18
|
+
if (this._timeoutHandle) {
|
19
|
+
clearTimeout(this._timeoutHandle);
|
20
|
+
this._timeoutHandle = null;
|
21
|
+
}
|
22
|
+
|
23
|
+
this._eta = NaN;
|
24
|
+
this._timeout = NaN;
|
25
|
+
this._timeoutDeferred = null;
|
26
|
+
}
|
27
|
+
|
28
|
+
get expired() {
|
29
|
+
return this._timeoutDeferred ? this._timeoutDeferred.isResolved() : false;
|
30
|
+
}
|
31
|
+
|
7
32
|
/**
|
8
|
-
* @param {string} description - gives more context for thrown errors
|
9
33
|
* @param {number} timeout - maximal allowed duration in milliseconds
|
10
34
|
*/
|
11
|
-
|
12
|
-
|
35
|
+
schedule(timeout) {
|
36
|
+
this.clear();
|
37
|
+
|
38
|
+
this._eta = Date.now() + timeout;
|
13
39
|
this._timeout = timeout;
|
14
|
-
|
15
|
-
this.
|
40
|
+
this._timeoutDeferred = new Deferred();
|
41
|
+
this._timeoutHandle = setTimeout(() => {
|
42
|
+
this._timeoutDeferred.resolve();
|
43
|
+
}, this._timeout);
|
16
44
|
|
17
|
-
this
|
45
|
+
return this;
|
18
46
|
}
|
19
47
|
|
20
|
-
|
21
|
-
this.
|
22
|
-
|
48
|
+
extend(ms) {
|
49
|
+
if (this.expired) {
|
50
|
+
return this.schedule(ms);
|
51
|
+
}
|
52
|
+
|
53
|
+
clearTimeout(this._timeoutHandle);
|
54
|
+
this._eta += ms;
|
55
|
+
this._timeout += ms;
|
23
56
|
this._timeoutHandle = setTimeout(() => {
|
24
57
|
this._timeoutDeferred.resolve();
|
25
|
-
}, this.
|
58
|
+
}, this._eta - Date.now());
|
26
59
|
}
|
27
60
|
|
28
|
-
async run(action) {
|
61
|
+
async run(description, action) {
|
62
|
+
if (!this._timeoutDeferred) {
|
63
|
+
throw new DetoxInternalError('Cannot run a timer action from an uninitialized timer');
|
64
|
+
}
|
65
|
+
|
29
66
|
const error = new DetoxRuntimeError({
|
30
|
-
message: `Exceeded timeout of ${this._timeout}ms while ${
|
67
|
+
message: `Exceeded timeout of ${this._timeout}ms while ${description}`,
|
31
68
|
noStack: true,
|
32
69
|
});
|
33
70
|
|
71
|
+
if (this.expired) {
|
72
|
+
throw error;
|
73
|
+
}
|
74
|
+
|
34
75
|
return Promise.race([
|
35
76
|
this._timeoutDeferred.promise.then(() => { throw error; }),
|
36
77
|
Promise.resolve().then(action),
|
37
78
|
]);
|
38
79
|
}
|
39
|
-
|
40
|
-
dispose() {
|
41
|
-
clearTimeout(this._timeoutHandle);
|
42
|
-
}
|
43
|
-
|
44
|
-
reset(extraDelayMs) {
|
45
|
-
this._timeout = extraDelayMs;
|
46
|
-
|
47
|
-
if (this._timeoutDeferred.status !== Deferred.PENDING) {
|
48
|
-
this._schedule();
|
49
|
-
} else {
|
50
|
-
clearTimeout(this._timeoutHandle);
|
51
|
-
this._timeoutHandle = setTimeout(() => this._timeoutDeferred.resolve(), extraDelayMs);
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
static async run({ description, timeout, fn }) {
|
56
|
-
const timer = new Timer({ description, timeout });
|
57
|
-
try {
|
58
|
-
await timer.run(fn);
|
59
|
-
} finally {
|
60
|
-
timer.dispose();
|
61
|
-
}
|
62
|
-
}
|
63
80
|
}
|
64
81
|
|
65
82
|
module.exports = Timer;
|
package/src/utils/argparse.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
|
1
3
|
const _ = require('lodash');
|
2
4
|
const argv = require('minimist')(process.argv.slice(2));
|
3
5
|
|
@@ -81,9 +83,18 @@ function joinArgs(keyValues, options = DEFAULT_JOIN_ARGUMENTS_OPTIONS) {
|
|
81
83
|
return argArray.join(' ');
|
82
84
|
}
|
83
85
|
|
86
|
+
function getCurrentCommand() {
|
87
|
+
const cwd = process.cwd();
|
88
|
+
|
89
|
+
return process.argv.slice(1).map((value, index) => {
|
90
|
+
return index ? value : path.relative(cwd, value);
|
91
|
+
}).join(' ');
|
92
|
+
}
|
93
|
+
|
84
94
|
module.exports = {
|
85
95
|
getArgValue,
|
86
96
|
getEnvValue,
|
87
97
|
getFlag,
|
88
98
|
joinArgs,
|
99
|
+
getCurrentCommand,
|
89
100
|
};
|
@@ -3,7 +3,7 @@ const { exec } = require('child-process-promise');
|
|
3
3
|
const _ = require('lodash');
|
4
4
|
|
5
5
|
const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
|
6
|
-
const rootLogger = require('../logger').child({
|
6
|
+
const rootLogger = require('../logger').child({ cat: ['child-process', 'child-process-exec'] });
|
7
7
|
const retry = require('../retry');
|
8
8
|
|
9
9
|
const execsCounter = require('./opsCounter');
|
@@ -2,7 +2,7 @@
|
|
2
2
|
const { spawn } = require('child-process-promise');
|
3
3
|
const _ = require('lodash');
|
4
4
|
|
5
|
-
const rootLogger = require('../logger').child({
|
5
|
+
const rootLogger = require('../logger').child({ cat: ['child-process', 'child-process-spawn'] });
|
6
6
|
const { escape } = require('../pipeCommands');
|
7
7
|
const retry = require('../retry');
|
8
8
|
|
package/src/utils/errorUtils.js
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
const { isError } = require('lodash');
|
2
|
+
const { deserializeError, serializeError } = require('serialize-error');
|
3
|
+
|
2
4
|
const CLEAN_AT = /\n\s*at [\s\S]*/m;
|
3
5
|
|
4
6
|
function filterErrorStack(error, predicate) {
|
@@ -16,11 +18,12 @@ function filterErrorStack(error, predicate) {
|
|
16
18
|
}
|
17
19
|
|
18
20
|
function replaceErrorStack(source, target) {
|
19
|
-
const sourceStack = source.stack ||
|
20
|
-
const targetStack = target.stack || target.message;
|
21
|
+
const sourceStack = (source.stack || '');
|
21
22
|
const sourceMessage = sourceStack.replace(CLEAN_AT, '');
|
22
|
-
const targetMessage = targetStack.replace(CLEAN_AT, '');
|
23
23
|
const actualSourceStack = sourceStack.slice(sourceMessage.length);
|
24
|
+
|
25
|
+
const targetMessage = target.message || target.stack.replace(CLEAN_AT, '');
|
26
|
+
|
24
27
|
target.stack = targetMessage + actualSourceStack;
|
25
28
|
return target;
|
26
29
|
}
|
@@ -37,9 +40,27 @@ function asError(error) {
|
|
37
40
|
return isError(error) ? error : new Error(error);
|
38
41
|
}
|
39
42
|
|
43
|
+
function serializeObjectWithError(obj, errorKey) {
|
44
|
+
if (obj[errorKey]) {
|
45
|
+
return { ...obj, [errorKey]: serializeError(obj[errorKey]) };
|
46
|
+
}
|
47
|
+
|
48
|
+
return obj;
|
49
|
+
}
|
50
|
+
|
51
|
+
function deserializeObjectWithError(obj, errorKey) {
|
52
|
+
if (typeof obj[errorKey] === 'object' && !(obj[errorKey] instanceof Error)) {
|
53
|
+
return { ...obj, [errorKey]: deserializeError(obj[errorKey]) };
|
54
|
+
}
|
55
|
+
|
56
|
+
return obj;
|
57
|
+
}
|
58
|
+
|
40
59
|
module.exports = {
|
41
60
|
asError,
|
42
61
|
replaceErrorStack,
|
43
62
|
filterErrorStack,
|
44
63
|
createErrorWithUserStack,
|
64
|
+
serializeObjectWithError,
|
65
|
+
deserializeObjectWithError,
|
45
66
|
};
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module.exports = {
|
2
|
+
actionDescription: {
|
3
|
+
adjustSliderToPosition: (newPosition) => `adjust slider to position ${newPosition}`,
|
4
|
+
clearText: () => 'clear input text',
|
5
|
+
getAttributes: () => 'get element attributes',
|
6
|
+
longPress: (duration) => `long press${duration !== undefined ? ` for ${duration}ms` : ''}`,
|
7
|
+
longPressAndDrag: (duration, startX, startY, targetElement, endX, endY, speed, holdDuration) =>
|
8
|
+
`long press and drag from ${startX}, ${startY} to ${endX}, ${endY} with speed ${speed} and hold duration ${holdDuration}`,
|
9
|
+
multiTap: (times) => `tap ${times} times`,
|
10
|
+
pinch: (scale, speed, angle) => `pinch with scale ${scale}, speed ${speed}, and angle ${angle}`,
|
11
|
+
pinchWithAngle: (direction, speed, angle) => `pinch with direction ${direction}, speed ${speed}, and angle ${angle}`,
|
12
|
+
replaceText: (value) => `replace input text: "${value}"`,
|
13
|
+
scroll: (amount, direction, startPositionX, startPositionY) =>
|
14
|
+
`scroll ${amount} pixels ${direction}${startPositionX !== undefined && startPositionY !== undefined ? ` from normalized position (${startPositionX}, ${startPositionY})` : ''}`,
|
15
|
+
scrollTo: (edge) => `scroll to ${edge}`,
|
16
|
+
scrollToIndex: (index) => `scroll to index #${index}`,
|
17
|
+
setColumnToValue: (column, value) => `set column ${column} to value ${value}`,
|
18
|
+
setDatePickerDate: (dateString, dateFormat) => `set date picker date to ${dateString} using format ${dateFormat}`,
|
19
|
+
swipe: (direction, speed, normalizedSwipeOffset, normalizedStartingPointX, normalizedStartingPointY) =>
|
20
|
+
`swipe ${direction} ${speed} with offset ${normalizedSwipeOffset}
|
21
|
+
${!isNaN(normalizedStartingPointX) && !isNaN(normalizedStartingPointY) ? ` from normalized position (${normalizedStartingPointX}, ${normalizedStartingPointY})` : ''}`,
|
22
|
+
takeScreenshot: (screenshotName) => `take screenshot${screenshotName !== undefined ? ` with name "${screenshotName}"` : ''}`,
|
23
|
+
tapAtPoint: (value) => `tap${value !== undefined ? ` at ${JSON.stringify(value)}` : ''}`,
|
24
|
+
tapBackspaceKey: () => 'tap on backspace key',
|
25
|
+
tapReturnKey: () => 'tap on return key',
|
26
|
+
typeText: (value) => `type input text: "${value}"`,
|
27
|
+
},
|
28
|
+
expectDescription: {
|
29
|
+
waitFor: (actionDescription) => `wait for expectation while ${actionDescription}`,
|
30
|
+
waitForWithTimeout: (expectDescription, timeout) => `${expectDescription} with timeout (${timeout} ms)`,
|
31
|
+
withTimeout: (timeout) => `wait until timeout (${timeout} ms)`,
|
32
|
+
toBeFocused: () => 'to be focused',
|
33
|
+
toBeVisible: (percent) => `to be visible${percent !== undefined ? ` ${percent}%` : ''}`,
|
34
|
+
toExist: () => 'to exist',
|
35
|
+
toHaveText: (text) => `to have text: "${text}"`,
|
36
|
+
toHaveLabel: (label) => `to have label: "${label}"`,
|
37
|
+
toHaveId: (id) => `to have id: "${id}"`,
|
38
|
+
toHaveValue: (value) => `to have value: "${value}"`,
|
39
|
+
toHaveSliderPosition: (position, tolerance) => `to have slider position: ${position}${tolerance > 0 ? ` with tolerance ${tolerance}` : ''}`,
|
40
|
+
toHaveToggleValue: (value) => `to have toggle value: ${value}`,
|
41
|
+
full: (expectDescription, notCondition) => `expect element ${notCondition ? `not ${expectDescription}` : expectDescription}`
|
42
|
+
}
|
43
|
+
};
|
package/src/utils/logger.js
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
|
3
|
+
function toSimplePath(filePath, cwd = process.cwd()) {
|
4
|
+
const relativePath = path.relative(cwd, filePath);
|
5
|
+
const isOutsideCwd = relativePath.split(path.sep, 1)[0] === '..';
|
6
|
+
return isOutsideCwd ? filePath : relativePath;
|
7
|
+
}
|
8
|
+
|
9
|
+
module.exports = {
|
10
|
+
toSimplePath,
|
11
|
+
};
|
package/src/utils/shellUtils.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
const SPACE = ' ';
|
2
2
|
const BACK_SLASH = '\\';
|
3
|
+
const FORWARD_SLASH = '/';
|
3
4
|
const SINGLE_QUOTE = "'";
|
4
5
|
const DOUBLE_QUOTE = '"';
|
5
6
|
|
@@ -64,6 +65,14 @@ function autoEscapeCmd(str) {
|
|
64
65
|
return escapeWithDoubleQuotedString(str);
|
65
66
|
}
|
66
67
|
|
68
|
+
function useForwardSlashesCMD(str) {
|
69
|
+
return str.split(BACK_SLASH).join(FORWARD_SLASH);
|
70
|
+
}
|
71
|
+
|
72
|
+
function useForwardSlashesShell(str) {
|
73
|
+
return str; // already POSIX, so no-op
|
74
|
+
}
|
75
|
+
|
67
76
|
const hasUnsafeChars = isRunningInCMDEXE()
|
68
77
|
/* istanbul ignore next */ ? hasUnsafeCMDChars
|
69
78
|
/* istanbul ignore next */ : hasUnsafeShellChars;
|
@@ -76,6 +85,10 @@ const escapeSpaces = isRunningInCMDEXE()
|
|
76
85
|
/* istanbul ignore next */ ? escapeSpacesCMD
|
77
86
|
/* istanbul ignore next */ : escapeSpacesShell;
|
78
87
|
|
88
|
+
const usePosixSlashes = isRunningInCMDEXE()
|
89
|
+
/* istanbul ignore next */ ? useForwardSlashesCMD
|
90
|
+
/* istanbul ignore next */ : useForwardSlashesShell;
|
91
|
+
|
79
92
|
module.exports = {
|
80
93
|
escapeInDoubleQuotedString,
|
81
94
|
escapeInDoubleQuotedRegexp,
|
@@ -94,4 +107,8 @@ module.exports = {
|
|
94
107
|
cmd: autoEscapeCmd,
|
95
108
|
shell: autoEscapeShell,
|
96
109
|
}),
|
110
|
+
useForwardSlashes: Object.assign(usePosixSlashes, {
|
111
|
+
cmd: useForwardSlashesCMD,
|
112
|
+
shell: useForwardSlashesShell,
|
113
|
+
}),
|
97
114
|
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
function _getCallStackTrace() {
|
2
|
+
return new Error().stack
|
3
|
+
.split('\n')
|
4
|
+
.slice(1) // Ignore Error message
|
5
|
+
.map(line => line
|
6
|
+
.replace(/^\s*at\s+/, '')
|
7
|
+
.replace(process.cwd(), '')
|
8
|
+
)
|
9
|
+
.filter(line => !line.includes('/detox/src')) // Ignore detox internal calls
|
10
|
+
.join('\n');
|
11
|
+
}
|
12
|
+
|
13
|
+
function invocationCall(logger, sectionName, invocation, action) {
|
14
|
+
return logger.trace.complete({
|
15
|
+
cat: 'ws-client,ws-client-invocation',
|
16
|
+
data: invocation,
|
17
|
+
stack: _getCallStackTrace(),
|
18
|
+
}, sectionName, action);
|
19
|
+
}
|
20
|
+
|
21
|
+
module.exports = invocationCall;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
function traceMethods(logger, obj, methodNames) {
|
2
|
+
for (const name of methodNames) {
|
3
|
+
const originalMethod = obj[name];
|
4
|
+
|
5
|
+
obj[name] = function tracedMethod(...args) {
|
6
|
+
return logger.trace.complete(
|
7
|
+
{ args },
|
8
|
+
name,
|
9
|
+
originalMethod.apply.bind(originalMethod, obj, args)
|
10
|
+
);
|
11
|
+
};
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
module.exports = traceMethods;
|
@@ -1 +0,0 @@
|
|
1
|
-
c6493b7e10e165c7c6e7f0b4cf9d100c
|
@@ -1 +0,0 @@
|
|
1
|
-
6afd03fe5e86a8a04e4caf452772e710d2943deb
|
@@ -1 +0,0 @@
|
|
1
|
-
1fd68b232ab5d4668575c8d666cacb5c8ab02e50f7aed50d8d53d36d2c669eee
|
@@ -1 +0,0 @@
|
|
1
|
-
3b59f3522d88982355734b5a6d74add724fdd37b569bfc4fb07a8a1f954aab82e054bb5348833b9c156479af8440af6aabb4c2f0f684ff10afe7ca330d2a17a1
|
@@ -1 +0,0 @@
|
|
1
|
-
692bae402dc4d4f29b815943905eb9e7
|
@@ -1 +0,0 @@
|
|
1
|
-
130eba535610edf748a958abcddf5b2551b371a6
|
@@ -1 +0,0 @@
|
|
1
|
-
3ab48363cf0d353f3013e0a1157a8f1781e3ef91f86929c321c885aba8f0af52
|
@@ -1 +0,0 @@
|
|
1
|
-
b5034dce6f23e5356cc635d35c511314c074f1a4b01ae5cf15663f00d9b27711add721b3a9e9b318bacae16209e8474ccf3fd29533f4e591353169da7ad6c2c5
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
e7043eb4fd0dfa3c309fd8cd35ee68e5
|
@@ -1 +0,0 @@
|
|
1
|
-
80bef0c22a710dabb0e72b8d15c59125db1bd58b
|
@@ -1 +0,0 @@
|
|
1
|
-
7828ffdff493f8a856efad9b7db540e4e6b13b91260292efe98791013ba2db04
|
@@ -1 +0,0 @@
|
|
1
|
-
a57448b5eec5edfb2b45b99b9c8a6714b3384f71ade0f25da7b453d14c29597e818690b293cefa9be9362be29efb2c420664283cb1fc994883cd143d46506a2f
|
@@ -1 +0,0 @@
|
|
1
|
-
1576eed74ead432e6108c03493a6873c
|
@@ -1 +0,0 @@
|
|
1
|
-
092446317977f5dc4261d559e9608932254f5e3b
|
@@ -1 +0,0 @@
|
|
1
|
-
f05c7aab6a3e42433c2934f4b7617441cce2d9c1879319cd5999b765cce8d968
|
@@ -1 +0,0 @@
|
|
1
|
-
1c0756ed5dd13915de4625248beffb25c78fdf56635b54b65df36c61116ae860a66bc421e14641630d165b1cc630f51a225221dbd8789214d108bc531eb51ef7
|
@@ -1,84 +0,0 @@
|
|
1
|
-
@file:RNDropSupportTodo(62, "Remove all of this; Use DelegatedIdleInterrogationStrategy, instead.")
|
2
|
-
|
3
|
-
package com.wix.detox.reactnative.idlingresources.timers
|
4
|
-
|
5
|
-
import com.facebook.react.bridge.ReactContext
|
6
|
-
import com.wix.detox.common.RNDropSupportTodo
|
7
|
-
import com.wix.detox.reactnative.helpers.RNHelpers
|
8
|
-
import org.joor.Reflect
|
9
|
-
import java.util.*
|
10
|
-
|
11
|
-
private const val BUSY_WINDOW_THRESHOLD = 1500
|
12
|
-
|
13
|
-
private class TimerReflected(timer: Any) {
|
14
|
-
private var reflected = Reflect.on(timer)
|
15
|
-
|
16
|
-
val isRepeating: Boolean
|
17
|
-
get() = reflected.field("mRepeat").get()
|
18
|
-
val interval: Int
|
19
|
-
get() = reflected.field("mInterval").get()
|
20
|
-
val targetTime: Long
|
21
|
-
get() = reflected.field("mTargetTime").get()
|
22
|
-
}
|
23
|
-
|
24
|
-
private class TimingModuleReflected(private val timingModule: Any) {
|
25
|
-
val timersQueue: PriorityQueue<Any>
|
26
|
-
get() = Reflect.on(timingModule).field("mTimers").get()
|
27
|
-
val timersLock: Any
|
28
|
-
get() = Reflect.on(timingModule).field("mTimerGuard").get()
|
29
|
-
|
30
|
-
operator fun component1() = timersQueue
|
31
|
-
operator fun component2() = timersLock
|
32
|
-
}
|
33
|
-
|
34
|
-
class DefaultIdleInterrogationStrategy
|
35
|
-
internal constructor(private val timersModule: Any)
|
36
|
-
: IdleInterrogationStrategy {
|
37
|
-
|
38
|
-
override fun isIdleNow(): Boolean {
|
39
|
-
val (timersQueue, timersLock) = TimingModuleReflected(timersModule)
|
40
|
-
synchronized(timersLock) {
|
41
|
-
val nextTimer = timersQueue.peek()
|
42
|
-
nextTimer?.let {
|
43
|
-
return !isTimerInBusyWindow(it) && !hasBusyTimers(timersQueue)
|
44
|
-
}
|
45
|
-
return true
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
private fun isTimerInBusyWindow(timer: Any): Boolean {
|
50
|
-
val timerReflected = TimerReflected(timer)
|
51
|
-
return when {
|
52
|
-
timerReflected.isRepeating -> false
|
53
|
-
timerReflected.interval > BUSY_WINDOW_THRESHOLD -> false
|
54
|
-
else -> true
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
private fun hasBusyTimers(timersQueue: PriorityQueue<Any>): Boolean {
|
59
|
-
timersQueue.forEach {
|
60
|
-
if (isTimerInBusyWindow(it)) {
|
61
|
-
return true
|
62
|
-
}
|
63
|
-
}
|
64
|
-
return false
|
65
|
-
}
|
66
|
-
|
67
|
-
companion object {
|
68
|
-
fun createIfSupported(reactContext: ReactContext): DefaultIdleInterrogationStrategy? {
|
69
|
-
// RN = 0.62.0:
|
70
|
-
// Should have been handled by DelegatedIdleInterrogationStrategy.createIfSupported() but seems the new TimingModule class
|
71
|
-
// was released without the awaited-for "hasActiveTimersInRange()" method.
|
72
|
-
try {
|
73
|
-
val timingModule = RNHelpers.getNativeModule(reactContext, "com.facebook.react.modules.core.TimingModule")
|
74
|
-
val timersManager = Reflect.on(timingModule).get<Any>("mJavaTimerManager")
|
75
|
-
return DefaultIdleInterrogationStrategy(timersManager)
|
76
|
-
} catch (ex: Exception) {
|
77
|
-
}
|
78
|
-
|
79
|
-
// RN < 0.62
|
80
|
-
val timingModule = RNHelpers.getNativeModule(reactContext, "com.facebook.react.modules.core.Timing") ?: return null
|
81
|
-
return DefaultIdleInterrogationStrategy(timingModule)
|
82
|
-
}
|
83
|
-
}
|
84
|
-
}
|