detox 20.1.0-next-is-hittable-check.0 → 20.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +2 -7
- package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar → 20.1.1/detox-20.1.1-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar → 20.1.1/detox-20.1.1-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.aar +0 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom → 20.1.1/detox-20.1.1.pom} +1 -1
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.1/detox-20.1.1.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/build.gradle +0 -1
- package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +3 -3
- package/android/detox/src/full/java/com/wix/detox/adapters/server/QueryStatusActionHandler.kt +12 -80
- package/android/detox/src/full/java/com/wix/detox/espresso/common/UiControllerImplReflected.kt +16 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/idlingresources/DescriptiveIdlingResource.kt +8 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/registry/BusyResourcesInquirer.kt +48 -0
- package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResource.kt +92 -0
- package/android/detox/src/full/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescription.kt → inquiry/DetoxBusyResourceDescription.kt} +6 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AnimatedModuleIdlingResource.java +18 -7
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResource.kt +3 -4
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/BridgeIdlingResource.java +12 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxBaseIdlingResource.java +2 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +14 -8
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt +2 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIManagerModuleReflected.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIModuleIdlingResource.kt +4 -6
- package/android/detox/src/testFull/java/com/wix/detox/adapters/server/QueryStatusActionHandlerSpec.kt +35 -94
- package/android/detox/src/testFull/java/com/wix/detox/espresso/registry/{IRStatusInquirerTest.kt → BusyResourcesInquirerTest.kt} +46 -7
- package/android/detox/src/testFull/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescriptionSpec.kt → inquiry/DetoxBusyResourceDescriptionSpec.kt} +6 -6
- package/android/detox/src/testFull/java/com/wix/detox/inquiry/DetoxBusyResourceSpec.kt +134 -0
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceSpec.kt +4 -5
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +5 -5
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceSpec.kt +4 -6
- package/index.d.ts +102 -18
- package/index.js +12 -1
- package/internals.d.ts +34 -9
- package/internals.js +10 -3
- package/local-cli/cli.js +6 -3
- package/local-cli/init.js +1 -1
- package/local-cli/test.js +6 -6
- package/local-cli/testCommand/TestRunnerCommand.js +97 -94
- package/local-cli/testCommand/TestRunnerError.js +17 -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/package.json +31 -16
- package/runners/deprecation.js +42 -44
- package/runners/jest/index.d.ts +60 -0
- package/runners/jest/index.js +3 -8
- package/runners/jest/reporters/DetoxReporter.js +21 -10
- package/runners/jest/testEnvironment/index.js +57 -41
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +62 -35
- package/runners/jest/testEnvironment/listeners/SpecReporter.js +12 -14
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -5
- package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
- package/src/DetoxWorker.js +96 -50
- package/src/android/core/NativeMatcher.js +14 -10
- package/src/android/espressoapi/EspressoDetox.js +1 -1
- package/src/android/espressoapi/web/WebElement.js +1 -1
- package/src/android/interactions/native.js +3 -2
- package/src/android/matchers/native.js +1 -2
- package/src/artifacts/ArtifactsManager.js +6 -6
- package/src/artifacts/templates/plugin/ArtifactPlugin.js +1 -1
- package/src/artifacts/templates/plugin/TwoSnapshotsPerTestPlugin.js +2 -1
- package/src/artifacts/templates/plugin/WholeTestRecorderPlugin.js +3 -2
- package/src/artifacts/utils/temporaryPath.js +32 -2
- package/src/client/AsyncWebSocket.js +3 -2
- package/src/client/actions/SyncStatusSchema.json +21 -0
- package/src/client/actions/formatters/SyncStatusFormatter.js +2 -0
- package/src/client/actions/formatters/sync-resources/BgThreadFormatter.js +5 -0
- package/src/configuration/collectCliConfig.js +2 -13
- package/src/configuration/composeLoggerConfig.js +1 -0
- package/src/configuration/composeRunnerConfig.js +5 -4
- package/src/devices/allocation/drivers/AllocationDriverBase.js +4 -2
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -3
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +3 -16
- package/src/devices/allocation/factories/base.js +1 -1
- package/src/devices/common/drivers/android/exec/ADB.js +4 -0
- package/src/devices/common/drivers/android/tools/AppInstallHelper.js +4 -4
- package/src/devices/common/drivers/android/tools/{FileXfer.js → FileTransfer.js} +2 -2
- package/src/devices/common/drivers/android/tools/TempFileTransfer.js +14 -0
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +1 -1
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +2 -0
- package/src/devices/runtime/RuntimeDevice.js +3 -3
- package/src/devices/runtime/drivers/android/AndroidDriver.js +7 -6
- package/src/devices/runtime/factories/android.js +6 -5
- package/src/devices/runtime/factories/base.js +3 -2
- package/src/errors/DetoxConfigErrorComposer.js +6 -1
- package/src/errors/DetoxError.js +5 -1
- package/src/ios/expectTwo.js +22 -13
- package/src/ipc/IPCClient.js +26 -17
- package/src/ipc/IPCServer.js +11 -3
- package/src/ipc/SessionState.js +11 -11
- package/src/logger/DetoxLogger.js +67 -47
- package/src/logger/index.js +1 -0
- package/src/logger/utils/BunyanLogger.js +54 -10
- package/src/logger/utils/CategoryThreadDispatcher.js +8 -29
- package/src/logger/utils/DetoxLogFinalizer.js +166 -0
- package/src/logger/utils/MessageStack.js +17 -6
- package/src/logger/utils/ThreadDispatcher.js +5 -25
- package/src/logger/utils/customConsoleLogger.js +22 -5
- package/src/logger/utils/getMainCategory.js +5 -0
- package/src/logger/utils/sanitizeBunyanContext.js +3 -1
- package/src/logger/utils/streams/BunyanTransformer.js +72 -0
- package/src/logger/utils/streams/ChromeTraceTransformer.js +132 -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 +14 -25
- package/src/realms/DetoxContext.js +16 -9
- package/src/realms/DetoxInternalsFacade.js +1 -7
- package/src/realms/DetoxPrimaryContext.js +42 -87
- package/src/realms/DetoxSecondaryContext.js +9 -13
- package/src/{symbols.js → realms/symbols.js} +0 -0
- package/src/servicelocator/android/index.js +2 -2
- package/src/utils/ExclusiveLockfile.js +1 -0
- package/src/utils/argparse.js +11 -27
- 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/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha512 +0 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/registry/IRStatusInquirer.kt +0 -24
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DescriptiveIdlingResource.kt +0 -10
- package/local-cli/build.test.js +0 -104
- package/local-cli/run-server.test.js +0 -23
- package/local-cli/test.test.js +0 -569
- package/runners/jest/deprecation.js +0 -25
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -23
- package/src/configuration/utils/warnings.js +0 -12
- package/src/devices/common/drivers/android/tools/TempFileXfer.js +0 -16
- package/src/logger/utils/streamUtils.js +0 -240
- package/src/realms/index.js +0 -10
- package/src/utils/trace.js +0 -3
@@ -11,8 +11,8 @@ const log = detoxInternals.log.child({ cat: 'lifecycle,jest-environment' });
|
|
11
11
|
|
12
12
|
class DetoxCoreListener {
|
13
13
|
constructor({ env }) {
|
14
|
-
this._startedTests = new
|
15
|
-
this._testsFailedBeforeStart = new
|
14
|
+
this._startedTests = new Set();
|
15
|
+
this._testsFailedBeforeStart = new Set();
|
16
16
|
this._env = env;
|
17
17
|
this._circusRetryTimes = 1;
|
18
18
|
}
|
@@ -41,10 +41,22 @@ class DetoxCoreListener {
|
|
41
41
|
}
|
42
42
|
|
43
43
|
async test_start({ test }) {
|
44
|
-
|
44
|
+
const metadata = this._getTestMetadata(test);
|
45
|
+
if (metadata.status === 'failed') {
|
45
46
|
this._testsFailedBeforeStart.add(test);
|
46
47
|
}
|
47
48
|
|
49
|
+
const logTrace = this._isTestSkipped(test)
|
50
|
+
? log.trace
|
51
|
+
: log.trace.begin;
|
52
|
+
|
53
|
+
logTrace({
|
54
|
+
context: 'test',
|
55
|
+
status: metadata.status,
|
56
|
+
fullName: metadata.fullName,
|
57
|
+
invocations: metadata.invocations,
|
58
|
+
}, metadata.title);
|
59
|
+
|
48
60
|
const circusRetryTimes = +this._env.global[RETRY_TIMES];
|
49
61
|
this._circusRetryTimes = isNaN(circusRetryTimes) ? 1 : 1 + circusRetryTimes;
|
50
62
|
}
|
@@ -69,7 +81,11 @@ class DetoxCoreListener {
|
|
69
81
|
|
70
82
|
async test_fn_start({ test }) {
|
71
83
|
await this._onBeforeActualTestStart(test);
|
72
|
-
|
84
|
+
|
85
|
+
if (!this._testsFailedBeforeStart.has(test)) {
|
86
|
+
// Jest bug workaround: beforeAll hook errors result into an unterminated test_fn_start event.
|
87
|
+
log.trace.begin({ functionCode: test.fn.toString() }, 'test_fn');
|
88
|
+
}
|
73
89
|
}
|
74
90
|
|
75
91
|
async test_fn_success() {
|
@@ -82,57 +98,68 @@ class DetoxCoreListener {
|
|
82
98
|
}
|
83
99
|
|
84
100
|
async test_done({ test }) {
|
85
|
-
|
86
|
-
const failed = test.errors.length > 0;
|
87
|
-
const metadata = {
|
88
|
-
...this._getTestMetadata(test),
|
89
|
-
status: failed ? 'failed' : 'passed',
|
90
|
-
timedOut: failed ? hasTimedOut(test) : undefined,
|
91
|
-
};
|
101
|
+
const metadata = this._getTestMetadata(test);
|
92
102
|
|
103
|
+
if (this._startedTests.has(test)) {
|
93
104
|
await detoxInternals.onTestDone(metadata);
|
94
105
|
this._startedTests.delete(test);
|
95
|
-
log.trace.end({
|
96
|
-
status: metadata.status,
|
97
|
-
timedOut: metadata.timedOut,
|
98
|
-
});
|
99
106
|
}
|
107
|
+
|
108
|
+
log.trace.end(_.pick(metadata, ['status', 'timedOut']));
|
100
109
|
}
|
101
110
|
|
102
111
|
async _onBeforeActualTestStart(test) {
|
103
|
-
if (!
|
104
|
-
return
|
112
|
+
if (!this._isTestActuallyStarting(test)) {
|
113
|
+
return;
|
105
114
|
}
|
106
115
|
|
107
|
-
const metadata = {
|
108
|
-
...this._getTestMetadata(test),
|
109
|
-
status: 'running',
|
110
|
-
};
|
111
|
-
|
112
116
|
this._startedTests.add(test);
|
117
|
+
await detoxInternals.onTestStart(this._getTestMetadata(test));
|
118
|
+
}
|
113
119
|
|
114
|
-
|
115
|
-
|
116
|
-
status: metadata.status,
|
117
|
-
fullName: metadata.fullName,
|
118
|
-
invocations: metadata.invocations,
|
119
|
-
}, metadata.title);
|
120
|
-
|
121
|
-
await detoxInternals.onTestStart(metadata);
|
122
|
-
return true;
|
120
|
+
_isTestActuallyStarting(test) {
|
121
|
+
return test && !this._isTestSkipped(test) && !this._startedTests.has(test) && !this._testsFailedBeforeStart.has(test);
|
123
122
|
}
|
124
123
|
|
125
|
-
|
126
|
-
|
127
|
-
return testSessionIndex * this._circusRetryTimes + test.invocations;
|
124
|
+
_isTestSkipped(test) {
|
125
|
+
return test && (test.mode === 'skip' || test.mode === 'todo');
|
128
126
|
}
|
129
127
|
|
130
128
|
_getTestMetadata(test) {
|
131
|
-
|
129
|
+
const result = {
|
132
130
|
title: test.name,
|
133
131
|
fullName: getFullTestName(test),
|
132
|
+
status: this._getTestStatus(test),
|
134
133
|
invocations: this._getTestInvocations(test),
|
135
134
|
};
|
135
|
+
|
136
|
+
if (result.status === 'failed') {
|
137
|
+
result.timedOut = hasTimedOut(test);
|
138
|
+
}
|
139
|
+
|
140
|
+
return result;
|
141
|
+
}
|
142
|
+
|
143
|
+
/** @returns { 'failed' | 'passed' | 'running' | 'skip' | 'todo' } */
|
144
|
+
_getTestStatus(test) {
|
145
|
+
if (!_.isEmpty(test.errors)) {
|
146
|
+
return 'failed';
|
147
|
+
}
|
148
|
+
|
149
|
+
if (this._isTestSkipped(test)) {
|
150
|
+
return test.mode;
|
151
|
+
}
|
152
|
+
|
153
|
+
if (test.status === 'done') {
|
154
|
+
return 'passed';
|
155
|
+
} else {
|
156
|
+
return test.status || 'running';
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
_getTestInvocations(test) {
|
161
|
+
const { testSessionIndex } = detoxInternals.session;
|
162
|
+
return testSessionIndex * this._circusRetryTimes + test.invocations;
|
136
163
|
}
|
137
164
|
}
|
138
165
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
const chalk = require('chalk').default;
|
2
|
+
const noop = require('lodash/noop');
|
2
3
|
|
3
4
|
const { config, log, session } = require('../../../../internals');
|
4
5
|
const { traceln } = require('../utils/stdout');
|
@@ -15,16 +16,21 @@ class SpecReporter {
|
|
15
16
|
this._suitesDesc = '';
|
16
17
|
}
|
17
18
|
|
18
|
-
|
19
|
+
setup() {
|
19
20
|
const jestSection = config.testRunner.jest;
|
20
21
|
const reportSpecs = jestSection && jestSection.reportSpecs;
|
21
|
-
|
22
|
-
|
22
|
+
const enabled = reportSpecs !== undefined ? reportSpecs : session.workersCount === 1;
|
23
|
+
|
24
|
+
if (!enabled) {
|
25
|
+
this.run_describe_start = noop;
|
26
|
+
this.run_describe_finish = noop;
|
27
|
+
this.test_start = noop;
|
28
|
+
this.test_done = noop;
|
29
|
+
this.test_skip = noop;
|
30
|
+
}
|
23
31
|
}
|
24
32
|
|
25
33
|
run_describe_start(event) {
|
26
|
-
if (!this.enabled) return;
|
27
|
-
|
28
34
|
if (event.describeBlock.parent !== undefined) {
|
29
35
|
this._onSuiteStart({
|
30
36
|
description: event.describeBlock.name,
|
@@ -33,16 +39,12 @@ class SpecReporter {
|
|
33
39
|
}
|
34
40
|
|
35
41
|
run_describe_finish(event) {
|
36
|
-
if (!this.enabled) return;
|
37
|
-
|
38
42
|
if (event.describeBlock.parent !== undefined) {
|
39
43
|
this._onSuiteEnd();
|
40
44
|
}
|
41
45
|
}
|
42
46
|
|
43
47
|
test_start(event) {
|
44
|
-
if (!this.enabled) return;
|
45
|
-
|
46
48
|
const { test } = event;
|
47
49
|
this._onTestStart({
|
48
50
|
description: test.name,
|
@@ -51,8 +53,6 @@ class SpecReporter {
|
|
51
53
|
}
|
52
54
|
|
53
55
|
test_done(event) {
|
54
|
-
if (!this.enabled) return;
|
55
|
-
|
56
56
|
const { test } = event;
|
57
57
|
const testInfo = {
|
58
58
|
description: test.name,
|
@@ -62,8 +62,6 @@ class SpecReporter {
|
|
62
62
|
}
|
63
63
|
|
64
64
|
test_skip(event) {
|
65
|
-
if (!this.enabled) return;
|
66
|
-
|
67
65
|
const testInfo = {
|
68
66
|
description: event.test.name,
|
69
67
|
};
|
@@ -110,7 +108,7 @@ class SpecReporter {
|
|
110
108
|
.concat(suite.description)
|
111
109
|
.concat((index === total - 1) ? ': ' : '');
|
112
110
|
});
|
113
|
-
this._suitesDesc = chalk.bold
|
111
|
+
this._suitesDesc = chalk.bold(this._suitesDesc);
|
114
112
|
}
|
115
113
|
|
116
114
|
_traceTest({ description, invocations }, _status = undefined) {
|
@@ -13,7 +13,7 @@ class WorkerAssignReporter {
|
|
13
13
|
|
14
14
|
run_start() {
|
15
15
|
if (config.testRunner.jest.reportWorkerAssign) {
|
16
|
-
log.info({ cat: 'lifecycle' }, `${this.
|
16
|
+
log.info({ cat: 'lifecycle' }, `${chalk.bold(this._testName)} is assigned to ${this._formatDeviceName()}`);
|
17
17
|
}
|
18
18
|
}
|
19
19
|
|
@@ -25,10 +25,6 @@ class WorkerAssignReporter {
|
|
25
25
|
|
26
26
|
return formattedDeviceName;
|
27
27
|
}
|
28
|
-
|
29
|
-
_formatTestName() {
|
30
|
-
return chalk.whiteBright(this._testName);
|
31
|
-
}
|
32
28
|
}
|
33
29
|
|
34
30
|
module.exports = WorkerAssignReporter;
|
@@ -1,8 +1,10 @@
|
|
1
1
|
const fs = require('fs');
|
2
2
|
const path = require('path');
|
3
3
|
|
4
|
+
const resolveFrom = require('resolve-from');
|
4
5
|
const semver = require('semver');
|
5
6
|
|
7
|
+
const { log } = require('../../../../internals');
|
6
8
|
const detoxPackageJson = require('../../../../package.json');
|
7
9
|
const { DetoxRuntimeError } = require('../../../../src/errors');
|
8
10
|
|
@@ -25,6 +27,10 @@ function assertJestCircus27(maybeProjectConfig) {
|
|
25
27
|
});
|
26
28
|
}
|
27
29
|
|
30
|
+
const jestManifestPath = resolveFrom(process.cwd(), 'jest/package.json');
|
31
|
+
const jestManifest = require(jestManifestPath);
|
32
|
+
assertSupportedVersion(jestManifest.version);
|
33
|
+
|
28
34
|
const circusVersion = require(circusPackageJson).version;
|
29
35
|
if (!circusVersion) {
|
30
36
|
throw new DetoxRuntimeError({
|
@@ -33,7 +39,14 @@ function assertJestCircus27(maybeProjectConfig) {
|
|
33
39
|
});
|
34
40
|
}
|
35
41
|
|
36
|
-
|
42
|
+
if (jestManifest.version !== circusVersion) {
|
43
|
+
log.warn([
|
44
|
+
`jest-circus@${circusVersion} does not match jest@${jestManifest.version}.\n`,
|
45
|
+
`- jest@${jestManifest.version} resolved path:\n\t${jestManifestPath}`,
|
46
|
+
`- jest-circus@${circusVersion} resolved path:\n\t${circusPackageJson}`,
|
47
|
+
`\nPlease make sure that your versions match to avoid unexpected behavior!`,
|
48
|
+
].join('\n'));
|
49
|
+
}
|
37
50
|
|
38
51
|
return maybeProjectConfig;
|
39
52
|
}
|
@@ -41,11 +54,12 @@ function assertJestCircus27(maybeProjectConfig) {
|
|
41
54
|
function assertSupportedVersion(actualVersion) {
|
42
55
|
const supportedRange = detoxPackageJson.peerDependencies.jest;
|
43
56
|
const minSupportedVersion = semver.minVersion(supportedRange);
|
57
|
+
const action = semver.lt(actualVersion, minSupportedVersion) ? 'upgrade' : 'downgrade';
|
44
58
|
|
45
|
-
if (semver.
|
59
|
+
if (!semver.satisfies(actualVersion, supportedRange, { includePrerelease: true })) {
|
46
60
|
throw new DetoxRuntimeError({
|
47
61
|
message: `Detected an unsupported jest@${actualVersion} version.`,
|
48
|
-
hint: `Please
|
62
|
+
hint: `Please ${action} your Jest test runner to the supported range: ${supportedRange}.`
|
49
63
|
});
|
50
64
|
}
|
51
65
|
}
|
package/src/DetoxWorker.js
CHANGED
@@ -1,17 +1,18 @@
|
|
1
|
+
const CAF = require('caf');
|
1
2
|
const _ = require('lodash');
|
2
3
|
|
3
4
|
const Client = require('./client/Client');
|
4
5
|
const environmentFactory = require('./environmentFactory');
|
5
6
|
const { DetoxRuntimeErrorComposer } = require('./errors');
|
6
7
|
const { InvocationManager } = require('./invoke');
|
7
|
-
const symbols = require('./symbols');
|
8
|
+
const symbols = require('./realms/symbols');
|
8
9
|
const AsyncEmitter = require('./utils/AsyncEmitter');
|
9
10
|
const uuid = require('./utils/uuid');
|
10
11
|
|
11
12
|
class DetoxWorker {
|
12
13
|
constructor(context) {
|
13
14
|
this._context = context;
|
14
|
-
this.
|
15
|
+
this._injectedGlobalProperties = [];
|
15
16
|
this._config = context[symbols.config];
|
16
17
|
this._runtimeErrorComposer = new DetoxRuntimeErrorComposer(this._config);
|
17
18
|
this._client = null;
|
@@ -32,6 +33,18 @@ class DetoxWorker {
|
|
32
33
|
onError: this._onEmitError.bind(this),
|
33
34
|
});
|
34
35
|
|
36
|
+
|
37
|
+
/** @type {DetoxInternals.RuntimeConfig['apps']} */
|
38
|
+
this._appsConfig = null;
|
39
|
+
/** @type {DetoxInternals.RuntimeConfig['artifacts']} */
|
40
|
+
this._artifactsConfig = null;
|
41
|
+
/** @type {DetoxInternals.RuntimeConfig['behavior']} */
|
42
|
+
this._behaviorConfig = null;
|
43
|
+
/** @type {DetoxInternals.RuntimeConfig['device']} */
|
44
|
+
this._deviceConfig = null;
|
45
|
+
/** @type {DetoxInternals.RuntimeConfig['session']} */
|
46
|
+
this._sessionConfig = null;
|
47
|
+
|
35
48
|
/** @type {string} */
|
36
49
|
this.id = 'worker';
|
37
50
|
/** @type {Detox.Device} */
|
@@ -53,11 +66,23 @@ class DetoxWorker {
|
|
53
66
|
this.trace = this._context.trace;
|
54
67
|
/** @deprecated */
|
55
68
|
this.traceCall = this._context.traceCall;
|
56
|
-
}
|
57
69
|
|
58
|
-
|
59
|
-
|
70
|
+
this._reinstallAppsOnDevice = CAF(this._reinstallAppsOnDevice.bind(this));
|
71
|
+
this._initToken = new CAF.cancelToken();
|
72
|
+
|
73
|
+
this._cafWrap([
|
74
|
+
'init',
|
75
|
+
'onRunDescribeStart',
|
76
|
+
'onTestStart',
|
77
|
+
'onHookFailure',
|
78
|
+
'onTestFnFailure',
|
79
|
+
'onTestDone',
|
80
|
+
'onRunDescribeFinish',
|
81
|
+
]);
|
82
|
+
}
|
60
83
|
|
84
|
+
/** @this {DetoxWorker} */
|
85
|
+
init = function* (signal) {
|
61
86
|
const {
|
62
87
|
apps: appsConfig,
|
63
88
|
artifacts: artifactsConfig,
|
@@ -71,6 +96,7 @@ class DetoxWorker {
|
|
71
96
|
this._behaviorConfig = behaviorConfig;
|
72
97
|
this._deviceConfig = deviceConfig;
|
73
98
|
this._sessionConfig = sessionConfig;
|
99
|
+
// @ts-ignore
|
74
100
|
this._sessionConfig.sessionId = sessionConfig.sessionId || uuid.UUID();
|
75
101
|
this._runtimeErrorComposer.appsConfig = this._appsConfig;
|
76
102
|
|
@@ -82,8 +108,7 @@ class DetoxWorker {
|
|
82
108
|
}
|
83
109
|
};
|
84
110
|
|
85
|
-
|
86
|
-
if (this._isCleaningUp) return;
|
111
|
+
yield this._client.connect();
|
87
112
|
|
88
113
|
const invocationManager = new InvocationManager(this._client);
|
89
114
|
|
@@ -100,8 +125,7 @@ class DetoxWorker {
|
|
100
125
|
} = environmentFactory.createFactories(this._deviceConfig);
|
101
126
|
|
102
127
|
const envValidator = envValidatorFactory.createValidator();
|
103
|
-
|
104
|
-
if (this._isCleaningUp) return;
|
128
|
+
yield envValidator.validate();
|
105
129
|
|
106
130
|
const commonDeps = {
|
107
131
|
invocationManager,
|
@@ -112,8 +136,7 @@ class DetoxWorker {
|
|
112
136
|
|
113
137
|
this._artifactsManager = artifactsManagerFactory.createArtifactsManager(this._artifactsConfig, commonDeps);
|
114
138
|
this._deviceAllocator = deviceAllocatorFactory.createDeviceAllocator(commonDeps);
|
115
|
-
this._deviceCookie =
|
116
|
-
if (this._isCleaningUp) return;
|
139
|
+
this._deviceCookie = yield this._deviceAllocator.allocate(this._deviceConfig);
|
117
140
|
|
118
141
|
this.device = runtimeDeviceFactory.createRuntimeDevice(
|
119
142
|
this._deviceCookie,
|
@@ -124,7 +147,6 @@ class DetoxWorker {
|
|
124
147
|
deviceConfig: this._deviceConfig,
|
125
148
|
sessionConfig,
|
126
149
|
});
|
127
|
-
if (this._isCleaningUp) return;
|
128
150
|
|
129
151
|
const matchers = matchersFactory.createMatchers({
|
130
152
|
invocationManager,
|
@@ -134,34 +156,37 @@ class DetoxWorker {
|
|
134
156
|
Object.assign(this, matchers);
|
135
157
|
|
136
158
|
if (behaviorConfig.init.exposeGlobals) {
|
137
|
-
|
159
|
+
const injectedGlobals = {
|
138
160
|
...matchers,
|
139
161
|
device: this.device,
|
140
162
|
detox: this,
|
141
|
-
}
|
163
|
+
};
|
164
|
+
|
165
|
+
this._injectedGlobalProperties = Object.keys(injectedGlobals);
|
166
|
+
Object.assign(DetoxWorker.global, injectedGlobals);
|
142
167
|
}
|
143
168
|
|
144
169
|
// @ts-ignore
|
145
|
-
|
146
|
-
if (this._isCleaningUp) return;
|
170
|
+
yield this.device.installUtilBinaries();
|
147
171
|
|
148
172
|
if (behaviorConfig.init.reinstallApp) {
|
149
|
-
|
150
|
-
if (this._isCleaningUp) return;
|
173
|
+
yield this._reinstallAppsOnDevice(signal);
|
151
174
|
}
|
152
175
|
|
153
176
|
const appAliases = Object.keys(this._appsConfig);
|
154
177
|
if (appAliases.length === 1) {
|
155
|
-
|
178
|
+
yield this.device.selectApp(appAliases[0]);
|
156
179
|
} else {
|
157
|
-
|
180
|
+
yield this.device.selectApp(null);
|
158
181
|
}
|
159
|
-
|
160
|
-
return this;
|
161
|
-
}
|
182
|
+
};
|
162
183
|
|
163
184
|
async cleanup() {
|
164
|
-
this.
|
185
|
+
this._initToken.abort('CLEANUP');
|
186
|
+
|
187
|
+
for (const key of this._injectedGlobalProperties) {
|
188
|
+
delete DetoxWorker.global[key];
|
189
|
+
}
|
165
190
|
|
166
191
|
if (this._artifactsManager) {
|
167
192
|
await this._artifactsManager.onBeforeCleanup();
|
@@ -190,38 +215,45 @@ class DetoxWorker {
|
|
190
215
|
return this._context.log;
|
191
216
|
}
|
192
217
|
|
193
|
-
onRunDescribeStart =
|
194
|
-
|
195
|
-
|
218
|
+
onRunDescribeStart = function* (_signal, ...args) {
|
219
|
+
yield this._artifactsManager.onRunDescribeStart(...args);
|
220
|
+
};
|
221
|
+
|
222
|
+
onTestStart = function* (_signal, testSummary) {
|
196
223
|
this._validateTestSummary('beforeEach', testSummary);
|
197
224
|
|
198
|
-
|
199
|
-
await this._dumpUnhandledErrorsIfAny({
|
225
|
+
yield this._dumpUnhandledErrorsIfAny({
|
200
226
|
pendingRequests: false,
|
201
227
|
testName: testSummary.fullName,
|
202
228
|
});
|
203
229
|
|
204
|
-
|
205
|
-
|
230
|
+
yield this._artifactsManager.onTestStart(testSummary);
|
231
|
+
};
|
232
|
+
|
233
|
+
onHookFailure = function* (_signal, ...args) {
|
234
|
+
yield this._artifactsManager.onHookFailure(...args);
|
206
235
|
};
|
207
|
-
|
208
|
-
onTestFnFailure =
|
209
|
-
|
210
|
-
|
236
|
+
|
237
|
+
onTestFnFailure = function* (_signal, ...args) {
|
238
|
+
yield this._artifactsManager.onTestFnFailure(...args);
|
239
|
+
};
|
240
|
+
|
241
|
+
onTestDone = function* (_signal, testSummary) {
|
211
242
|
this._validateTestSummary('afterEach', testSummary);
|
212
243
|
|
213
|
-
|
214
|
-
await this._artifactsManager.onTestDone(testSummary);
|
244
|
+
yield this._artifactsManager.onTestDone(testSummary);
|
215
245
|
|
216
|
-
|
217
|
-
await this._dumpUnhandledErrorsIfAny({
|
246
|
+
yield this._dumpUnhandledErrorsIfAny({
|
218
247
|
pendingRequests: testSummary.timedOut,
|
219
248
|
testName: testSummary.fullName,
|
220
249
|
});
|
221
250
|
};
|
222
|
-
onRunDescribeFinish = async (...args) => this._artifactsManager.onRunDescribeFinish(...args);
|
223
251
|
|
224
|
-
|
252
|
+
onRunDescribeFinish = function* (_signal, ...args) {
|
253
|
+
yield this._artifactsManager.onRunDescribeFinish(...args);
|
254
|
+
};
|
255
|
+
|
256
|
+
*_reinstallAppsOnDevice(_signal) {
|
225
257
|
const appNames = _(this._appsConfig)
|
226
258
|
.map((config, key) => [key, `${config.binaryPath}:${config.testBinaryPath}`])
|
227
259
|
.uniqBy(1)
|
@@ -229,17 +261,13 @@ class DetoxWorker {
|
|
229
261
|
.value();
|
230
262
|
|
231
263
|
for (const appName of appNames) {
|
232
|
-
|
233
|
-
|
234
|
-
await this.device.uninstallApp();
|
235
|
-
if (this._isCleaningUp) return;
|
264
|
+
yield this.device.selectApp(appName);
|
265
|
+
yield this.device.uninstallApp();
|
236
266
|
}
|
237
267
|
|
238
268
|
for (const appName of appNames) {
|
239
|
-
|
240
|
-
|
241
|
-
await this.device.installApp();
|
242
|
-
if (this._isCleaningUp) return;
|
269
|
+
yield this.device.selectApp(appName);
|
270
|
+
yield this.device.installApp();
|
243
271
|
}
|
244
272
|
}
|
245
273
|
|
@@ -271,10 +299,28 @@ class DetoxWorker {
|
|
271
299
|
error
|
272
300
|
);
|
273
301
|
}
|
302
|
+
|
303
|
+
_cafWrap(methodNames) {
|
304
|
+
for (const methodName of methodNames) {
|
305
|
+
const cafMethod = CAF(this[methodName].bind(this));
|
306
|
+
this[methodName] = async (...args) => {
|
307
|
+
try {
|
308
|
+
await cafMethod(this._initToken.signal, ...args);
|
309
|
+
} catch (e) {
|
310
|
+
if (e !== 'CLEANUP') {
|
311
|
+
throw e;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
315
|
+
return this;
|
316
|
+
};
|
317
|
+
}
|
318
|
+
}
|
319
|
+
|
274
320
|
}
|
275
321
|
|
276
322
|
/**
|
277
|
-
* @type {NodeJS.Global}
|
323
|
+
* @type {NodeJS.Global | {}}
|
278
324
|
*/
|
279
325
|
DetoxWorker.global = global;
|
280
326
|
|
@@ -2,29 +2,33 @@ const invoke = require('../../invoke');
|
|
2
2
|
const DetoxMatcherApi = require('../espressoapi/DetoxMatcher');
|
3
3
|
|
4
4
|
class NativeMatcher {
|
5
|
+
constructor(call) {
|
6
|
+
this._call = call || null;
|
7
|
+
}
|
8
|
+
|
5
9
|
withAncestor(matcher) {
|
6
|
-
|
7
|
-
return
|
10
|
+
const call = invoke.callDirectly(DetoxMatcherApi.matcherWithAncestor(this, matcher));
|
11
|
+
return new NativeMatcher(call);
|
8
12
|
}
|
9
13
|
|
10
14
|
withDescendant(matcher) {
|
11
|
-
|
12
|
-
return
|
15
|
+
const call = invoke.callDirectly(DetoxMatcherApi.matcherWithDescendant(this, matcher));
|
16
|
+
return new NativeMatcher(call);
|
13
17
|
}
|
14
18
|
|
15
19
|
and(matcher) {
|
16
|
-
|
17
|
-
return
|
20
|
+
const call = invoke.callDirectly(DetoxMatcherApi.matcherForAnd(this, matcher));
|
21
|
+
return new NativeMatcher(call);
|
18
22
|
}
|
19
23
|
|
20
24
|
or(matcher) {
|
21
|
-
|
22
|
-
return
|
25
|
+
const call = invoke.callDirectly(DetoxMatcherApi.matcherForOr(this, matcher));
|
26
|
+
return new NativeMatcher(call);
|
23
27
|
}
|
24
28
|
|
25
29
|
get not() {
|
26
|
-
|
27
|
-
return
|
30
|
+
const call = invoke.callDirectly(DetoxMatcherApi.matcherForNot(this));
|
31
|
+
return new NativeMatcher(call);
|
28
32
|
}
|
29
33
|
|
30
34
|
_avoidProblematicReactNativeElements() {
|
@@ -69,7 +69,7 @@ class WebElement {
|
|
69
69
|
static runScriptWithArgs(element, script, args) {
|
70
70
|
if (typeof script !== "string") throw new Error("script should be a string, but got " + (script + (" (" + (typeof script + ")"))));
|
71
71
|
|
72
|
-
if (typeof args !== 'object' || !args
|
72
|
+
if (typeof args !== 'object' || !Array.isArray(args)) {
|
73
73
|
throw new Error('args must be an array, got ' + typeof args);
|
74
74
|
}
|
75
75
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
|
2
2
|
const { expectDescription, actionDescription } = require('../../utils/invocationTraceDescriptions');
|
3
|
-
const
|
3
|
+
const log = require('../../utils/logger').child({ cat: 'ws-client, ws' });
|
4
|
+
const traceInvocationCall = require('../../utils/traceInvocationCall').bind(null, log);
|
4
5
|
const { ScrollAmountStopAtEdgeAction } = require('../actions/native');
|
5
6
|
const { NativeMatcher } = require('../core/NativeMatcher');
|
6
7
|
const DetoxAssertionApi = require('../espressoapi/DetoxAssertion');
|
@@ -18,7 +19,7 @@ class Interaction {
|
|
18
19
|
}
|
19
20
|
|
20
21
|
async execute() {
|
21
|
-
return
|
22
|
+
return traceInvocationCall(this._traceDescription, this._call,
|
22
23
|
this._invocationManager.execute(this._call).then((resultObj) => resultObj ? resultObj.result : undefined));
|
23
24
|
}
|
24
25
|
}
|
@@ -64,8 +64,7 @@ class ToggleMatcher extends NativeMatcher {
|
|
64
64
|
}
|
65
65
|
}
|
66
66
|
|
67
|
-
// TODO
|
68
|
-
// Please be aware, that this is just a dummy matcher
|
67
|
+
// TODO: Please be aware, that this is just a dummy matcher
|
69
68
|
class TraitsMatcher extends NativeMatcher {
|
70
69
|
constructor(value) {
|
71
70
|
super();
|
@@ -46,13 +46,13 @@ class ArtifactsManager extends EventEmitter {
|
|
46
46
|
_resolveArtifactsPathBuilder(pathBuilder, rootDir) {
|
47
47
|
if (typeof pathBuilder === 'string') {
|
48
48
|
pathBuilder = resolveModuleFromPath(pathBuilder);
|
49
|
+
}
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
}
|
51
|
+
if (typeof pathBuilder === 'function') {
|
52
|
+
try {
|
53
|
+
pathBuilder = pathBuilder({ rootDir });
|
54
|
+
} catch (e) {
|
55
|
+
pathBuilder = new pathBuilder({ rootDir });
|
56
56
|
}
|
57
57
|
}
|
58
58
|
|