detox 20.0.14-is-hittable-over-master.0 → 20.0.14-prerelease.0
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.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-javadoc.jar → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-sources.jar → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.aar → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0.aar} +0 -0
- package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.aar.md5 → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0.aar.md5} +0 -0
- package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.aar.sha1 → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0.aar.sha1} +0 -0
- package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.aar.sha256 → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0.aar.sha256} +0 -0
- package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.aar.sha512 → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0.aar.sha512} +0 -0
- package/Detox-android/com/wix/detox/{20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.pom → 20.0.14-prerelease.0/detox-20.0.14-prerelease.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.14-prerelease.0/detox-20.0.14-prerelease.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/build.gradle +0 -1
- package/android/detox/proguard-rules-app.pro +4 -2
- package/index.d.ts +105 -19
- package/internals.d.ts +103 -22
- package/local-cli/cli.js +1 -1
- package/local-cli/init.js +1 -1
- package/local-cli/test.js +6 -6
- package/local-cli/test.test.js +41 -41
- package/local-cli/testCommand/TestRunnerCommand.js +75 -78
- package/local-cli/testCommand/builder.js +0 -1
- package/local-cli/testCommand/middlewares.js +1 -11
- package/local-cli/testCommand/warnings.js +0 -3
- package/local-cli/utils/jestInternals.js +4 -1
- package/package.json +27 -13
- 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 +7 -3
- 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/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -1
- package/src/DetoxWorker.js +95 -55
- package/src/artifacts/ArtifactsManager.js +6 -24
- package/src/configuration/collectCliConfig.js +1 -12
- package/src/configuration/composeLoggerConfig.js +2 -2
- package/src/configuration/composeRunnerConfig.js +8 -6
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +1 -1
- package/src/errors/DetoxConfigErrorComposer.js +6 -1
- package/src/ipc/SessionState.js +8 -6
- package/src/logger/DetoxLogger.js +5 -25
- package/src/logger/index.js +1 -0
- package/src/logger/utils/CategoryThreadDispatcher.js +7 -29
- package/src/logger/utils/DetoxLogFinalizer.js +134 -0
- package/src/logger/utils/ThreadDispatcher.js +5 -25
- package/src/logger/utils/customConsoleLogger.js +4 -3
- package/src/logger/utils/streamUtils.js +34 -26
- package/src/realms/DetoxContext.js +10 -13
- package/src/realms/DetoxInternalsFacade.js +0 -6
- package/src/realms/DetoxPrimaryContext.js +29 -84
- package/src/realms/DetoxSecondaryContext.js +6 -10
- package/src/symbols.js +0 -12
- package/src/utils/argparse.js +11 -0
- package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.14-is-hittable-over-master.0/detox-20.0.14-is-hittable-over-master.0.pom.sha512 +0 -1
- package/runners/jest/deprecation.js +0 -25
- package/src/configuration/utils/warnings.js +0 -12
package/src/DetoxWorker.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
const CAF = require('caf');
|
1
2
|
const _ = require('lodash');
|
2
3
|
|
3
4
|
const Client = require('./client/Client');
|
@@ -11,7 +12,7 @@ const uuid = require('./utils/uuid');
|
|
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,44 +215,45 @@ class DetoxWorker {
|
|
190
215
|
return this._context.log;
|
191
216
|
}
|
192
217
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
218
|
+
onRunDescribeStart = function* (_signal, ...args) {
|
219
|
+
yield this._artifactsManager.onRunDescribeStart(...args);
|
220
|
+
};
|
221
|
+
|
222
|
+
onTestStart = function* (_signal, testSummary) {
|
197
223
|
this._validateTestSummary('beforeEach', testSummary);
|
198
224
|
|
199
|
-
|
200
|
-
await this._dumpUnhandledErrorsIfAny({
|
225
|
+
yield this._dumpUnhandledErrorsIfAny({
|
201
226
|
pendingRequests: false,
|
202
227
|
testName: testSummary.fullName,
|
203
228
|
});
|
204
229
|
|
205
|
-
|
206
|
-
|
230
|
+
yield this._artifactsManager.onTestStart(testSummary);
|
231
|
+
};
|
232
|
+
|
233
|
+
onHookFailure = function* (_signal, ...args) {
|
234
|
+
yield this._artifactsManager.onHookFailure(...args);
|
207
235
|
};
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
onTestDone = async (testSummary) => {
|
215
|
-
if (this._isCleaningUp) return;
|
236
|
+
|
237
|
+
onTestFnFailure = function* (_signal, ...args) {
|
238
|
+
yield this._artifactsManager.onTestFnFailure(...args);
|
239
|
+
};
|
240
|
+
|
241
|
+
onTestDone = function* (_signal, testSummary) {
|
216
242
|
this._validateTestSummary('afterEach', testSummary);
|
217
243
|
|
218
|
-
|
219
|
-
await this._artifactsManager.onTestDone(testSummary);
|
244
|
+
yield this._artifactsManager.onTestDone(testSummary);
|
220
245
|
|
221
|
-
|
222
|
-
await this._dumpUnhandledErrorsIfAny({
|
246
|
+
yield this._dumpUnhandledErrorsIfAny({
|
223
247
|
pendingRequests: testSummary.timedOut,
|
224
248
|
testName: testSummary.fullName,
|
225
249
|
});
|
226
250
|
};
|
227
|
-
onRunDescribeFinish = async (...args) => this._artifactsManager.onRunDescribeFinish(...args);
|
228
|
-
onRunFinish = async (...args) => this._artifactsManager.onRunFinish(...args);
|
229
251
|
|
230
|
-
|
252
|
+
onRunDescribeFinish = function* (_signal, ...args) {
|
253
|
+
yield this._artifactsManager.onRunDescribeFinish(...args);
|
254
|
+
};
|
255
|
+
|
256
|
+
*_reinstallAppsOnDevice(_signal) {
|
231
257
|
const appNames = _(this._appsConfig)
|
232
258
|
.map((config, key) => [key, `${config.binaryPath}:${config.testBinaryPath}`])
|
233
259
|
.uniqBy(1)
|
@@ -235,17 +261,13 @@ class DetoxWorker {
|
|
235
261
|
.value();
|
236
262
|
|
237
263
|
for (const appName of appNames) {
|
238
|
-
|
239
|
-
|
240
|
-
await this.device.uninstallApp();
|
241
|
-
if (this._isCleaningUp) return;
|
264
|
+
yield this.device.selectApp(appName);
|
265
|
+
yield this.device.uninstallApp();
|
242
266
|
}
|
243
267
|
|
244
268
|
for (const appName of appNames) {
|
245
|
-
|
246
|
-
|
247
|
-
await this.device.installApp();
|
248
|
-
if (this._isCleaningUp) return;
|
269
|
+
yield this.device.selectApp(appName);
|
270
|
+
yield this.device.installApp();
|
249
271
|
}
|
250
272
|
}
|
251
273
|
|
@@ -277,10 +299,28 @@ class DetoxWorker {
|
|
277
299
|
error
|
278
300
|
);
|
279
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
|
+
|
280
320
|
}
|
281
321
|
|
282
322
|
/**
|
283
|
-
* @type {NodeJS.Global}
|
323
|
+
* @type {NodeJS.Global | {}}
|
284
324
|
*/
|
285
325
|
DetoxWorker.global = global;
|
286
326
|
|
@@ -32,19 +32,13 @@ class ArtifactsManager extends EventEmitter {
|
|
32
32
|
'onBootDevice',
|
33
33
|
'onCreateExternalArtifact',
|
34
34
|
'onHookFailure',
|
35
|
-
'onHookStart',
|
36
|
-
'onHookSuccess',
|
37
35
|
'onLaunchApp',
|
38
36
|
'onRunDescribeFinish',
|
39
37
|
'onRunDescribeStart',
|
40
|
-
'onRunFinish',
|
41
|
-
'onRunStart',
|
42
38
|
'onShutdownDevice',
|
43
39
|
'onTerminateApp',
|
44
40
|
'onTestDone',
|
45
41
|
'onTestFnFailure',
|
46
|
-
'onTestFnStart',
|
47
|
-
'onTestFnSuccess',
|
48
42
|
'onTestStart',
|
49
43
|
]);
|
50
44
|
}
|
@@ -52,13 +46,13 @@ class ArtifactsManager extends EventEmitter {
|
|
52
46
|
_resolveArtifactsPathBuilder(pathBuilder, rootDir) {
|
53
47
|
if (typeof pathBuilder === 'string') {
|
54
48
|
pathBuilder = resolveModuleFromPath(pathBuilder);
|
49
|
+
}
|
55
50
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}
|
51
|
+
if (typeof pathBuilder === 'function') {
|
52
|
+
try {
|
53
|
+
pathBuilder = pathBuilder({ rootDir });
|
54
|
+
} catch (e) {
|
55
|
+
pathBuilder = new pathBuilder({ rootDir });
|
62
56
|
}
|
63
57
|
}
|
64
58
|
|
@@ -185,8 +179,6 @@ class ArtifactsManager extends EventEmitter {
|
|
185
179
|
});
|
186
180
|
}
|
187
181
|
|
188
|
-
async onRunStart() {}
|
189
|
-
|
190
182
|
async onRunDescribeStart(suite) {
|
191
183
|
await this._callPlugins('ascending', 'onRunDescribeStart', suite);
|
192
184
|
}
|
@@ -195,22 +187,14 @@ class ArtifactsManager extends EventEmitter {
|
|
195
187
|
await this._callPlugins('ascending', 'onTestStart', testSummary);
|
196
188
|
}
|
197
189
|
|
198
|
-
async onHookStart() {}
|
199
|
-
|
200
190
|
async onHookFailure(testSummary) {
|
201
191
|
await this._callPlugins('plain', 'onHookFailure', testSummary);
|
202
192
|
}
|
203
193
|
|
204
|
-
async onHookSuccess() {}
|
205
|
-
|
206
|
-
async onTestFnStart() {}
|
207
|
-
|
208
194
|
async onTestFnFailure(testSummary) {
|
209
195
|
await this._callPlugins('plain', 'onTestFnFailure', testSummary);
|
210
196
|
}
|
211
197
|
|
212
|
-
async onTestFnSuccess() {}
|
213
|
-
|
214
198
|
async onTestDone(testSummary) {
|
215
199
|
await this._callPlugins('descending', 'onTestDone', testSummary);
|
216
200
|
}
|
@@ -219,8 +203,6 @@ class ArtifactsManager extends EventEmitter {
|
|
219
203
|
await this._callPlugins('descending', 'onRunDescribeFinish', suite);
|
220
204
|
}
|
221
205
|
|
222
|
-
async onRunFinish() {}
|
223
|
-
|
224
206
|
async onBeforeCleanup() {
|
225
207
|
await this._callPlugins('descending', 'onBeforeCleanup');
|
226
208
|
await this._idlePromise;
|
@@ -1,9 +1,6 @@
|
|
1
1
|
const _ = require('lodash');
|
2
2
|
|
3
3
|
const argparse = require('../utils/argparse');
|
4
|
-
const log = require('../utils/logger').child({ cat: 'config' });
|
5
|
-
|
6
|
-
const { DEVICE_LAUNCH_ARGS_GENERIC_DEPRECATION } = require('./utils/warnings');
|
7
4
|
|
8
5
|
const asBoolean = (value) => {
|
9
6
|
if (typeof value === 'boolean') {
|
@@ -25,14 +22,6 @@ const asNumber = (value) => {
|
|
25
22
|
: undefined;
|
26
23
|
};
|
27
24
|
|
28
|
-
const deprecateDeviceLaunchArgs = (value) => {
|
29
|
-
if (value) {
|
30
|
-
log.warn(DEVICE_LAUNCH_ARGS_GENERIC_DEPRECATION);
|
31
|
-
}
|
32
|
-
|
33
|
-
return value;
|
34
|
-
};
|
35
|
-
|
36
25
|
function collectCliConfig({ argv }) {
|
37
26
|
const env = (key) => argparse.getArgValue(key);
|
38
27
|
const get = (key, fallback) => {
|
@@ -51,7 +40,7 @@ function collectCliConfig({ argv }) {
|
|
51
40
|
configPath: get('config-path'),
|
52
41
|
configuration: get('configuration'),
|
53
42
|
debugSynchronization: asNumber(get('debug-synchronization')),
|
54
|
-
deviceBootArgs: get('device-boot-args'
|
43
|
+
deviceBootArgs: get('device-boot-args'),
|
55
44
|
appLaunchArgs: get('app-launch-args'),
|
56
45
|
deviceName: get('device-name'),
|
57
46
|
forceAdbInstall: asBoolean(get('force-adb-install')),
|
@@ -14,7 +14,7 @@ function composeLoggerConfig(opts) {
|
|
14
14
|
const items = [
|
15
15
|
{
|
16
16
|
level: 'info',
|
17
|
-
overrideConsole:
|
17
|
+
overrideConsole: true,
|
18
18
|
options: defaultOptions,
|
19
19
|
},
|
20
20
|
globalConfig.logger,
|
@@ -46,7 +46,7 @@ function adaptCLI(cliConfig) {
|
|
46
46
|
}
|
47
47
|
|
48
48
|
if (cliConfig.useCustomLogger !== undefined) {
|
49
|
-
result.overrideConsole = cliConfig.useCustomLogger
|
49
|
+
result.overrideConsole = cliConfig.useCustomLogger;
|
50
50
|
}
|
51
51
|
|
52
52
|
if (cliConfig.noColor) {
|
@@ -56,11 +56,12 @@ function composeRunnerConfig(opts) {
|
|
56
56
|
|
57
57
|
if (typeof merged.inspectBrk === 'function') {
|
58
58
|
if (cliConfig.inspectBrk) {
|
59
|
+
merged.retries = 0;
|
60
|
+
merged.forwardEnv = true;
|
59
61
|
merged.inspectBrk(merged);
|
60
|
-
merged.inspectBrk = true;
|
61
|
-
} else {
|
62
|
-
merged.inspectBrk = false;
|
63
62
|
}
|
63
|
+
|
64
|
+
delete merged.inspectBrk;
|
64
65
|
}
|
65
66
|
|
66
67
|
return merged;
|
@@ -119,9 +120,10 @@ function hasEmptyPositionalArgs(value, key) {
|
|
119
120
|
* @param {Detox.DetoxTestRunnerConfig} config
|
120
121
|
*/
|
121
122
|
function inspectBrkHookDefault(config) {
|
122
|
-
|
123
|
-
|
124
|
-
|
123
|
+
/* istanbul ignore next */
|
124
|
+
config.args.$0 = os.platform() !== 'win32'
|
125
|
+
? `node --inspect-brk ./node_modules/.bin/jest`
|
126
|
+
: `node --inspect-brk ./node_modules/jest/bin/jest.js`;
|
125
127
|
config.args.runInBand = true;
|
126
128
|
delete config.args.w;
|
127
129
|
delete config.args.workers;
|
@@ -93,7 +93,7 @@ class AppleSimUtils {
|
|
93
93
|
`(https://developer.apple.com/xcode/). In case you already have the latest Xcode version installed, ` +
|
94
94
|
`try run the command: \`sudo xcode-select -s /Applications/Xcode.app\`. If you are running tests from CI, ` +
|
95
95
|
`we recommend running them with "--headless" device configuration (see: ` +
|
96
|
-
`https://wix.github.io/Detox/docs/next/
|
96
|
+
`https://wix.github.io/Detox/docs/next/cli/test/#options).`
|
97
97
|
);
|
98
98
|
}
|
99
99
|
|
@@ -664,7 +664,12 @@ Examine your Detox config${this._atPath()}`,
|
|
664
664
|
}
|
665
665
|
|
666
666
|
invalidTestRunnerProperty(isGlobal) {
|
667
|
-
const testRunner = _.get(
|
667
|
+
const testRunner = _.get(
|
668
|
+
isGlobal
|
669
|
+
? this.contents
|
670
|
+
: this._getSelectedConfiguration(),
|
671
|
+
['testRunner']
|
672
|
+
);
|
668
673
|
|
669
674
|
return new DetoxConfigError({
|
670
675
|
message: `testRunner should be an object, not a ${typeof testRunner}`,
|
package/src/ipc/SessionState.js
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
const vm = require('vm');
|
2
|
+
|
1
3
|
const cycle = require('json-cycle');
|
2
4
|
|
3
|
-
const
|
5
|
+
const context = vm.createContext({ require }, {
|
6
|
+
name: 'VM User Context',
|
7
|
+
});
|
4
8
|
|
5
9
|
class SessionState {
|
6
10
|
constructor({
|
7
|
-
id =
|
11
|
+
id = '',
|
8
12
|
contexts = [],
|
9
|
-
detoxConfigSnapshotPath = '',
|
10
13
|
detoxConfig = null,
|
11
14
|
detoxIPCServer = '',
|
12
15
|
testResults = [],
|
@@ -15,7 +18,6 @@ class SessionState {
|
|
15
18
|
}) {
|
16
19
|
this.id = id;
|
17
20
|
this.contexts = contexts;
|
18
|
-
this.detoxConfigSnapshotPath = detoxConfigSnapshotPath;
|
19
21
|
this.detoxConfig = detoxConfig;
|
20
22
|
this.detoxIPCServer = detoxIPCServer;
|
21
23
|
this.testResults = testResults;
|
@@ -41,8 +43,8 @@ class SessionState {
|
|
41
43
|
}
|
42
44
|
|
43
45
|
static reviver(key, val) {
|
44
|
-
if (typeof val === 'object' && typeof val.$fn == 'string') {
|
45
|
-
return
|
46
|
+
if (typeof val === 'object' && val !== null && typeof val.$fn == 'string') {
|
47
|
+
return vm.runInContext(val.$fn, context);
|
46
48
|
} else {
|
47
49
|
return val;
|
48
50
|
}
|
@@ -55,7 +55,7 @@ class DetoxLogger {
|
|
55
55
|
|
56
56
|
this._sharedConfig.userConfig = this._sharedConfig.userConfig || {
|
57
57
|
level: 'info',
|
58
|
-
overrideConsole:
|
58
|
+
overrideConsole: false,
|
59
59
|
options: {
|
60
60
|
showDate: false,
|
61
61
|
showLoggerName: false,
|
@@ -71,25 +71,7 @@ class DetoxLogger {
|
|
71
71
|
.installFileStream(this.file)
|
72
72
|
.installDebugStream(this.config);
|
73
73
|
|
74
|
-
this._sharedConfig.dispatcher = new CategoryThreadDispatcher(
|
75
|
-
logger: this,
|
76
|
-
categories: {
|
77
|
-
'lifecycle': [0],
|
78
|
-
'cli': [1],
|
79
|
-
'logger': [2],
|
80
|
-
'ipc': [29],
|
81
|
-
'ws-server': [50, 99],
|
82
|
-
'ws-client': [100, 149],
|
83
|
-
'device': [150, 159],
|
84
|
-
'artifacts-manager': [300],
|
85
|
-
'artifacts-plugin': [310, 349],
|
86
|
-
'artifact': [350, 399],
|
87
|
-
'child-process': [400, 499],
|
88
|
-
'default': [999],
|
89
|
-
'user': [10000, 10999]
|
90
|
-
},
|
91
|
-
});
|
92
|
-
|
74
|
+
this._sharedConfig.dispatcher = new CategoryThreadDispatcher();
|
93
75
|
this._sharedConfig.messageStack = new MessageStack();
|
94
76
|
|
95
77
|
this.overrideConsole();
|
@@ -143,14 +125,12 @@ class DetoxLogger {
|
|
143
125
|
* @internal
|
144
126
|
*/
|
145
127
|
overrideConsole(sandbox) {
|
146
|
-
const
|
147
|
-
if (
|
128
|
+
const enabled = this.config.overrideConsole;
|
129
|
+
if (!enabled) {
|
148
130
|
return;
|
149
131
|
}
|
150
132
|
|
151
|
-
|
152
|
-
customConsoleLogger.overrideConsoleMethods((sandbox || global).console, this);
|
153
|
-
}
|
133
|
+
customConsoleLogger.overrideConsoleMethods((sandbox || global).console, this);
|
154
134
|
}
|
155
135
|
|
156
136
|
/**
|
package/src/logger/index.js
CHANGED
@@ -1,23 +1,9 @@
|
|
1
|
-
const _ = require('lodash');
|
2
|
-
|
3
1
|
const ThreadDispatcher = require('./ThreadDispatcher');
|
4
2
|
|
5
3
|
class CategoryThreadDispatcher {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
* @param {Detox.Logger} config.logger
|
10
|
-
*/
|
11
|
-
constructor(config) {
|
12
|
-
this.categories = config.categories;
|
13
|
-
this.dispatchers = _.mapValues(this.categories, (range, name) => {
|
14
|
-
return new ThreadDispatcher({
|
15
|
-
name,
|
16
|
-
logger: config.logger,
|
17
|
-
min: range[0],
|
18
|
-
max: range[1] || range[0],
|
19
|
-
});
|
20
|
-
});
|
4
|
+
constructor() {
|
5
|
+
/** @type {Record<string, ThreadDispatcher>} */
|
6
|
+
this._dispatchers = {};
|
21
7
|
}
|
22
8
|
|
23
9
|
/**
|
@@ -38,20 +24,12 @@ class CategoryThreadDispatcher {
|
|
38
24
|
|
39
25
|
/** @returns {ThreadDispatcher} */
|
40
26
|
_resolveDispatcher(cat) {
|
41
|
-
const mainCategory = cat ? cat.split(',', 1)[0] : '';
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
categorize(tid) {
|
46
|
-
return _.findKey(this.categories, ([min, max]) => min <= tid && tid <= max) || 'default';
|
47
|
-
}
|
48
|
-
|
49
|
-
threadize(cat) {
|
50
|
-
if (!cat) {
|
51
|
-
return this.categories.default[0];
|
27
|
+
const mainCategory = cat ? cat.split(',', 1)[0] : 'default';
|
28
|
+
if (!this._dispatchers[mainCategory]) {
|
29
|
+
this._dispatchers[mainCategory] = new ThreadDispatcher(mainCategory);
|
52
30
|
}
|
53
31
|
|
54
|
-
return
|
32
|
+
return this._dispatchers[mainCategory];
|
55
33
|
}
|
56
34
|
}
|
57
35
|
|