detox 19.9.0 → 21.0.0-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.0/detox-19.9.0-javadoc.jar → 21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.9.0/detox-19.9.0-sources.jar → 21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar +0 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.9.0/detox-19.9.0.pom → 21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom} +2 -2
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-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/build.gradle +2 -2
- package/android/detox/build.gradle +2 -2
- package/android/detox/publish-pom.gradle +1 -5
- package/android/detox/publishing.gradle +7 -9
- 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/android/detox/src/full/java/com/wix/detox/adapters/server/WebSocketClient.java +1 -3
- package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAction.java +3 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/UiAutomatorHelper.java +1 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +23 -16
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeLoadingMonitor.kt +8 -54
- package/android/detox/src/main/java/com/wix/detox/common/DetoxErrors.java +1 -4
- package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +1 -2
- package/android/detox/src/main/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +36 -0
- package/android/detox/src/{full → main}/java/com/wix/detox/espresso/action/GetAttributesAction.kt +1 -13
- package/android/detox/src/main/java/com/wix/detox/espresso/action/common/utils/UiControllerUtils.kt +1 -1
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/AdjustSliderToPositionActionTest.kt +59 -0
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +3 -15
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -2
- package/android/gradlew +107 -181
- package/index.d.ts +208 -186
- package/index.js +1 -0
- package/internals.d.ts +124 -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 +332 -673
- package/local-cli/testCommand/TestRunnerCommand.js +157 -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 +28 -22
- 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 +35 -17
- 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/log/android/ADBLogcatRecording.js +28 -11
- 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 +9 -67
- 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 +74 -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/android/genycloud/GenyAllocDriver.js +0 -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/exec/ADB.js +0 -5
- 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 +76 -29
- 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 +117 -0
- package/src/ipc/IPCServer.js +87 -0
- package/src/ipc/state.js +76 -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/ChromeTracingExporter.js +5 -6
- 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.0/detox-19.9.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar +0 -0
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.9.0/detox-19.9.0.pom.sha512 +0 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +0 -22
- package/android/detox/src/full/java/com/wix/detox/espresso/common/SliderHelper.kt +0 -75
- package/android/detox/src/main/java/com/wix/detox/espresso/action/common/ReflectUtils.kt +0 -10
- package/android/detox/src/testFull/java/com/wix/detox/espresso/common/SliderHelperTest.kt +0 -39
- 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,56 @@
|
|
1
|
+
const fs = require('fs');
|
2
|
+
const path = require('path');
|
3
|
+
|
4
|
+
const semver = require('semver');
|
5
|
+
|
6
|
+
const detoxPackageJson = require('../../../../package.json');
|
7
|
+
const { DetoxRuntimeError } = require('../../../../src/errors');
|
8
|
+
|
9
|
+
function assertJestCircus27(maybeProjectConfig) {
|
10
|
+
const projectConfig = maybeProjectConfig.projectConfig || maybeProjectConfig;
|
11
|
+
|
12
|
+
if (!/jest-circus/.test(projectConfig.testRunner)) {
|
13
|
+
throw new DetoxRuntimeError({
|
14
|
+
message: 'Cannot continue without Jest Circus test runner underneath, exiting.',
|
15
|
+
hint: 'Make sure that in your Jest config you have no "testRunner" property or it is explicitly set to "jest-circus/runner".',
|
16
|
+
debugInfo: `The test runner powering your configuration is:\n${projectConfig.testRunner}`,
|
17
|
+
});
|
18
|
+
}
|
19
|
+
|
20
|
+
const circusPackageJson = path.join(path.dirname(projectConfig.testRunner), 'package.json');
|
21
|
+
if (!fs.existsSync(circusPackageJson)) {
|
22
|
+
throw new DetoxRuntimeError({
|
23
|
+
message: 'Check that you have an installed copy of "jest-circus" npm package, exiting.',
|
24
|
+
debugInfo: `Its package.json file is missing: ${circusPackageJson}`,
|
25
|
+
});
|
26
|
+
}
|
27
|
+
|
28
|
+
const circusVersion = require(circusPackageJson).version;
|
29
|
+
if (!circusVersion) {
|
30
|
+
throw new DetoxRuntimeError({
|
31
|
+
message: 'Check that you have an valid copy of "jest-circus" npm package, exiting.',
|
32
|
+
debugInfo: `Its package.json file has no "version" property. See:\n` + circusPackageJson,
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
assertSupportedVersion(circusVersion);
|
37
|
+
|
38
|
+
return maybeProjectConfig;
|
39
|
+
}
|
40
|
+
|
41
|
+
function assertSupportedVersion(actualVersion) {
|
42
|
+
const supportedRange = detoxPackageJson.peerDependencies.jest;
|
43
|
+
const minSupportedVersion = semver.minVersion(supportedRange);
|
44
|
+
|
45
|
+
if (semver.lt(actualVersion, minSupportedVersion)) {
|
46
|
+
throw new DetoxRuntimeError({
|
47
|
+
message: `Detected an unsupported jest@${actualVersion} version.`,
|
48
|
+
hint: `Please upgrade your Jest test runner to the supported range: ${supportedRange}.`
|
49
|
+
});
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
module.exports = {
|
54
|
+
assertJestCircus27,
|
55
|
+
assertSupportedVersion,
|
56
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
const { assertSupportedVersion } = require('./assertJestCircus27');
|
2
|
+
|
3
|
+
describe('assertSupportedVersion', () => {
|
4
|
+
test.each([
|
5
|
+
['27.2.5'],
|
6
|
+
['27.2.6-prerelease.0'],
|
7
|
+
['27.3.0'],
|
8
|
+
['28.0.0-alpha.1'],
|
9
|
+
['28.0.0'],
|
10
|
+
['28.1.0'],
|
11
|
+
['29.0.0-next.0'],
|
12
|
+
['30.0.0'],
|
13
|
+
])('should pass for %j', (version) => {
|
14
|
+
expect(() => assertSupportedVersion(version)).not.toThrow();
|
15
|
+
});
|
16
|
+
|
17
|
+
test.each([
|
18
|
+
['26.0.0'],
|
19
|
+
['27.2.4'],
|
20
|
+
])('should throw an error for %j', (version) => {
|
21
|
+
expect(() => assertSupportedVersion(version)).toThrowError(/unsupported jest.*version/);
|
22
|
+
});
|
23
|
+
});
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,10 +1 @@
|
|
1
|
-
|
2
|
-
const WorkerAssignReporterCircus = require('../jest/WorkerAssignReporterCircus');
|
3
|
-
|
4
|
-
const DetoxCircusEnvironment = require('./environment');
|
5
|
-
|
6
|
-
module.exports = {
|
7
|
-
DetoxCircusEnvironment,
|
8
|
-
SpecReporter: SpecReporterCircus,
|
9
|
-
WorkerAssignReporter: WorkerAssignReporterCircus,
|
10
|
-
};
|
1
|
+
module.exports = require('../migration')(__filename);
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = require('../migration')(__filename);
|
@@ -0,0 +1,37 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
|
3
|
+
const chalk = require('chalk');
|
4
|
+
const _ = require('lodash');
|
5
|
+
|
6
|
+
const SEARCH_VALUE = ['', 'detox', 'runners', 'jest-circus', ''].join(path.sep);
|
7
|
+
const REPLACE_VALUE = ['', 'detox', 'runners', 'jest', ''].join(path.sep);
|
8
|
+
|
9
|
+
function jsify(pathToFile) {
|
10
|
+
return 'detox/' + path
|
11
|
+
.relative(
|
12
|
+
path.join(__dirname, '..'),
|
13
|
+
pathToFile
|
14
|
+
)
|
15
|
+
.replace(/\\/g, '/')
|
16
|
+
.replace(/(?:\/index)?\.js$/, '');
|
17
|
+
}
|
18
|
+
|
19
|
+
const redirectWithWarning = _.memoize((
|
20
|
+
oldPath,
|
21
|
+
newPath = oldPath.replace(SEARCH_VALUE, REPLACE_VALUE)
|
22
|
+
) => {
|
23
|
+
redirectWithWarning._log([
|
24
|
+
'[DEPRECATION] Detox detected an attempt to require a module from an outdated location, please change in your project:',
|
25
|
+
`- ${jsify(oldPath)}`,
|
26
|
+
`+ ${jsify(newPath)}`,
|
27
|
+
'',
|
28
|
+
].join('\n'));
|
29
|
+
|
30
|
+
return require(newPath);
|
31
|
+
});
|
32
|
+
|
33
|
+
// @ts-ignore
|
34
|
+
// istanbul ignore next
|
35
|
+
redirectWithWarning._log = msg => process.stderr.write(chalk.yellow(msg) + '\n');
|
36
|
+
|
37
|
+
module.exports = redirectWithWarning;
|
@@ -1,35 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
}
|
5
|
-
|
6
|
-
async beforeEach(context) {
|
7
|
-
await this.detox.beforeEach({
|
8
|
-
title: context.currentTest.title,
|
9
|
-
fullName: context.currentTest.fullTitle(),
|
10
|
-
status: this._mapStatus(context, false),
|
11
|
-
});
|
12
|
-
}
|
13
|
-
|
14
|
-
async afterEach(context) {
|
15
|
-
await this.detox.afterEach({
|
16
|
-
title: context.currentTest.title,
|
17
|
-
fullName: context.currentTest.fullTitle(),
|
18
|
-
status: this._mapStatus(context, true),
|
19
|
-
timedOut: context.currentTest.timedOut,
|
20
|
-
});
|
21
|
-
}
|
22
|
-
|
23
|
-
_mapStatus(context, isAfterTest) {
|
24
|
-
switch (context.currentTest.state) {
|
25
|
-
case 'passed':
|
26
|
-
return 'passed';
|
27
|
-
case 'failed':
|
28
|
-
return 'failed';
|
29
|
-
default:
|
30
|
-
return isAfterTest ? 'failed' : 'running';
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
module.exports = DetoxMochaAdapter;
|
1
|
+
/** @deprecated */
|
2
|
+
/** @type {never} */
|
3
|
+
module.exports = require('../deprecation');
|
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
}
|
6
|
-
|
7
|
-
declare const adapter: DetoxMochaAdapter;
|
1
|
+
/**
|
2
|
+
* @deprecated Mocha integration is no longer supported since Detox v20.0.0
|
3
|
+
*/
|
4
|
+
declare const adapter: never;
|
8
5
|
|
9
6
|
export = adapter;
|
package/runners/mocha/adapter.js
CHANGED
@@ -1,60 +1,20 @@
|
|
1
|
-
// @ts-nocheck
|
2
|
-
const { URL } = require('url');
|
3
|
-
const util = require('util');
|
4
|
-
|
5
1
|
const _ = require('lodash');
|
6
2
|
|
7
|
-
const lifecycleSymbols = require('../runners/integration').lifecycle;
|
8
|
-
|
9
3
|
const Client = require('./client/Client');
|
10
4
|
const environmentFactory = require('./environmentFactory');
|
11
5
|
const { DetoxRuntimeErrorComposer } = require('./errors');
|
12
6
|
const { InvocationManager } = require('./invoke');
|
13
|
-
const
|
7
|
+
const symbols = require('./symbols');
|
14
8
|
const AsyncEmitter = require('./utils/AsyncEmitter');
|
15
|
-
const
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
class Detox {
|
24
|
-
constructor(config) {
|
25
|
-
log.trace(
|
26
|
-
{ event: 'DETOX_CREATE', config },
|
27
|
-
'created a Detox instance with config:\n%s',
|
28
|
-
util.inspect(_.omit(config, ['errorComposer']), {
|
29
|
-
getters: false,
|
30
|
-
depth: Infinity,
|
31
|
-
maxArrayLength: Infinity,
|
32
|
-
maxStringLength: Infinity,
|
33
|
-
breakLength: false,
|
34
|
-
compact: false,
|
35
|
-
})
|
36
|
-
);
|
37
|
-
|
38
|
-
this[_initHandle] = null;
|
39
|
-
|
40
|
-
for (const [key, symbol] of Object.entries(lifecycleSymbols)) {
|
41
|
-
this[symbol] = (...args) => this._artifactsManager[key](...args);
|
42
|
-
}
|
43
|
-
|
44
|
-
this[lifecycleSymbols.onTestStart] = this.beforeEach;
|
45
|
-
this[lifecycleSymbols.onTestDone] = this.afterEach;
|
46
|
-
|
47
|
-
const { appsConfig, artifactsConfig, behaviorConfig, deviceConfig, sessionConfig } = config;
|
48
|
-
|
49
|
-
this._appsConfig = appsConfig;
|
50
|
-
this._artifactsConfig = artifactsConfig;
|
51
|
-
this._behaviorConfig = behaviorConfig;
|
52
|
-
this._deviceConfig = deviceConfig;
|
53
|
-
this._sessionConfig = sessionConfig;
|
54
|
-
this._runtimeErrorComposer = new DetoxRuntimeErrorComposer({ appsConfig });
|
55
|
-
|
9
|
+
const uuid = require('./utils/uuid');
|
10
|
+
|
11
|
+
class DetoxWorker {
|
12
|
+
constructor(context) {
|
13
|
+
this._context = context;
|
14
|
+
this._isCleaningUp = false;
|
15
|
+
this._config = context[symbols.config];
|
16
|
+
this._runtimeErrorComposer = new DetoxRuntimeErrorComposer(this._config);
|
56
17
|
this._client = null;
|
57
|
-
this._server = null;
|
58
18
|
this._artifactsManager = null;
|
59
19
|
this._eventEmitter = new AsyncEmitter({
|
60
20
|
events: [
|
@@ -72,116 +32,67 @@ class Detox {
|
|
72
32
|
onError: this._onEmitError.bind(this),
|
73
33
|
});
|
74
34
|
|
35
|
+
/** @type {Detox.Device} */
|
75
36
|
this.device = null;
|
76
|
-
|
77
|
-
this.
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
}
|
87
|
-
|
88
|
-
return this[_initHandle].promise;
|
89
|
-
}
|
90
|
-
|
91
|
-
async cleanup() {
|
92
|
-
await this[_assertNoPendingInit]().catch(_.noop);
|
93
|
-
|
94
|
-
if (this._artifactsManager) {
|
95
|
-
await this._artifactsManager.onBeforeCleanup();
|
96
|
-
this._artifactsManager = null;
|
97
|
-
}
|
98
|
-
|
99
|
-
if (this._client) {
|
100
|
-
this._client.dumpPendingRequests();
|
101
|
-
await this._client.cleanup();
|
102
|
-
this._client = null;
|
103
|
-
}
|
104
|
-
|
105
|
-
if (this.device) {
|
106
|
-
const shutdown = this._behaviorConfig.cleanup.shutdownDevice;
|
107
|
-
await this.device._cleanup();
|
108
|
-
await this._deviceAllocator.free(this._deviceCookie, { shutdown });
|
109
|
-
}
|
110
|
-
|
111
|
-
if (this._server) {
|
112
|
-
await this._server.close();
|
113
|
-
this._server = null;
|
114
|
-
}
|
37
|
+
/** @type {Detox.ElementFacade} */
|
38
|
+
this.element = null;
|
39
|
+
/** @type {Detox.WaitForFacade} */
|
40
|
+
this.waitFor = null;
|
41
|
+
/** @type {Detox.ExpectFacade} */
|
42
|
+
this.expect = null;
|
43
|
+
/** @type {Detox.ByFacade} */
|
44
|
+
this.by = null;
|
45
|
+
/** @type {Detox.WebFacade} */
|
46
|
+
this.web = null;
|
115
47
|
|
116
48
|
this._deviceAllocator = null;
|
117
49
|
this._deviceCookie = null;
|
118
|
-
this.device = null;
|
119
|
-
}
|
120
|
-
|
121
|
-
async beforeEach(testSummary) {
|
122
|
-
await this[_assertNoPendingInit]();
|
123
50
|
|
124
|
-
this.
|
125
|
-
|
126
|
-
|
127
|
-
pendingRequests: false,
|
128
|
-
testName: testSummary.fullName,
|
129
|
-
});
|
130
|
-
await this._artifactsManager.onTestStart(testSummary);
|
131
|
-
}
|
132
|
-
|
133
|
-
async afterEach(testSummary) {
|
134
|
-
await this[_assertNoPendingInit]();
|
135
|
-
|
136
|
-
this._validateTestSummary('afterEach', testSummary);
|
137
|
-
this._logTestRunCheckpoint('DETOX_AFTER_EACH', testSummary);
|
138
|
-
await this._artifactsManager.onTestDone(testSummary);
|
139
|
-
await this._dumpUnhandledErrorsIfAny({
|
140
|
-
pendingRequests: testSummary.timedOut,
|
141
|
-
testName: testSummary.fullName,
|
142
|
-
});
|
51
|
+
this.trace = this._context.trace;
|
52
|
+
/** @deprecated */
|
53
|
+
this.traceCall = this._context.traceCall;
|
143
54
|
}
|
144
55
|
|
145
|
-
async
|
146
|
-
|
147
|
-
const sessionConfig = this._sessionConfig;
|
56
|
+
async init() {
|
57
|
+
if (this._isCleaningUp) return;
|
148
58
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
await this._server.open();
|
158
|
-
|
159
|
-
if (!sessionConfig.server) {
|
160
|
-
sessionConfig.server = `ws://localhost:${this._server.port}`;
|
161
|
-
}
|
162
|
-
}
|
59
|
+
const { appsConfig, artifactsConfig, behaviorConfig, deviceConfig, sessionConfig } = this._config;
|
60
|
+
this._appsConfig = appsConfig;
|
61
|
+
this._artifactsConfig = artifactsConfig;
|
62
|
+
this._behaviorConfig = behaviorConfig;
|
63
|
+
this._deviceConfig = deviceConfig;
|
64
|
+
this._sessionConfig = sessionConfig;
|
65
|
+
this._runtimeErrorComposer.appsConfig = this._appsConfig;
|
163
66
|
|
67
|
+
sessionConfig.sessionId = sessionConfig.sessionId || uuid.UUID();
|
164
68
|
this._client = new Client(sessionConfig);
|
165
69
|
this._client.terminateApp = async () => {
|
70
|
+
// @ts-ignore
|
166
71
|
if (this.device && this.device._isAppRunning()) {
|
167
72
|
await this.device.terminateApp();
|
168
73
|
}
|
169
74
|
};
|
170
75
|
|
171
76
|
await this._client.connect();
|
77
|
+
if (this._isCleaningUp) return;
|
172
78
|
|
173
79
|
const invocationManager = new InvocationManager(this._client);
|
174
80
|
|
175
81
|
const {
|
82
|
+
// @ts-ignore
|
176
83
|
envValidatorFactory,
|
177
84
|
deviceAllocatorFactory,
|
85
|
+
// @ts-ignore
|
178
86
|
artifactsManagerFactory,
|
87
|
+
// @ts-ignore
|
179
88
|
matchersFactory,
|
89
|
+
// @ts-ignore
|
180
90
|
runtimeDeviceFactory,
|
181
91
|
} = environmentFactory.createFactories(this._deviceConfig);
|
182
92
|
|
183
93
|
const envValidator = envValidatorFactory.createValidator();
|
184
94
|
await envValidator.validate();
|
95
|
+
if (this._isCleaningUp) return;
|
185
96
|
|
186
97
|
const commonDeps = {
|
187
98
|
invocationManager,
|
@@ -191,9 +102,9 @@ class Detox {
|
|
191
102
|
};
|
192
103
|
|
193
104
|
this._artifactsManager = artifactsManagerFactory.createArtifactsManager(this._artifactsConfig, commonDeps);
|
194
|
-
|
195
105
|
this._deviceAllocator = deviceAllocatorFactory.createDeviceAllocator(commonDeps);
|
196
106
|
this._deviceCookie = await this._deviceAllocator.allocate(this._deviceConfig);
|
107
|
+
if (this._isCleaningUp) return;
|
197
108
|
|
198
109
|
this.device = runtimeDeviceFactory.createRuntimeDevice(
|
199
110
|
this._deviceCookie,
|
@@ -204,7 +115,7 @@ class Detox {
|
|
204
115
|
deviceConfig: this._deviceConfig,
|
205
116
|
sessionConfig,
|
206
117
|
});
|
207
|
-
|
118
|
+
if (this._isCleaningUp) return;
|
208
119
|
|
209
120
|
const matchers = matchersFactory.createMatchers({
|
210
121
|
invocationManager,
|
@@ -213,34 +124,102 @@ class Detox {
|
|
213
124
|
});
|
214
125
|
Object.assign(this, matchers);
|
215
126
|
|
216
|
-
if (behaviorConfig.exposeGlobals) {
|
217
|
-
Object.assign(
|
127
|
+
if (behaviorConfig.init.exposeGlobals) {
|
128
|
+
Object.assign(DetoxWorker.global, {
|
218
129
|
...matchers,
|
219
130
|
device: this.device,
|
131
|
+
detox: this,
|
220
132
|
});
|
221
133
|
}
|
222
134
|
|
135
|
+
// @ts-ignore
|
223
136
|
await this.device.installUtilBinaries();
|
224
|
-
if (
|
137
|
+
if (this._isCleaningUp) return;
|
138
|
+
|
139
|
+
if (behaviorConfig.init.reinstallApp) {
|
225
140
|
await this._reinstallAppsOnDevice();
|
141
|
+
if (this._isCleaningUp) return;
|
142
|
+
}
|
143
|
+
|
144
|
+
const appAliases = Object.keys(this._appsConfig);
|
145
|
+
if (appAliases.length === 1) {
|
146
|
+
await this.device.selectApp(appAliases[0]);
|
147
|
+
} else {
|
148
|
+
await this.device.selectApp(null);
|
226
149
|
}
|
227
150
|
|
228
151
|
return this;
|
229
152
|
}
|
230
153
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
154
|
+
async cleanup() {
|
155
|
+
this._isCleaningUp = true;
|
156
|
+
|
157
|
+
if (this._artifactsManager) {
|
158
|
+
await this._artifactsManager.onBeforeCleanup();
|
159
|
+
this._artifactsManager = null;
|
235
160
|
}
|
236
161
|
|
237
|
-
if (
|
238
|
-
|
162
|
+
if (this._client) {
|
163
|
+
this._client.dumpPendingRequests();
|
164
|
+
await this._client.cleanup();
|
165
|
+
this._client = null;
|
239
166
|
}
|
240
167
|
|
241
|
-
|
168
|
+
if (this.device) {
|
169
|
+
const shutdown = this._behaviorConfig ? this._behaviorConfig.cleanup.shutdownDevice : false;
|
170
|
+
// @ts-ignore
|
171
|
+
await this.device._cleanup();
|
172
|
+
await this._deviceAllocator.free(this._deviceCookie, { shutdown });
|
173
|
+
}
|
174
|
+
|
175
|
+
this._deviceAllocator = null;
|
176
|
+
this._deviceCookie = null;
|
177
|
+
this.device = null;
|
178
|
+
}
|
179
|
+
|
180
|
+
get log() {
|
181
|
+
return this._context.log;
|
242
182
|
}
|
243
183
|
|
184
|
+
onRunStart = async (...args) => this._artifactsManager.onRunStart(...args);
|
185
|
+
onRunDescribeStart = async (...args) => this._artifactsManager.onRunDescribeStart(...args);
|
186
|
+
onTestStart = async (testSummary) => {
|
187
|
+
if (this._isCleaningUp) return;
|
188
|
+
this._validateTestSummary('beforeEach', testSummary);
|
189
|
+
this._logTestRunCheckpoint('DETOX_BEFORE_EACH', testSummary);
|
190
|
+
|
191
|
+
if (this._isCleaningUp) return;
|
192
|
+
await this._dumpUnhandledErrorsIfAny({
|
193
|
+
pendingRequests: false,
|
194
|
+
testName: testSummary.fullName,
|
195
|
+
});
|
196
|
+
|
197
|
+
if (this._isCleaningUp) return;
|
198
|
+
await this._artifactsManager.onTestStart(testSummary);
|
199
|
+
};
|
200
|
+
onHookStart = async (...args) => this._artifactsManager.onHookStart(...args);
|
201
|
+
onHookFailure = async (...args) => this._artifactsManager.onHookFailure(...args);
|
202
|
+
onHookSuccess = async (...args) => this._artifactsManager.onHookSuccess(...args);
|
203
|
+
onTestFnStart = async (...args) => this._artifactsManager.onTestFnStart(...args);
|
204
|
+
onTestFnFailure = async (...args) => this._artifactsManager.onTestFnFailure(...args);
|
205
|
+
onTestFnSuccess = async (...args) => this._artifactsManager.onTestFnSuccess(...args);
|
206
|
+
onTestDone = async (testSummary) => {
|
207
|
+
if (this._isCleaningUp) return;
|
208
|
+
this._validateTestSummary('afterEach', testSummary);
|
209
|
+
this._logTestRunCheckpoint('DETOX_AFTER_EACH', testSummary);
|
210
|
+
|
211
|
+
if (this._isCleaningUp) return;
|
212
|
+
await this._artifactsManager.onTestDone(testSummary);
|
213
|
+
|
214
|
+
if (this._isCleaningUp) return;
|
215
|
+
await this._dumpUnhandledErrorsIfAny({
|
216
|
+
pendingRequests: testSummary.timedOut,
|
217
|
+
testName: testSummary.fullName,
|
218
|
+
});
|
219
|
+
};
|
220
|
+
onRunDescribeFinish = async (...args) => this._artifactsManager.onRunDescribeFinish(...args);
|
221
|
+
onRunFinish = async (...args) => this._artifactsManager.onRunFinish(...args);
|
222
|
+
|
244
223
|
async _reinstallAppsOnDevice() {
|
245
224
|
const appNames = _(this._appsConfig)
|
246
225
|
.map((config, key) => [key, `${config.binaryPath}:${config.testBinaryPath}`])
|
@@ -250,21 +229,21 @@ class Detox {
|
|
250
229
|
|
251
230
|
for (const appName of appNames) {
|
252
231
|
await this.device.selectApp(appName);
|
232
|
+
if (this._isCleaningUp) return;
|
253
233
|
await this.device.uninstallApp();
|
234
|
+
if (this._isCleaningUp) return;
|
254
235
|
}
|
255
236
|
|
256
237
|
for (const appName of appNames) {
|
257
238
|
await this.device.selectApp(appName);
|
239
|
+
if (this._isCleaningUp) return;
|
258
240
|
await this.device.installApp();
|
259
|
-
|
260
|
-
|
261
|
-
if (appNames.length !== 1) {
|
262
|
-
await this.device.selectApp(null);
|
241
|
+
if (this._isCleaningUp) return;
|
263
242
|
}
|
264
243
|
}
|
265
244
|
|
266
245
|
_logTestRunCheckpoint(event, { status, fullName }) {
|
267
|
-
log.trace({ event, status }, `${status} test: ${JSON.stringify(fullName)}`);
|
246
|
+
this.log.trace({ event, status }, `${status} test: ${JSON.stringify(fullName)}`);
|
268
247
|
}
|
269
248
|
|
270
249
|
_validateTestSummary(methodName, testSummary) {
|
@@ -289,29 +268,17 @@ class Detox {
|
|
289
268
|
}
|
290
269
|
|
291
270
|
_onEmitError({ error, eventName, eventObj }) {
|
292
|
-
log.error(
|
271
|
+
this.log.error(
|
293
272
|
{ event: 'EMIT_ERROR', fn: eventName },
|
294
273
|
`Caught an exception in: emitter.emit("${eventName}", ${JSON.stringify(eventObj)})\n\n`,
|
295
274
|
error
|
296
275
|
);
|
297
276
|
}
|
298
|
-
|
299
|
-
static async globalInit(configs) {
|
300
|
-
const handler = await environmentFactory.createGlobalLifecycleHandler(configs.deviceConfig);
|
301
|
-
if (handler) {
|
302
|
-
await handler.globalInit();
|
303
|
-
}
|
304
|
-
}
|
305
|
-
|
306
|
-
static async globalCleanup(configs) {
|
307
|
-
const handler = await environmentFactory.createGlobalLifecycleHandler(configs.deviceConfig);
|
308
|
-
if (handler) {
|
309
|
-
await handler.globalCleanup();
|
310
|
-
}
|
311
|
-
}
|
312
277
|
}
|
313
278
|
|
314
|
-
|
315
|
-
|
279
|
+
/**
|
280
|
+
* @type {NodeJS.Global}
|
281
|
+
*/
|
282
|
+
DetoxWorker.global = global;
|
316
283
|
|
317
|
-
module.exports =
|
284
|
+
module.exports = DetoxWorker;
|