detox 19.9.1 → 20.0.2-breaking.new-global-lifecycle.0
Sign up to get free protection for your applications and to get access to all the features.
- package/Detox-android/com/wix/detox/{19.9.1/detox-19.9.1-javadoc.jar → 20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.9.1/detox-19.9.1-sources.jar → 20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.9.1/detox-19.9.1.pom → 20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.2-breaking.new-global-lifecycle.0/detox-20.0.2-breaking.new-global-lifecycle.0.pom.sha512 +1 -0
- package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
- package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
- package/Detox-ios-src.tbz +0 -0
- package/Detox-ios.tbz +0 -0
- package/android/detox/src/full/java/com/wix/detox/Detox.java +2 -59
- package/android/detox/src/full/java/com/wix/detox/NotificationDataParser.kt +3 -3
- package/index.d.ts +213 -186
- package/index.js +1 -0
- package/internals.d.ts +131 -0
- package/internals.js +4 -0
- package/local-cli/build-framework-cache.js +2 -2
- package/local-cli/build.js +7 -8
- package/local-cli/build.test.js +46 -40
- package/local-cli/clean-framework-cache.js +3 -3
- package/local-cli/cli.js +0 -1
- package/local-cli/init.js +20 -55
- package/local-cli/templates/jest.js +9 -34
- package/local-cli/test.js +18 -282
- package/local-cli/test.test.js +337 -672
- package/local-cli/testCommand/TestRunnerCommand.js +156 -0
- package/local-cli/{utils/testCommandArgs.js → testCommand/builder.js} +10 -35
- package/local-cli/testCommand/middlewares.js +75 -0
- package/local-cli/{utils → testCommand}/warnings.js +0 -10
- package/local-cli/utils/jestInternals.js +13 -2
- package/local-cli/utils/yargsUtils.js +67 -0
- package/package.json +26 -20
- package/runners/deprecation.js +47 -0
- package/runners/jest/JestCircusEnvironment.js +3 -38
- package/runners/jest/adapter.d.ts +4 -10
- package/runners/jest/adapter.js +3 -6
- package/runners/jest/assignReporter.d.ts +4 -1
- package/runners/jest/assignReporter.js +3 -6
- package/runners/jest/deprecation.js +25 -0
- package/runners/jest/globalSetup.js +1 -0
- package/runners/jest/globalTeardown.js +1 -0
- package/runners/jest/index.js +21 -0
- package/runners/jest/reporter.js +1 -0
- package/runners/jest/reporters/DetoxReporter.js +5 -0
- package/runners/jest/specReporter.d.ts +4 -9
- package/runners/jest/specReporter.js +3 -10
- package/runners/jest/streamlineReporter.js +3 -22
- package/runners/jest/testEnvironment/index.js +155 -0
- package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxCoreListener.js +36 -22
- package/runners/{jest-circus → jest/testEnvironment}/listeners/DetoxInitErrorListener.js +1 -1
- package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +27 -0
- package/runners/jest/{SpecReporterImpl.js → testEnvironment/listeners/SpecReporter.js} +61 -7
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +34 -0
- package/runners/jest/testEnvironment/listeners/index.js +13 -0
- package/runners/{jest-circus → jest/testEnvironment}/utils/assertExistingContext.js +2 -2
- package/runners/jest/testEnvironment/utils/assertJestCircus27.js +56 -0
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +23 -0
- package/runners/jest/{utils → testEnvironment/utils}/getFullTestName.js +0 -0
- package/runners/jest/{utils → testEnvironment/utils}/hasTimedOut.js +0 -0
- package/runners/jest/{utils → testEnvironment/utils}/index.js +0 -0
- package/runners/jest/{utils → testEnvironment/utils}/stdout.js +0 -0
- package/runners/jest-circus/environment/index.js +6 -0
- package/runners/jest-circus/index.js +1 -10
- package/runners/jest-circus/reporter.js +1 -0
- package/runners/migration.js +37 -0
- package/runners/mocha/DetoxMochaAdapter.js +3 -35
- package/runners/mocha/adapter.d.ts +4 -7
- package/runners/mocha/adapter.js +3 -5
- package/src/{Detox.js → DetoxWorker.js} +131 -164
- package/src/artifacts/ArtifactsManager.js +51 -2
- package/src/artifacts/providers/index.js +0 -4
- package/src/artifacts/utils/buildDefaultArtifactsRootDirpath.js +2 -4
- package/src/artifacts/utils/temporaryPath.js +2 -0
- package/src/client/AsyncWebSocket.js +1 -1
- package/src/client/actions/actions.js +2 -2
- package/src/configuration/collectCliConfig.js +2 -4
- package/src/configuration/composeAppsConfig.js +8 -66
- package/src/configuration/composeArtifactsConfig.js +6 -32
- package/src/configuration/composeBehaviorConfig.js +3 -13
- package/src/configuration/composeDeviceConfig.js +37 -62
- package/src/configuration/composeLoggerConfig.js +50 -0
- package/src/configuration/composeRunnerConfig.js +75 -14
- package/src/configuration/composeSessionConfig.js +1 -3
- package/src/configuration/index.js +24 -23
- package/src/configuration/utils/deviceAppTypes.js +0 -1
- package/src/devices/allocation/DeviceAllocator.js +3 -3
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +2 -6
- package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +1 -1
- package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +3 -3
- package/src/devices/allocation/factories/index.js +0 -1
- package/src/devices/common/drivers/DeviceLauncher.js +2 -2
- package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +1 -1
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +4 -9
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +34 -9
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +1 -1
- package/src/devices/runtime/RuntimeDevice.js +69 -81
- package/src/devices/runtime/drivers/index.js +0 -1
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +3 -2
- package/src/devices/runtime/factories/ios.js +1 -8
- package/src/devices/runtime/utils/LaunchArgsEditor.js +4 -59
- package/src/devices/runtime/utils/Storage.js +4 -0
- package/src/environmentFactory.js +0 -8
- package/src/errors/DetoxConfigErrorComposer.js +77 -30
- package/src/errors/DetoxError.js +4 -0
- package/src/errors/DetoxRuntimeError.js +5 -5
- package/src/errors/index.js +2 -0
- package/src/ipc/IPCClient.js +118 -0
- package/src/ipc/IPCServer.js +94 -0
- package/src/ipc/state.js +89 -0
- package/src/logger/DetoxLogger.js +244 -0
- package/src/logger/DetoxTraceEventBuilder.js +21 -0
- package/src/logger/DetoxTracer.js +133 -0
- package/src/logger/TraceThreadDispatcher.js +52 -0
- package/src/{utils → logger}/customConsoleLogger.js +1 -1
- package/src/realms/DetoxConstants.js +13 -0
- package/src/realms/DetoxContext.js +170 -0
- package/src/realms/DetoxInternalsFacade.js +35 -0
- package/src/realms/DetoxPrimaryContext.js +229 -0
- package/src/realms/DetoxSecondaryContext.js +94 -0
- package/src/realms/index.js +10 -0
- package/src/realms/primary.js +3 -0
- package/src/realms/secondary.js +3 -0
- package/src/server/DetoxConnection.js +1 -1
- package/src/symbols.js +56 -0
- package/src/utils/Timer.js +14 -6
- package/{local-cli/utils/misc.js → src/utils/envUtils.js} +0 -9
- package/src/utils/logger.js +2 -162
- package/src/utils/shellUtils.js +18 -0
- package/src/utils/streamUtils.js +214 -0
- package/src/utils/trace.js +9 -44
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar +0 -0
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.9.1/detox-19.9.1.pom.sha512 +0 -1
- package/local-cli/templates/mocha.js +0 -32
- package/local-cli/utils/splitArgv.js +0 -107
- package/runners/integration.js +0 -16
- package/runners/jest/DetoxAdapterCircus.js +0 -60
- package/runners/jest/DetoxAdapterImpl.js +0 -81
- package/runners/jest/DetoxAdapterJasmine.js +0 -67
- package/runners/jest/DetoxStreamlineJestReporter.js +0 -98
- package/runners/jest/FailingTestsReporter.js +0 -16
- package/runners/jest/SpecReporterCircus.js +0 -51
- package/runners/jest/SpecReporterJasmine.js +0 -39
- package/runners/jest/WorkerAssignReporterCircus.js +0 -17
- package/runners/jest/WorkerAssignReporterImpl.js +0 -21
- package/runners/jest/WorkerAssignReporterJasmine.js +0 -15
- package/runners/jest/runnerInfo.js +0 -9
- package/runners/jest-circus/environment.js +0 -206
- package/runners/jest-circus/utils/assertJestCircus26.js +0 -39
- package/runners/jest-circus/utils/wrapErrorWithNoopLifecycle.js +0 -14
- package/src/DetoxConstants.js +0 -13
- package/src/DetoxExportWrapper.js +0 -140
- package/src/artifacts/timeline/TimelineArtifactPlugin.js +0 -95
- package/src/devices/allocation/drivers/NoneAllocDriver.js +0 -10
- package/src/devices/allocation/factories/none.js +0 -11
- package/src/index.js +0 -6
- package/src/utils/MissingDetox.js +0 -78
- package/src/utils/fakeTimestampsProvider.js +0 -9
- package/src/utils/getWorkerId.js +0 -5
- package/src/utils/lastFailedTests.js +0 -38
- package/src/utils/sh.js +0 -18
@@ -0,0 +1,214 @@
|
|
1
|
+
const { PassThrough, Transform } = require('stream');
|
2
|
+
|
3
|
+
const bunyanDebugStream = require('bunyan-debug-stream');
|
4
|
+
const duplexify = require('duplexify');
|
5
|
+
const multiSort = require('multi-sort-stream');
|
6
|
+
const pipe = require('multipipe');
|
7
|
+
const JsonlParser = require('stream-json/jsonl/Parser');
|
8
|
+
const stripAnsi = require('strip-ansi');
|
9
|
+
const { AbstractEventBuilder } = require('trace-event-lib');
|
10
|
+
|
11
|
+
const DetoxTracer = require('../logger/DetoxTracer');
|
12
|
+
|
13
|
+
const log = require('./logger').child({ __filename });
|
14
|
+
|
15
|
+
function compareTimestamps(a, b) {
|
16
|
+
return +(a.value.time > b.value.time) - +(a.value.time < b.value.time);
|
17
|
+
}
|
18
|
+
|
19
|
+
function mapTransform(fn) {
|
20
|
+
return new Transform({
|
21
|
+
objectMode: true,
|
22
|
+
transform(chunk, encoding, callback){
|
23
|
+
this.push(fn(chunk));
|
24
|
+
callback();
|
25
|
+
},
|
26
|
+
});
|
27
|
+
}
|
28
|
+
|
29
|
+
function flatMapTransform(fn) {
|
30
|
+
let index = 0;
|
31
|
+
|
32
|
+
return new Transform({
|
33
|
+
objectMode: true,
|
34
|
+
transform(chunk, encoding, callback){
|
35
|
+
const result = fn(chunk, index++);
|
36
|
+
if (Array.isArray(result)) {
|
37
|
+
// eslint-disable-next-line unicorn/no-array-method-this-argument
|
38
|
+
result.forEach(pushThis, this);
|
39
|
+
} else if (result) {
|
40
|
+
this.push(result);
|
41
|
+
}
|
42
|
+
|
43
|
+
callback();
|
44
|
+
},
|
45
|
+
});
|
46
|
+
}
|
47
|
+
|
48
|
+
function pushThis(x) {
|
49
|
+
return this.push(x);
|
50
|
+
}
|
51
|
+
|
52
|
+
function extractValue({ value }) {
|
53
|
+
value.msg = stripAnsi(value.msg);
|
54
|
+
|
55
|
+
if (typeof value.time === 'string') {
|
56
|
+
value.time = new Date(value.time);
|
57
|
+
}
|
58
|
+
|
59
|
+
return value;
|
60
|
+
}
|
61
|
+
|
62
|
+
function through() {
|
63
|
+
return new PassThrough({ objectMode: true });
|
64
|
+
}
|
65
|
+
|
66
|
+
function mergeSortedJSONL(jsonlStreams, comparator = compareTimestamps) {
|
67
|
+
const intermediate = mapTransform(extractValue);
|
68
|
+
const reemitError = (err) => intermediate.emit('error', err);
|
69
|
+
const addReemit = (stream) => stream.on('error', reemitError);
|
70
|
+
return pipe(multiSort(jsonlStreams.map(addReemit), comparator), intermediate, through());
|
71
|
+
}
|
72
|
+
|
73
|
+
function writeJSONL() {
|
74
|
+
return new JsonlStringer({
|
75
|
+
header: '',
|
76
|
+
delimiter: '\n',
|
77
|
+
footer: '',
|
78
|
+
});
|
79
|
+
}
|
80
|
+
|
81
|
+
function writeJSON() {
|
82
|
+
return new JsonlStringer({
|
83
|
+
header: '[\n\t',
|
84
|
+
delimiter: ',\n\t',
|
85
|
+
footer: '\n]\n',
|
86
|
+
});
|
87
|
+
}
|
88
|
+
|
89
|
+
function debugStream(options) {
|
90
|
+
const out = new PassThrough({ encoding: 'utf8' });
|
91
|
+
const writable = bunyanDebugStream.default({
|
92
|
+
...options,
|
93
|
+
colors: false,
|
94
|
+
out,
|
95
|
+
});
|
96
|
+
|
97
|
+
return duplexify(writable, out, {
|
98
|
+
readableObjectMode: false,
|
99
|
+
writableObjectMode: true
|
100
|
+
});
|
101
|
+
}
|
102
|
+
|
103
|
+
class JsonlStringer extends Transform {
|
104
|
+
constructor({ replacer = undefined, header = '', delimiter = '\n', footer = '' } = {}) {
|
105
|
+
super({ writableObjectMode: true, readableObjectMode: false });
|
106
|
+
|
107
|
+
this._replacer = replacer;
|
108
|
+
this._header = header;
|
109
|
+
this._delimiter = delimiter;
|
110
|
+
this._footer = footer;
|
111
|
+
}
|
112
|
+
|
113
|
+
_transform(chunk, _, callback) {
|
114
|
+
if (this._header) {
|
115
|
+
this.push(this._header);
|
116
|
+
}
|
117
|
+
|
118
|
+
this.push(JSON.stringify(chunk, this._replacer));
|
119
|
+
this._transform = this._nextTransform;
|
120
|
+
callback(null);
|
121
|
+
}
|
122
|
+
|
123
|
+
_nextTransform(chunk, _, callback) {
|
124
|
+
this.push(this._delimiter + JSON.stringify(chunk, this._replacer));
|
125
|
+
callback(null);
|
126
|
+
}
|
127
|
+
|
128
|
+
_flush(callback) {
|
129
|
+
if (this._footer) {
|
130
|
+
this.push(this._footer);
|
131
|
+
}
|
132
|
+
|
133
|
+
callback();
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
class SimpleEventBuilder extends AbstractEventBuilder {
|
138
|
+
events = [];
|
139
|
+
send(event) {
|
140
|
+
this.events.push(event);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
function chromeTraceStream() {
|
145
|
+
const knownPids = new Set();
|
146
|
+
const knownTids = new Set();
|
147
|
+
|
148
|
+
return flatMapTransform((data) => {
|
149
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
150
|
+
const { pid, trace, msg, time, name: _name, hostname: _hostname, ...args } = data;
|
151
|
+
const tid = trace ? trace.tid : DetoxTracer.threadize(args.cat);
|
152
|
+
const ts = new Date(time).getTime() * 1E3;
|
153
|
+
|
154
|
+
const builder = new SimpleEventBuilder();
|
155
|
+
if (!knownPids.has(pid)) {
|
156
|
+
builder.process_name(pid === process.pid ? 'primary' : 'secondary', pid);
|
157
|
+
knownPids.add(pid);
|
158
|
+
}
|
159
|
+
|
160
|
+
const tidHash = `${pid}:${tid}`;
|
161
|
+
if (!knownTids.has(tidHash)) {
|
162
|
+
builder.thread_name(DetoxTracer.categorize(tid), tid, pid);
|
163
|
+
builder.thread_sort_index(tid, tid, pid);
|
164
|
+
knownTids.add(tidHash);
|
165
|
+
}
|
166
|
+
|
167
|
+
const event = { ph: 'i', ...data.trace, pid, tid, ts, args };
|
168
|
+
if (!trace || trace.ph !== 'E') {
|
169
|
+
event.name = msg || '';
|
170
|
+
}
|
171
|
+
|
172
|
+
builder.events.push(event);
|
173
|
+
return builder.events;
|
174
|
+
});
|
175
|
+
}
|
176
|
+
|
177
|
+
// TODO: create PR to https://github.com/mafintosh/duplexify
|
178
|
+
// should be able to pass { error: false } to end-of-stream
|
179
|
+
function preventErrorSubscriptions(emitter) {
|
180
|
+
const originalOn = emitter.on.bind(emitter);
|
181
|
+
emitter.on = (event, ...args) => {
|
182
|
+
if (event === 'error') {
|
183
|
+
return emitter;
|
184
|
+
}
|
185
|
+
|
186
|
+
return originalOn(event, ...args);
|
187
|
+
};
|
188
|
+
|
189
|
+
return emitter;
|
190
|
+
}
|
191
|
+
|
192
|
+
function readJSONL() {
|
193
|
+
const readable = new PassThrough({ objectMode: true });
|
194
|
+
const writable = JsonlParser.make({ checkErrors: true })
|
195
|
+
.on('error', (err) => {
|
196
|
+
if (err instanceof SyntaxError) {
|
197
|
+
log.debug({ event: 'JSONL_ERROR', err });
|
198
|
+
readable.end();
|
199
|
+
} else {
|
200
|
+
readable.emit('error', err);
|
201
|
+
}
|
202
|
+
});
|
203
|
+
|
204
|
+
return duplexify.obj(preventErrorSubscriptions(writable), writable.pipe(readable));
|
205
|
+
}
|
206
|
+
|
207
|
+
module.exports = {
|
208
|
+
readJSONL,
|
209
|
+
writeJSON,
|
210
|
+
writeJSONL,
|
211
|
+
mergeSortedJSONL,
|
212
|
+
debugStream,
|
213
|
+
chromeTraceStream,
|
214
|
+
};
|
package/src/utils/trace.js
CHANGED
@@ -1,54 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
}
|
5
|
-
|
6
|
-
init(timestampProviderFn = Date.now) {
|
7
|
-
this._timestampProviderFn = timestampProviderFn;
|
8
|
-
this.events = [
|
9
|
-
this._event('init'),
|
10
|
-
];
|
11
|
-
}
|
1
|
+
/** @type {Detox.Tracer} */
|
2
|
+
const trace = require('../..').trace;
|
3
|
+
const traceCall = trace.bind(null);
|
12
4
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
endSection(name, args) {
|
18
|
-
this.events.push(this._event('end', name, args));
|
19
|
-
}
|
5
|
+
function traceMethods(obj, cat, methodNames) {
|
6
|
+
for (const name of methodNames) {
|
7
|
+
const originalMethod = obj[name];
|
20
8
|
|
21
|
-
|
22
|
-
|
23
|
-
this._event('init'),
|
24
|
-
];
|
25
|
-
}
|
26
|
-
|
27
|
-
_event(type, name, args) {
|
28
|
-
return {
|
29
|
-
type,
|
30
|
-
ts: this._timestampProviderFn(),
|
31
|
-
name,
|
32
|
-
args,
|
9
|
+
obj[name] = function tracedMethod() {
|
10
|
+
return traceCall({ cat, name }, originalMethod.apply.bind(originalMethod, obj, arguments));
|
33
11
|
};
|
34
12
|
}
|
35
13
|
}
|
36
14
|
|
37
|
-
let trace = new Trace();
|
38
|
-
async function traceCall(sectionName, func) {
|
39
|
-
trace.startSection(sectionName);
|
40
|
-
try {
|
41
|
-
const result = await func();
|
42
|
-
trace.endSection(sectionName, { success: true });
|
43
|
-
return result;
|
44
|
-
} catch (error) {
|
45
|
-
trace.endSection(sectionName, { success: false, error: error.toString() });
|
46
|
-
throw error;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
|
50
15
|
module.exports = {
|
51
|
-
Trace,
|
52
16
|
trace,
|
53
17
|
traceCall,
|
18
|
+
traceMethods,
|
54
19
|
};
|
@@ -1 +0,0 @@
|
|
1
|
-
31031f641f4838a7fd2cc69f228fab37
|
@@ -1 +0,0 @@
|
|
1
|
-
546ba7c24a48941f2bdd2895c0f9eb97ec9f93f4
|
@@ -1 +0,0 @@
|
|
1
|
-
98ed2bec49a0898295dbc63e4b01b3ec14b8ed8bc5f449f1ae13a8df46df8b94
|
@@ -1 +0,0 @@
|
|
1
|
-
ac217f1f8c18c192a449aee7cad69612a371d2e4a82458c8830c1242515cb3e73c3fa43aeaf45bd71025bc84760ae818c82583a74c17f944b6ff5182b5935398
|
@@ -1 +0,0 @@
|
|
1
|
-
1a67a8520ffb42030572c079d6c8dd61
|
@@ -1 +0,0 @@
|
|
1
|
-
18e724df796f8d00fa0029084092c30a75ad4acd
|
@@ -1 +0,0 @@
|
|
1
|
-
8394ad55a508ce78e5512f9a10a96e64ee4bdf6c7972ffdb90c9a70fa63e1430
|
@@ -1 +0,0 @@
|
|
1
|
-
84deae513735699bec509d7b5e2baf4142aab527881bc2d1e53a88bde7e0553fb28e89fedf14213caaa7ac714917156f2fc4c0d8fb5c194199489f57112547e3
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
f00a26db2932c0f5dd9e4ea695c5f55c
|
@@ -1 +0,0 @@
|
|
1
|
-
39dba13a0e694adb108fc6bb4d15b58b21a4eed5
|
@@ -1 +0,0 @@
|
|
1
|
-
c9897fd212cfefb379527e059f6f29a94f29c4681b3659e26f8f08b22e20d1ea
|
@@ -1 +0,0 @@
|
|
1
|
-
f12faacdbbcf214aba48971b1054310eca06c2a69d403404376b087d86beb76345e383bc6d452f6af8ec25b050895700bd930f8a33c9439153a972a179b3c763
|
@@ -1 +0,0 @@
|
|
1
|
-
3198b870e3e7ed3180a7531904c72b4c
|
@@ -1 +0,0 @@
|
|
1
|
-
acd1cb11d1c3eb38773e06ccfc27bf92aa7a034c
|
@@ -1 +0,0 @@
|
|
1
|
-
baf4edbae2dfa7d970360e30273b05e3e555f022f507cc808329226e0f860882
|
@@ -1 +0,0 @@
|
|
1
|
-
ef1d06b5ec6a0a06beb78fb6bba3c96d74b7c0da379a52f0023a07436a027b7fedfd14c8ede193c348ea668ba271e8364c3996c2d12f6d86cb8a399b4c75a57e
|
@@ -1,32 +0,0 @@
|
|
1
|
-
const firstTestContent = require('./firstTestContent');
|
2
|
-
|
3
|
-
const mochaRcContent = JSON.stringify({
|
4
|
-
recursive: true,
|
5
|
-
timeout: 120000,
|
6
|
-
bail: true,
|
7
|
-
file: 'e2e/init.js',
|
8
|
-
}, null, 4);
|
9
|
-
|
10
|
-
const initjsContent = `const detox = require('detox');
|
11
|
-
const adapter = require('detox/runners/mocha/adapter');
|
12
|
-
|
13
|
-
before(async () => {
|
14
|
-
await detox.init();
|
15
|
-
});
|
16
|
-
|
17
|
-
beforeEach(async function () {
|
18
|
-
await adapter.beforeEach(this);
|
19
|
-
});
|
20
|
-
|
21
|
-
afterEach(async function () {
|
22
|
-
await adapter.afterEach(this);
|
23
|
-
});
|
24
|
-
|
25
|
-
after(async () => {
|
26
|
-
await detox.cleanup();
|
27
|
-
});
|
28
|
-
`;
|
29
|
-
|
30
|
-
exports.initjs = initjsContent;
|
31
|
-
exports.firstTest = firstTestContent;
|
32
|
-
exports.runnerConfig = mochaRcContent;
|
@@ -1,107 +0,0 @@
|
|
1
|
-
const _ = require('lodash');
|
2
|
-
|
3
|
-
const { resolveJestCliArgs } = require('./jestInternals');
|
4
|
-
const testCommandArgs = require('./testCommandArgs');
|
5
|
-
|
6
|
-
function extractKnownKeys(yargsBuilder) {
|
7
|
-
return Object.entries(yargsBuilder).reduce(
|
8
|
-
(set, [key, option]) => {
|
9
|
-
if (option.alias) {
|
10
|
-
if (Array.isArray(option.alias)) {
|
11
|
-
for (const value of option.alias) {
|
12
|
-
set.add(value);
|
13
|
-
}
|
14
|
-
} else {
|
15
|
-
set.add(option.alias);
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
return set.add(key);
|
20
|
-
},
|
21
|
-
new Set()
|
22
|
-
);
|
23
|
-
}
|
24
|
-
|
25
|
-
function disengageBooleanArgs(argv, booleanKeys) {
|
26
|
-
const result = {};
|
27
|
-
const passthrough = [];
|
28
|
-
|
29
|
-
for (const entry of Object.entries(argv)) {
|
30
|
-
const [key, value] = entry;
|
31
|
-
if (key === '_' || key === '--') {
|
32
|
-
continue;
|
33
|
-
}
|
34
|
-
|
35
|
-
const positiveKey = key.startsWith('no-') ? key.slice(3) : key;
|
36
|
-
if (booleanKeys.has(positiveKey) && typeof value !== 'boolean') {
|
37
|
-
result[positiveKey] = key === positiveKey;
|
38
|
-
passthrough.push(value);
|
39
|
-
} else {
|
40
|
-
result[key] = value;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
return {
|
45
|
-
specs: passthrough.concat(argv._),
|
46
|
-
passthrough: {
|
47
|
-
_: argv['--'] || [],
|
48
|
-
...result,
|
49
|
-
},
|
50
|
-
};
|
51
|
-
}
|
52
|
-
|
53
|
-
function getJestBooleanArgs() {
|
54
|
-
return _(resolveJestCliArgs())
|
55
|
-
.thru(args => args.options)
|
56
|
-
.pickBy(({ type }) => type === 'boolean')
|
57
|
-
.thru(extractKnownKeys)
|
58
|
-
.value();
|
59
|
-
}
|
60
|
-
|
61
|
-
function getMochaBooleanArgs() {
|
62
|
-
const metadata = require('mocha/lib/cli/run-option-metadata');
|
63
|
-
|
64
|
-
return _(metadata.types.boolean)
|
65
|
-
.flatMap(key => [key, ...(metadata.aliases[key] || [])])
|
66
|
-
.thru(keys => new Set(keys))
|
67
|
-
.value();
|
68
|
-
}
|
69
|
-
|
70
|
-
function splitDetoxArgv(argv) {
|
71
|
-
const aliases = extractKnownKeys(testCommandArgs);
|
72
|
-
const isDetoxArg = (_value, key) => aliases.has(key);
|
73
|
-
|
74
|
-
const detoxArgs = _.pickBy(argv, isDetoxArg);
|
75
|
-
const runnerArgs = _.omitBy(argv, isDetoxArg);
|
76
|
-
runnerArgs._ = runnerArgs._.slice(1); // omit 'test' string, as in 'detox test'
|
77
|
-
if (typeof detoxArgs['debug-synchronization'] === 'string') {
|
78
|
-
const erroneousPassthrough = detoxArgs['debug-synchronization'];
|
79
|
-
detoxArgs['debug-synchronization'] = 3000;
|
80
|
-
runnerArgs._.unshift(erroneousPassthrough);
|
81
|
-
}
|
82
|
-
|
83
|
-
return { detoxArgs, runnerArgs };
|
84
|
-
}
|
85
|
-
|
86
|
-
function splitMochaArgv(argv) {
|
87
|
-
return disengageBooleanArgs(argv, getMochaBooleanArgs());
|
88
|
-
}
|
89
|
-
|
90
|
-
function splitJestArgv(argv) {
|
91
|
-
return realiasJestArgv(disengageBooleanArgs(argv, getJestBooleanArgs()));
|
92
|
-
}
|
93
|
-
|
94
|
-
function realiasJestArgv({ specs, passthrough }) {
|
95
|
-
if (passthrough.hasOwnProperty('t')) {
|
96
|
-
passthrough.testNamePattern = passthrough.t;
|
97
|
-
delete passthrough.t;
|
98
|
-
}
|
99
|
-
|
100
|
-
return { specs, passthrough };
|
101
|
-
}
|
102
|
-
|
103
|
-
module.exports = {
|
104
|
-
detox: splitDetoxArgv,
|
105
|
-
jest: splitJestArgv,
|
106
|
-
mocha: splitMochaArgv,
|
107
|
-
};
|
package/runners/integration.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
lifecycle: {
|
3
|
-
onRunStart: Symbol('run_start'),
|
4
|
-
onRunDescribeStart: Symbol('run_describe_start'),
|
5
|
-
onTestStart: Symbol('test_start'),
|
6
|
-
onHookStart: Symbol('hook_start'),
|
7
|
-
onHookFailure: Symbol('hook_failure'),
|
8
|
-
onHookSuccess: Symbol('hook_success'),
|
9
|
-
onTestFnStart: Symbol('test_fn_start'),
|
10
|
-
onTestFnFailure: Symbol('test_fn_failure'),
|
11
|
-
onTestFnSuccess: Symbol('test_fn_success'),
|
12
|
-
onTestDone: Symbol('test_done'),
|
13
|
-
onRunDescribeFinish: Symbol('run_describe_finish'),
|
14
|
-
onRunFinish: Symbol('run_finish'),
|
15
|
-
},
|
16
|
-
};
|
@@ -1,60 +0,0 @@
|
|
1
|
-
const DetoxAdapter = require('./DetoxAdapterImpl');
|
2
|
-
const { getFullTestName, hasTimedOut } = require('./utils');
|
3
|
-
|
4
|
-
class DetoxAdapterCircus {
|
5
|
-
constructor(detox) {
|
6
|
-
this._adapter = new DetoxAdapter(detox, DetoxAdapterCircus._describeInitError);
|
7
|
-
}
|
8
|
-
|
9
|
-
static _describeInitError() {
|
10
|
-
return {
|
11
|
-
message: 'Detox adapter to Jest is malfunctioning.',
|
12
|
-
hint: `Make sure you register it as a test-event listener inside init.js:\n` +
|
13
|
-
`-------------------------------------------------------------\n` +
|
14
|
-
'detoxCircus.getEnv().addEventsListener(adapter);',
|
15
|
-
};
|
16
|
-
}
|
17
|
-
|
18
|
-
async beforeEach() {
|
19
|
-
await this._adapter.beforeEach();
|
20
|
-
}
|
21
|
-
|
22
|
-
async afterAll() {
|
23
|
-
await this._adapter.afterAll();
|
24
|
-
}
|
25
|
-
|
26
|
-
async run_describe_start({ describeBlock: { name, children } }, state) { // eslint-disable-line no-unused-vars
|
27
|
-
if (children.length) await this._adapter.suiteStart({ name });
|
28
|
-
}
|
29
|
-
|
30
|
-
async run_describe_finish({ describeBlock: { name, children } }, state) { // eslint-disable-line no-unused-vars
|
31
|
-
if (children.length) await this._adapter.suiteEnd({ name });
|
32
|
-
}
|
33
|
-
|
34
|
-
test_start(event) {
|
35
|
-
const { test } = event;
|
36
|
-
if (test.mode === 'skip' || test.mode === 'todo' || test.errors.length > 0) {
|
37
|
-
return;
|
38
|
-
}
|
39
|
-
|
40
|
-
this._adapter.testStart({
|
41
|
-
title: test.name,
|
42
|
-
fullName: getFullTestName(test),
|
43
|
-
status: 'running',
|
44
|
-
});
|
45
|
-
}
|
46
|
-
|
47
|
-
test_done(event) {
|
48
|
-
const { test } = event;
|
49
|
-
this._adapter.testComplete({
|
50
|
-
status: test.errors.length ? 'failed' : 'passed',
|
51
|
-
timedOut: hasTimedOut(test)
|
52
|
-
});
|
53
|
-
}
|
54
|
-
|
55
|
-
test_skip(event) { // eslint-disable-line no-unused-vars
|
56
|
-
// Ignored (for clarity)
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
module.exports = DetoxAdapterCircus;
|
@@ -1,81 +0,0 @@
|
|
1
|
-
const DetoxRuntimeError = require('../../src/errors/DetoxRuntimeError');
|
2
|
-
const log = require('../../src/utils/logger').child({ __filename });
|
3
|
-
|
4
|
-
class DetoxAdapterImpl {
|
5
|
-
constructor(detox, describeInitErrorFn) {
|
6
|
-
if (process.env.DETOX_RERUN_INDEX) {
|
7
|
-
log.warn(
|
8
|
-
'While Detox CLI supports "-R <N>, --retries <N>" mechanism, ' +
|
9
|
-
'this outdated Jest integration does not — expect artifacts issues. ' +
|
10
|
-
'Please migrate to the new Jest Circus integration.\n\n' +
|
11
|
-
'See: https://wix.github.io/Detox/docs/api/guide/jest\n');
|
12
|
-
}
|
13
|
-
|
14
|
-
this.detox = detox;
|
15
|
-
this._describeInitError = describeInitErrorFn;
|
16
|
-
this._currentTest = null;
|
17
|
-
this._todos = [];
|
18
|
-
}
|
19
|
-
|
20
|
-
async beforeEach() {
|
21
|
-
if (!this._currentTest) {
|
22
|
-
throw new DetoxRuntimeError(this._describeInitError());
|
23
|
-
}
|
24
|
-
|
25
|
-
const currentTest = this._currentTest;
|
26
|
-
|
27
|
-
await this._flush();
|
28
|
-
await this.detox.beforeEach(currentTest);
|
29
|
-
}
|
30
|
-
|
31
|
-
async afterAll() {
|
32
|
-
await this._flush();
|
33
|
-
}
|
34
|
-
|
35
|
-
async suiteStart({ name }) {
|
36
|
-
this._enqueue(() => this.detox.suiteStart({ name }));
|
37
|
-
}
|
38
|
-
|
39
|
-
async suiteEnd({ name }) {
|
40
|
-
this._enqueue(() => this.detox.suiteEnd({ name }));
|
41
|
-
}
|
42
|
-
|
43
|
-
testStart({ title, fullName, status }) {
|
44
|
-
this._currentTest = {
|
45
|
-
title,
|
46
|
-
fullName,
|
47
|
-
status,
|
48
|
-
};
|
49
|
-
}
|
50
|
-
|
51
|
-
testComplete({ status, timedOut }) {
|
52
|
-
if (this._currentTest) {
|
53
|
-
const _test = {
|
54
|
-
...this._currentTest,
|
55
|
-
status,
|
56
|
-
timedOut,
|
57
|
-
};
|
58
|
-
|
59
|
-
this._currentTest = null;
|
60
|
-
this._enqueue(() => this._afterEach(_test));
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
async _afterEach(previousTest) {
|
65
|
-
await this.detox.afterEach(previousTest);
|
66
|
-
}
|
67
|
-
|
68
|
-
_enqueue(fn) {
|
69
|
-
this._todos.push(fn);
|
70
|
-
}
|
71
|
-
|
72
|
-
async _flush() {
|
73
|
-
const t = this._todos;
|
74
|
-
|
75
|
-
while (t.length > 0) {
|
76
|
-
await Promise.resolve().then(t.shift()).catch(()=>{});
|
77
|
-
}
|
78
|
-
}
|
79
|
-
}
|
80
|
-
|
81
|
-
module.exports = DetoxAdapterImpl;
|