detox 19.13.0 → 20.0.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.13.0/detox-19.13.0-javadoc.jar → 20.0.0/detox-20.0.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.13.0/detox-19.13.0-sources.jar → 20.0.0/detox-20.0.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.13.0/detox-19.13.0.pom → 20.0.0/detox-20.0.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.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/README.md +1 -1
- 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 +354 -191
- package/index.js +1 -0
- package/internals.d.ts +298 -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 +8 -7
- package/local-cli/init.js +73 -68
- package/local-cli/rebuild-framework-cache.js +1 -1
- package/local-cli/reset-lock-file.js +16 -0
- package/local-cli/templates/jest.js +14 -36
- package/local-cli/test.js +24 -282
- package/local-cli/test.test.js +394 -648
- package/local-cli/testCommand/TestRunnerCommand.js +163 -0
- package/local-cli/{utils/testCommandArgs.js → testCommand/builder.js} +10 -36
- package/local-cli/testCommand/middlewares.js +66 -0
- package/local-cli/{utils → testCommand}/warnings.js +0 -13
- package/local-cli/utils/jestInternals.js +13 -2
- package/local-cli/utils/yargsUtils.js +67 -0
- package/package.json +32 -19
- package/runners/deprecation.js +45 -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/globalSetup.js +1 -0
- package/runners/jest/globalTeardown.js +1 -0
- package/runners/jest/index.d.ts +60 -0
- package/runners/jest/index.js +16 -0
- package/runners/jest/index.test.js +13 -0
- package/runners/jest/reporter.js +1 -0
- package/runners/jest/reporters/DetoxReporter.js +36 -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 +205 -0
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +166 -0
- 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 -9
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +30 -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 +70 -0
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +22 -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/DetoxWorker.js +327 -0
- package/src/android/interactions/native.js +2 -1
- package/src/artifacts/ArtifactsManager.js +51 -35
- package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
- package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
- package/src/artifacts/providers/index.js +0 -4
- package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
- package/src/artifacts/templates/artifact/Artifact.js +1 -1
- package/src/artifacts/templates/plugin/ArtifactPlugin.js +1 -1
- package/src/artifacts/utils/buildDefaultArtifactsRootDirpath.js +2 -4
- package/src/artifacts/utils/temporaryPath.js +18 -5
- package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
- package/src/client/AsyncWebSocket.js +8 -17
- package/src/client/Client.js +1 -1
- package/src/client/actions/actions.js +2 -2
- package/src/configuration/collectCliConfig.js +3 -16
- package/src/configuration/composeAppsConfig.js +12 -66
- package/src/configuration/composeArtifactsConfig.js +6 -32
- package/src/configuration/composeBehaviorConfig.js +3 -13
- package/src/configuration/composeDeviceConfig.js +38 -63
- package/src/configuration/composeLoggerConfig.js +59 -0
- package/src/configuration/composeRunnerConfig.js +127 -14
- package/src/configuration/composeSessionConfig.js +1 -3
- package/src/configuration/index.js +36 -30
- package/src/configuration/loadExternalConfig.js +1 -1
- package/src/configuration/utils/deviceAppTypes.js +0 -1
- package/src/devices/allocation/DeviceAllocator.js +4 -2
- package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +5 -3
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -5
- package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +1 -1
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
- 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/android/genycloud/services/GenyRecipesService.js +1 -1
- package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
- package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +35 -10
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
- package/src/devices/runtime/RuntimeDevice.js +85 -86
- package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
- package/src/devices/runtime/drivers/android/AndroidDriver.js +3 -3
- package/src/devices/runtime/drivers/index.js +0 -1
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +4 -3
- 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 +92 -30
- package/src/errors/DetoxError.js +4 -0
- package/src/errors/DetoxRuntimeError.js +5 -5
- package/src/errors/index.js +2 -0
- package/src/ios/expectTwo.js +2 -1
- package/src/ipc/IPCClient.js +117 -0
- package/src/ipc/IPCServer.js +98 -0
- package/src/ipc/SessionState.js +62 -0
- package/src/logger/DetoxLogger.js +348 -0
- package/src/logger/index.js +5 -0
- package/src/logger/utils/BunyanLogger.js +76 -0
- package/src/logger/utils/CategoryThreadDispatcher.js +36 -0
- package/src/logger/utils/DetoxLogFinalizer.js +140 -0
- package/src/logger/utils/MessageStack.js +24 -0
- package/src/logger/utils/ThreadDispatcher.js +61 -0
- package/src/{utils → logger/utils}/customConsoleLogger.js +5 -4
- package/src/logger/utils/sanitizeBunyanContext.js +30 -0
- package/src/logger/utils/streamUtils.js +248 -0
- package/src/logger/utils/tracerLegacy.js +37 -0
- package/src/realms/DetoxConstants.js +13 -0
- package/src/realms/DetoxContext.js +183 -0
- package/src/realms/DetoxInternalsFacade.js +31 -0
- package/src/realms/DetoxPrimaryContext.js +261 -0
- package/src/realms/DetoxSecondaryContext.js +91 -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 +18 -23
- package/src/server/DetoxServer.js +7 -10
- package/src/server/DetoxSession.js +6 -6
- package/src/server/DetoxSessionManager.js +1 -1
- package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
- package/src/symbols.js +50 -0
- package/src/utils/Timer.js +58 -33
- package/src/utils/argparse.js +11 -0
- package/src/utils/childProcess/exec.js +1 -1
- package/src/utils/childProcess/spawn.js +1 -1
- package/{local-cli/utils/misc.js → src/utils/envUtils.js} +0 -9
- package/src/utils/errorUtils.js +20 -0
- package/src/utils/logger.js +2 -162
- package/src/utils/shellUtils.js +18 -0
- package/src/utils/traceInvocationCall.js +21 -0
- package/src/utils/traceMethods.js +15 -0
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar +0 -0
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.13.0/detox-19.13.0.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/listeners/DetoxCoreListener.js +0 -113
- package/runners/jest-circus/utils/assertJestCircus26.js +0 -39
- package/runners/jest-circus/utils/wrapErrorWithNoopLifecycle.js +0 -14
- package/src/Detox.js +0 -317
- package/src/DetoxConstants.js +0 -13
- package/src/DetoxExportWrapper.js +0 -140
- package/src/artifacts/timeline/TimelineArtifactPlugin.js +0 -92
- package/src/configuration/utils/warnings.js +0 -12
- 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/ChromeTracingExporter.js +0 -54
- 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
- package/src/utils/trace.js +0 -96
@@ -1,92 +0,0 @@
|
|
1
|
-
const fs = require('fs-extra');
|
2
|
-
const _noop = require('lodash/noop');
|
3
|
-
|
4
|
-
const ChromeTracingExporter = require('../../utils/ChromeTracingExporter');
|
5
|
-
const fakeTimestampsProvider = require('../../utils/fakeTimestampsProvider');
|
6
|
-
const { trace } = require('../../utils/trace');
|
7
|
-
const FileArtifact = require('../templates/artifact/FileArtifact');
|
8
|
-
const ArtifactPlugin = require('../templates/plugin/ArtifactPlugin');
|
9
|
-
|
10
|
-
const TIMELINE_CONTEXT_TYPES = require('./TimelineContextTypes');
|
11
|
-
|
12
|
-
const traceNoop = {
|
13
|
-
startSection: _noop,
|
14
|
-
endSection: _noop,
|
15
|
-
};
|
16
|
-
|
17
|
-
class TimelineArtifactPlugin extends ArtifactPlugin {
|
18
|
-
constructor(config) {
|
19
|
-
super(config);
|
20
|
-
this._useFakeTimestamps = config.useFakeTimestamps;
|
21
|
-
|
22
|
-
const threadId = process.env.JEST_WORKER_ID || process.pid;
|
23
|
-
this._trace = this.enabled ? trace : traceNoop;
|
24
|
-
this._traceExporter = new ChromeTracingExporter({
|
25
|
-
process: { id: 0, name: 'detox' },
|
26
|
-
thread: { id: threadId, name: `Worker #${threadId}` },
|
27
|
-
});
|
28
|
-
}
|
29
|
-
|
30
|
-
async onBootDevice(event) {
|
31
|
-
this._deviceName = event.deviceId;
|
32
|
-
return super.onBootDevice(event);
|
33
|
-
}
|
34
|
-
|
35
|
-
async onRunDescribeStart(suite) {
|
36
|
-
const sectionName = (suite.name === 'ROOT_DESCRIBE_BLOCK' ? this._deviceName : suite.name);
|
37
|
-
this._trace.startSection(sectionName, { context: TIMELINE_CONTEXT_TYPES.DESCRIBE });
|
38
|
-
await super.onRunDescribeStart(suite);
|
39
|
-
}
|
40
|
-
|
41
|
-
async onRunDescribeFinish(suite) {
|
42
|
-
const sectionName = (suite.name === 'ROOT_DESCRIBE_BLOCK' ? this._deviceName : suite.name);
|
43
|
-
this._trace.endSection(sectionName, { context: TIMELINE_CONTEXT_TYPES.DESCRIBE });
|
44
|
-
await super.onRunDescribeFinish(suite);
|
45
|
-
}
|
46
|
-
|
47
|
-
async onTestStart(testSummary) {
|
48
|
-
this._trace.startSection(testSummary.title, { context: TIMELINE_CONTEXT_TYPES.TEST, ...testSummary });
|
49
|
-
await super.onTestStart(testSummary);
|
50
|
-
}
|
51
|
-
|
52
|
-
async onTestDone(testSummary) {
|
53
|
-
this._trace.endSection(testSummary.title, { context: TIMELINE_CONTEXT_TYPES.TEST, ...testSummary });
|
54
|
-
await super.onTestDone(testSummary);
|
55
|
-
}
|
56
|
-
|
57
|
-
async onBeforeCleanup() {
|
58
|
-
this._deviceName = null;
|
59
|
-
|
60
|
-
if (!this.enabled) {
|
61
|
-
return;
|
62
|
-
}
|
63
|
-
|
64
|
-
const traceLogPath = await this.api.preparePathForArtifact(`detox.trace.json`);
|
65
|
-
const append = await this._logFileExists(traceLogPath);
|
66
|
-
const events = this._useFakeTimestamps ? this._transformEventTimestamps(trace.events) : trace.events;
|
67
|
-
const data = this._traceExporter.export(events, append);
|
68
|
-
|
69
|
-
const fileArtifact = new FileArtifact({ temporaryData: data });
|
70
|
-
await fileArtifact.save(traceLogPath, { append });
|
71
|
-
}
|
72
|
-
|
73
|
-
async _logFileExists(traceLogPath) {
|
74
|
-
return fs.access(traceLogPath).then(() => true).catch(() => false);
|
75
|
-
}
|
76
|
-
|
77
|
-
_transformEventTimestamps(events) {
|
78
|
-
return events.map((event) => ({
|
79
|
-
...event,
|
80
|
-
ts: fakeTimestampsProvider(),
|
81
|
-
}));
|
82
|
-
}
|
83
|
-
|
84
|
-
/** @param {string} config */
|
85
|
-
static parseConfig(config) {
|
86
|
-
return {
|
87
|
-
enabled: config === 'all',
|
88
|
-
};
|
89
|
-
}
|
90
|
-
}
|
91
|
-
|
92
|
-
module.exports = TimelineArtifactPlugin;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
const DEVICE_LAUNCH_ARGS_DEPRECATION = `\
|
2
|
-
--device-launch-args is a deprecated name of this option.
|
3
|
-
Please change your scripts to use --device-boot-args instead.`;
|
4
|
-
|
5
|
-
const DEVICE_LAUNCH_ARGS_GENERIC_DEPRECATION = `\
|
6
|
-
--device-launch-args / $DETOX_DEVICE_LAUNCH_ARGS is a deprecated name of this option.
|
7
|
-
Please change your scripts to use --device-boot-args / $DETOX_DEVICE_BOOT_ARGS instead.`;
|
8
|
-
|
9
|
-
module.exports = {
|
10
|
-
DEVICE_LAUNCH_ARGS_DEPRECATION,
|
11
|
-
DEVICE_LAUNCH_ARGS_GENERIC_DEPRECATION,
|
12
|
-
};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
const AllocationDriverBase = require('./AllocationDriverBase');
|
2
|
-
|
3
|
-
class NoneAllocDriver extends AllocationDriverBase {
|
4
|
-
async allocate(deviceQuery) { // eslint-disable-line no-unused-vars
|
5
|
-
return null;
|
6
|
-
}
|
7
|
-
async free(cookie, options) {} // eslint-disable-line no-unused-vars
|
8
|
-
}
|
9
|
-
|
10
|
-
module.exports = NoneAllocDriver;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
// @ts-nocheck
|
2
|
-
const DeviceAllocatorFactory = require('./base');
|
3
|
-
|
4
|
-
class None extends DeviceAllocatorFactory {
|
5
|
-
_createDriver() {
|
6
|
-
const NoneAllocDriver = require('../drivers/NoneAllocDriver');
|
7
|
-
return new NoneAllocDriver();
|
8
|
-
}
|
9
|
-
}
|
10
|
-
|
11
|
-
module.exports = { None };
|
package/src/index.js
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
const _ = require('lodash');
|
2
|
-
|
3
|
-
const DetoxRuntimeError = require('../errors/DetoxRuntimeError');
|
4
|
-
|
5
|
-
class ChromeTracingExporter {
|
6
|
-
constructor({
|
7
|
-
process,
|
8
|
-
thread,
|
9
|
-
}) {
|
10
|
-
this._process = {
|
11
|
-
id: process.id,
|
12
|
-
name: process.name,
|
13
|
-
};
|
14
|
-
this._thread = {
|
15
|
-
id: thread.id,
|
16
|
-
name: thread.name,
|
17
|
-
};
|
18
|
-
}
|
19
|
-
|
20
|
-
export(traceEvents, append) {
|
21
|
-
const _events = _.flatMap(traceEvents, this._parseEvent.bind(this));
|
22
|
-
const json = JSON.stringify(_events);
|
23
|
-
const prefix = (append ? ',' : '[');
|
24
|
-
return `${prefix}${json.slice(1, -1)}`;
|
25
|
-
}
|
26
|
-
|
27
|
-
_parseEvent(event) {
|
28
|
-
const { name, ts, args, type } = event;
|
29
|
-
const tsInMicroseconds = ts * 1000;
|
30
|
-
switch (type) {
|
31
|
-
case 'start': return this._event(name, 'B', tsInMicroseconds, args);
|
32
|
-
case 'end': return this._event(name, 'E', tsInMicroseconds, args);
|
33
|
-
case 'init': return [
|
34
|
-
this._event('process_name', 'M', tsInMicroseconds, { name: this._process.name }),
|
35
|
-
this._event('thread_name', 'M', tsInMicroseconds, { name: this._thread.name }),
|
36
|
-
];
|
37
|
-
default:
|
38
|
-
throw new DetoxRuntimeError({ message: `Invalid type '${type}' in event: ${event}` });
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
_event(name, phase, ts, args) {
|
43
|
-
return {
|
44
|
-
name,
|
45
|
-
pid: this._process.id,
|
46
|
-
tid: this._thread.id,
|
47
|
-
ts,
|
48
|
-
ph: phase,
|
49
|
-
args: { ...args },
|
50
|
-
};
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
module.exports = ChromeTracingExporter;
|
@@ -1,78 +0,0 @@
|
|
1
|
-
const DetoxRuntimeError = require('../errors/DetoxRuntimeError');
|
2
|
-
|
3
|
-
class MissingDetox {
|
4
|
-
constructor() {
|
5
|
-
this.throwError = this.throwError.bind(this);
|
6
|
-
this.initContext(this);
|
7
|
-
|
8
|
-
this._defineRequiredProperty(this, 'beforeEach', async () => this.throwError(), true);
|
9
|
-
this._defineRequiredProperty(this, 'afterEach', async () => this.throwError(), true);
|
10
|
-
}
|
11
|
-
|
12
|
-
initContext(context) {
|
13
|
-
const readonly = context === this;
|
14
|
-
|
15
|
-
this._defineRequiredProperty(context, 'by', undefined, readonly);
|
16
|
-
this._defineRequiredProperty(context, 'device', undefined, readonly);
|
17
|
-
this._defineRequiredProperty(context, 'element', this.throwError, readonly);
|
18
|
-
this._defineRequiredProperty(context, 'expect', this.throwError, readonly);
|
19
|
-
this._defineRequiredProperty(context, 'waitFor', this.throwError, readonly);
|
20
|
-
this._defineRequiredProperty(context, 'web', undefined, readonly);
|
21
|
-
}
|
22
|
-
|
23
|
-
cleanupContext(context) {
|
24
|
-
this._cleanupProperty(context, 'by');
|
25
|
-
this._cleanupProperty(context, 'device');
|
26
|
-
this._cleanupProperty(context, 'element');
|
27
|
-
this._cleanupProperty(context, 'expect');
|
28
|
-
this._cleanupProperty(context, 'waitFor');
|
29
|
-
}
|
30
|
-
|
31
|
-
_cleanupProperty(context, name) {
|
32
|
-
if (context.hasOwnProperty(name)) {
|
33
|
-
context[name] = undefined;
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
_defineRequiredProperty(context, name, initialValue, readonly) {
|
38
|
-
if (context.hasOwnProperty(name)) {
|
39
|
-
return;
|
40
|
-
}
|
41
|
-
|
42
|
-
let _value = initialValue;
|
43
|
-
|
44
|
-
const descriptor = {
|
45
|
-
get: () => {
|
46
|
-
if (_value === undefined) {
|
47
|
-
this.throwError();
|
48
|
-
}
|
49
|
-
|
50
|
-
return _value;
|
51
|
-
},
|
52
|
-
};
|
53
|
-
|
54
|
-
if (!readonly) {
|
55
|
-
descriptor.set = (value) => {
|
56
|
-
_value = value;
|
57
|
-
};
|
58
|
-
}
|
59
|
-
|
60
|
-
Object.defineProperty(context, name, descriptor);
|
61
|
-
}
|
62
|
-
|
63
|
-
setError(err) {
|
64
|
-
this._lastError = err;
|
65
|
-
}
|
66
|
-
|
67
|
-
throwError() {
|
68
|
-
throw new DetoxRuntimeError({
|
69
|
-
message: 'Detox instance has not been initialized',
|
70
|
-
hint: this._lastError
|
71
|
-
? 'There was an error on attempt to call detox.init()'
|
72
|
-
: 'Make sure to call detox.init() before your test begins',
|
73
|
-
debugInfo: this._lastError && this._lastError.stack || '',
|
74
|
-
});
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
module.exports = MissingDetox;
|
package/src/utils/getWorkerId.js
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
const fs = require('fs-extra');
|
2
|
-
|
3
|
-
const environment = require('./environment');
|
4
|
-
|
5
|
-
async function resetLastFailedTests() {
|
6
|
-
const lastFailedTxt = environment.getLastFailedTestsPath();
|
7
|
-
await fs.remove(lastFailedTxt);
|
8
|
-
}
|
9
|
-
|
10
|
-
async function loadLastFailedTests() {
|
11
|
-
const lastFailedTxt = environment.getLastFailedTestsPath();
|
12
|
-
const lastFailedTests = await fs.exists(lastFailedTxt)
|
13
|
-
? (await fs.readFile(lastFailedTxt, 'utf8')).trim()
|
14
|
-
: '';
|
15
|
-
|
16
|
-
if (lastFailedTests) {
|
17
|
-
return lastFailedTests.split('\n');
|
18
|
-
} else {
|
19
|
-
return [];
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
/**
|
24
|
-
* @async
|
25
|
-
* @param {string[]} failedFiles - paths to the test suites
|
26
|
-
*/
|
27
|
-
async function saveLastFailedTests(failedFiles) {
|
28
|
-
const failedTestsPath = environment.getLastFailedTestsPath();
|
29
|
-
|
30
|
-
await fs.ensureFile(failedTestsPath);
|
31
|
-
await fs.writeFile(failedTestsPath, failedFiles.join('\n'));
|
32
|
-
}
|
33
|
-
|
34
|
-
module.exports = {
|
35
|
-
resetLastFailedTests,
|
36
|
-
loadLastFailedTests,
|
37
|
-
saveLastFailedTests,
|
38
|
-
};
|
package/src/utils/sh.js
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
// @ts-nocheck
|
2
|
-
const cpp = require('child-process-promise');
|
3
|
-
|
4
|
-
const sh = new Proxy({}, {
|
5
|
-
get: function(target, prop) {
|
6
|
-
if (target[prop] === undefined) {
|
7
|
-
return target[prop] = (...params) => {
|
8
|
-
return cpp.exec(`${prop} ${params.join(' ')}`);
|
9
|
-
};
|
10
|
-
} else {
|
11
|
-
return target[prop];
|
12
|
-
}
|
13
|
-
}
|
14
|
-
});
|
15
|
-
|
16
|
-
process.env['PATH'] = `${process.env.PATH}:${sh.npm(`bin`)}`;
|
17
|
-
|
18
|
-
module.exports = sh;
|
package/src/utils/trace.js
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
const assert = require('assert');
|
2
|
-
|
3
|
-
const TIMELINE_CONTEXT_TYPES = require('../artifacts/timeline/TimelineContextTypes');
|
4
|
-
|
5
|
-
class Trace {
|
6
|
-
constructor() {
|
7
|
-
this.events = [];
|
8
|
-
}
|
9
|
-
|
10
|
-
init(timestampProviderFn = Date.now) {
|
11
|
-
this._timestampProviderFn = timestampProviderFn;
|
12
|
-
this.events = [
|
13
|
-
this._event('init'),
|
14
|
-
];
|
15
|
-
}
|
16
|
-
|
17
|
-
startSection(name, args) {
|
18
|
-
this.events.push(this._event('start', name, args));
|
19
|
-
}
|
20
|
-
|
21
|
-
endSection(name, args) {
|
22
|
-
this.events.push(this._event('end', name, args));
|
23
|
-
}
|
24
|
-
|
25
|
-
reset() {
|
26
|
-
this.events = [
|
27
|
-
this._event('init'),
|
28
|
-
];
|
29
|
-
}
|
30
|
-
|
31
|
-
_event(type, name, args) {
|
32
|
-
return {
|
33
|
-
type,
|
34
|
-
ts: this._timestampProviderFn(),
|
35
|
-
name,
|
36
|
-
args,
|
37
|
-
};
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
|
-
let trace = new Trace();
|
42
|
-
|
43
|
-
/**
|
44
|
-
* Trace a single call, with a given name and arguments.
|
45
|
-
* @param sectionName The name of the section to trace.
|
46
|
-
* @param promiseOrFunction {Promise|Function} Promise or a function that provides a promise.
|
47
|
-
* @param args {Object} Optional arguments to pass to the trace.
|
48
|
-
* @returns {any} The returned value of the traced call.
|
49
|
-
*
|
50
|
-
* @see https://wix.github.io/Detox/docs/next/api/detox-object-api/#detoxtracecall.
|
51
|
-
*/
|
52
|
-
function traceCall(sectionName, promiseOrFunction, args = {}) {
|
53
|
-
assert(sectionName,
|
54
|
-
`must provide section name when calling \`traceCall\` with args: \n ${JSON.stringify(args)}`);
|
55
|
-
|
56
|
-
const promise = typeof promiseOrFunction === 'function' ? promiseOrFunction() : promiseOrFunction;
|
57
|
-
|
58
|
-
trace.startSection(sectionName, args);
|
59
|
-
return promise
|
60
|
-
.then((result) => {
|
61
|
-
trace.endSection(sectionName, { ...args, success: true });
|
62
|
-
return result;
|
63
|
-
})
|
64
|
-
.catch((error) => {
|
65
|
-
trace.endSection(sectionName, { ...args, success: false, error: error.toString() });
|
66
|
-
throw error;
|
67
|
-
});
|
68
|
-
}
|
69
|
-
|
70
|
-
function traceInvocationCall(sectionName, invocation, promise) {
|
71
|
-
return traceCall(
|
72
|
-
sectionName, promise, {
|
73
|
-
context: TIMELINE_CONTEXT_TYPES.INVOCATION,
|
74
|
-
stackTrace: _getCallStackTrace(),
|
75
|
-
invocation: JSON.stringify(invocation),
|
76
|
-
});
|
77
|
-
}
|
78
|
-
|
79
|
-
function _getCallStackTrace() {
|
80
|
-
return new Error().stack
|
81
|
-
.split('\n')
|
82
|
-
.slice(1) // Ignore Error message
|
83
|
-
.map(line => line
|
84
|
-
.replace(/^\s*at\s+/, '')
|
85
|
-
.replace(process.cwd(), '')
|
86
|
-
)
|
87
|
-
.filter(line => !line.includes('/detox/src')) // Ignore detox internal calls
|
88
|
-
.join('\n');
|
89
|
-
}
|
90
|
-
|
91
|
-
module.exports = {
|
92
|
-
Trace,
|
93
|
-
trace,
|
94
|
-
traceCall,
|
95
|
-
traceInvocationCall
|
96
|
-
};
|