detox 20.0.3-breaking.new-global-lifecycle.0 → 20.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar → 20.0.3/detox-20.0.3-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar → 20.0.3/detox-20.0.3-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom → 20.0.3/detox-20.0.3.pom} +1 -7
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.3/detox-20.0.3.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/build.gradle +12 -7
- package/android/detox/build.gradle +13 -9
- package/android/detox/proguard-rules-app.pro +6 -0
- package/android/detox/proguard-rules.pro +3 -0
- package/android/detox/publishing.gradle +27 -27
- package/android/detox/src/full/java/com/wix/detox/DetoxCrashHandler.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/LaunchArgs.java +9 -0
- package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +15 -2
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeIdlingResources.kt +43 -38
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/IdlingResourceDescription.kt +19 -13
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +33 -30
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategy.kt +7 -27
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/IdleInterrogationStrategy.kt +1 -11
- package/android/detox/src/main/java/com/wix/detox/common/TextFileReader.kt +1 -1
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/DetoxMultiTapSpec.kt +4 -3
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +61 -0
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategySpec.kt +3 -11
- package/index.d.ts +195 -59
- package/internals.d.ts +205 -43
- package/local-cli/build.js +1 -1
- package/local-cli/cli.js +11 -6
- package/local-cli/init.js +61 -21
- package/local-cli/rebuild-framework-cache.js +1 -1
- package/local-cli/reset-lock-file.js +16 -0
- package/local-cli/templates/jest.js +13 -10
- package/local-cli/test.js +14 -8
- package/local-cli/test.test.js +142 -61
- package/local-cli/testCommand/TestRunnerCommand.js +97 -77
- package/local-cli/testCommand/TestRunnerError.js +17 -0
- package/local-cli/testCommand/TestRunnerError.test.js +25 -0
- package/local-cli/testCommand/builder.js +0 -1
- package/local-cli/testCommand/middlewares.js +4 -13
- package/local-cli/testCommand/warnings.js +0 -3
- package/local-cli/utils/jestInternals.js +4 -1
- package/package.json +23 -18
- package/runners/deprecation.js +42 -44
- package/runners/jest/globalSetup.js +1 -1
- package/runners/jest/globalTeardown.js +1 -1
- package/runners/jest/index.d.ts +60 -0
- package/runners/jest/index.js +3 -8
- package/runners/jest/index.test.js +13 -0
- package/runners/jest/reporters/DetoxReporter.js +33 -2
- package/runners/jest/testEnvironment/index.js +119 -69
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +93 -46
- package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +1 -1
- package/runners/jest/testEnvironment/listeners/SpecReporter.js +13 -15
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -5
- package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -1
- package/src/DetoxWorker.js +99 -62
- package/src/android/core/NativeElement.js +56 -20
- package/src/android/core/NativeExpect.js +28 -9
- package/src/android/interactions/native.js +25 -18
- package/src/artifacts/ArtifactsManager.js +14 -47
- package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
- package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
- 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/timeline/TimelineContextTypes.js +7 -0
- package/src/artifacts/utils/temporaryPath.js +49 -8
- package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
- package/src/client/AsyncWebSocket.js +8 -17
- package/src/client/Client.js +19 -2
- package/src/client/actions/formatters/sync-resources/NetworkFormatter.js +1 -1
- package/src/configuration/collectCliConfig.js +1 -12
- package/src/configuration/composeAppsConfig.js +4 -0
- package/src/configuration/composeDeviceConfig.js +1 -1
- package/src/configuration/composeLoggerConfig.js +19 -10
- package/src/configuration/composeRunnerConfig.js +14 -9
- package/src/configuration/index.js +5 -1
- package/src/configuration/loadExternalConfig.js +1 -1
- package/src/devices/allocation/DeviceAllocator.js +3 -2
- package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +5 -5
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +6 -5
- package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +4 -17
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
- package/src/devices/common/drivers/android/exec/ADB.js +4 -0
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +3 -3
- 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/android/tools/MonitoredInstrumentation.js +1 -1
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +29 -3
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
- package/src/devices/runtime/RuntimeDevice.js +19 -12
- package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
- package/src/devices/runtime/drivers/android/AndroidDriver.js +10 -2
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +1 -1
- package/src/errors/DetoxConfigErrorComposer.js +14 -1
- package/src/errors/DetoxError.js +5 -1
- package/src/ios/expectTwo.js +153 -67
- package/src/ipc/IPCClient.js +12 -13
- package/src/ipc/IPCServer.js +28 -24
- package/src/ipc/{state.js → SessionState.js} +26 -53
- package/src/logger/DetoxLogger.js +287 -154
- package/src/logger/index.js +5 -0
- package/src/logger/utils/BunyanLogger.js +115 -0
- package/src/logger/utils/CategoryThreadDispatcher.js +37 -0
- package/src/logger/utils/DetoxLogFinalizer.js +162 -0
- package/src/logger/utils/MessageStack.js +35 -0
- package/src/logger/utils/ThreadDispatcher.js +61 -0
- package/src/logger/{customConsoleLogger.js → utils/customConsoleLogger.js} +23 -6
- package/src/logger/utils/getMainCategory.js +5 -0
- package/src/logger/utils/sanitizeBunyanContext.js +30 -0
- package/src/logger/utils/streams/BunyanTransformer.js +72 -0
- package/src/logger/utils/streams/ChromeTraceTransformer.js +127 -0
- package/src/logger/utils/streams/DetoxJSONLParser.js +31 -0
- package/src/logger/utils/streams/JSONLStringer.js +55 -0
- package/src/logger/utils/streams/index.js +7 -0
- package/src/logger/utils/streams/transformers.js +39 -0
- package/src/logger/utils/tracerLegacy.js +37 -0
- package/src/realms/DetoxContext.js +79 -65
- package/src/realms/DetoxInternalsFacade.js +8 -12
- package/src/realms/DetoxPrimaryContext.js +104 -70
- package/src/realms/DetoxSecondaryContext.js +29 -32
- 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 +16 -22
- package/src/utils/Timer.js +55 -38
- package/src/utils/argparse.js +11 -0
- package/src/utils/childProcess/exec.js +1 -1
- package/src/utils/childProcess/spawn.js +1 -1
- package/src/utils/errorUtils.js +24 -3
- package/src/utils/invocationTraceDescriptions.js +43 -0
- package/src/utils/logger.js +1 -1
- package/src/utils/pathUtils.js +11 -0
- package/src/utils/shellUtils.js +17 -0
- package/src/utils/traceInvocationCall.js +21 -0
- package/src/utils/traceMethods.js +15 -0
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.3-breaking.new-global-lifecycle.0/detox-20.0.3-breaking.new-global-lifecycle.0.pom.sha512 +0 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategy.kt +0 -84
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategySpec.kt +0 -115
- package/runners/jest/deprecation.js +0 -25
- package/src/configuration/utils/warnings.js +0 -12
- package/src/logger/DetoxTraceEventBuilder.js +0 -21
- package/src/logger/DetoxTracer.js +0 -133
- package/src/logger/TraceThreadDispatcher.js +0 -52
- package/src/utils/ChromeTracingExporter.js +0 -54
- package/src/utils/streamUtils.js +0 -214
- package/src/utils/trace.js +0 -19
package/internals.d.ts
CHANGED
@@ -3,84 +3,233 @@
|
|
3
3
|
|
4
4
|
declare global {
|
5
5
|
namespace DetoxInternals {
|
6
|
+
type DetoxStatus = 'inactive' | 'init' | 'active' | 'cleanup';
|
7
|
+
|
6
8
|
type Facade = {
|
7
|
-
|
9
|
+
//#region Initialization
|
8
10
|
/**
|
9
|
-
* Use with a caution, when you still have no config, yet need to avoid {@link Facade#
|
11
|
+
* Use with a caution, when you still have no config, yet need to avoid {@link Facade#init}
|
10
12
|
*/
|
11
|
-
resolveConfig(options?: Partial<
|
13
|
+
resolveConfig(options?: Partial<DetoxInitOptions>): Promise<RuntimeConfig>;
|
12
14
|
|
13
15
|
/**
|
14
|
-
*
|
16
|
+
* Returns one of statuses depending on what’s going with the current Detox context:
|
17
|
+
*
|
18
|
+
* `inactive` – before `init()` and after `cleanup()` is called.
|
19
|
+
* `init` – while `init()` is executing.
|
20
|
+
* `active` – after `init()` and before `cleanup()` is called.
|
21
|
+
* `cleanup` – while `cleanup()` is executing.
|
15
22
|
*/
|
16
|
-
|
23
|
+
getStatus(): DetoxStatus;
|
17
24
|
|
18
25
|
/**
|
19
|
-
*
|
26
|
+
* Starts a new Detox test session with the provided configuration.
|
27
|
+
* See {@link https://wix.github.io/Detox/docs/api/internals} for more details.
|
20
28
|
*/
|
21
|
-
|
29
|
+
init(options?: Partial<DetoxInitOptions>): Promise<void>;
|
22
30
|
|
23
31
|
/**
|
24
|
-
*
|
32
|
+
* This is the phase where Detox loads its expectation library and boots a device.
|
33
|
+
* You don't need to call it separately unless you use `init({ workerId: null })` override.
|
25
34
|
*/
|
26
|
-
|
35
|
+
installWorker(options?: Partial<DetoxInstallWorkerOptions>): Promise<void>;
|
27
36
|
|
28
37
|
/**
|
29
|
-
*
|
30
|
-
*
|
38
|
+
* Deallocates the device.
|
39
|
+
* Most Client API (device, by, element, expect) will stop working, except for the logger.
|
31
40
|
*/
|
32
|
-
|
33
|
-
// endregion
|
41
|
+
uninstallWorker(): Promise<void>;
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
onHookSuccess(event: unknown): Promise<void>;
|
42
|
-
onTestFnStart(event: unknown): Promise<void>;
|
43
|
-
onTestFnFailure(event: unknown): Promise<void>;
|
44
|
-
onTestFnSuccess(event: unknown): Promise<void>;
|
45
|
-
onTestDone(event: unknown): Promise<void>;
|
46
|
-
onRunDescribeFinish(event: unknown): Promise<void>;
|
47
|
-
onRunFinish(event: unknown): Promise<void>;
|
43
|
+
/**
|
44
|
+
* This method should be called when the main or child process is about to exit.
|
45
|
+
* See {@link https://wix.github.io/Detox/docs/api/internals} for more details.
|
46
|
+
*/
|
47
|
+
cleanup(): Promise<void>;
|
48
|
+
//#endregion
|
48
49
|
|
50
|
+
//#region Lifecycle
|
51
|
+
/**
|
52
|
+
* Reports that the test runner started executing a test suite, e.g. a `beforeAll` hook or a first test.
|
53
|
+
*/
|
54
|
+
onRunDescribeStart(event: {
|
55
|
+
/** Test suite name */
|
56
|
+
name: string;
|
57
|
+
}): Promise<void>;
|
58
|
+
/**
|
59
|
+
* Reports that the test runner started executing a specific test.
|
60
|
+
*/
|
61
|
+
onTestStart(event: {
|
62
|
+
/** Test name */
|
63
|
+
title: string;
|
64
|
+
/** Test name including the ancestor suite titles */
|
65
|
+
fullName: string;
|
66
|
+
/**
|
67
|
+
* N-th time this test is running, if there is a retry mechanism.
|
68
|
+
*
|
69
|
+
* @default 1
|
70
|
+
*/
|
71
|
+
invocations?: number;
|
72
|
+
status: 'running';
|
73
|
+
}): Promise<void>;
|
74
|
+
/**
|
75
|
+
* Reports about an error in the midst of `beforeAll`, `beforeEach`, `afterEach`, `afterAll` or any other hook.
|
76
|
+
*/
|
77
|
+
onHookFailure(event: {
|
78
|
+
error: Error | string;
|
79
|
+
/**
|
80
|
+
* @example 'beforeAll'
|
81
|
+
* @example 'afterEach'
|
82
|
+
*/
|
83
|
+
hook: string;
|
84
|
+
}): Promise<void>;
|
85
|
+
/**
|
86
|
+
* Reports about an error in the midst of a test function, `test` or `it`.
|
87
|
+
*/
|
88
|
+
onTestFnFailure(event: {
|
89
|
+
error: Error | string;
|
90
|
+
}): Promise<void>;
|
91
|
+
/**
|
92
|
+
* Reports the final status of the test, `passed` or `failed`.
|
93
|
+
*/
|
94
|
+
onTestDone(event: {
|
95
|
+
/** Test name */
|
96
|
+
title: string;
|
97
|
+
/** Test name including the ancestor suite titles */
|
98
|
+
fullName: string;
|
99
|
+
/**
|
100
|
+
* N-th time this test is running, if there is a retry mechanism.
|
101
|
+
*
|
102
|
+
* @default 1
|
103
|
+
*/
|
104
|
+
invocations?: number;
|
105
|
+
status: 'passed' | 'failed';
|
106
|
+
/** Whether a timeout was the reason for why the test failed. */
|
107
|
+
timedOut?: boolean;
|
108
|
+
}): Promise<void>;
|
49
109
|
/**
|
50
|
-
* Reports
|
110
|
+
* Reports that the test runner has finished executing a test suite, e.g. all the `afterAll` hooks have been executed or the last test has finished running.
|
111
|
+
*/
|
112
|
+
onRunDescribeFinish(event: {
|
113
|
+
/** Test suite name */
|
114
|
+
name: string;
|
115
|
+
}): Promise<void>;
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Reports to Detox CLI about passed and failed test files.
|
119
|
+
* The failed test files might be re-run again if
|
51
120
|
* {@link Detox.DetoxTestRunnerConfig#retries} is set to a non-zero.
|
52
121
|
*
|
53
|
-
* @param
|
54
|
-
* @param permanent whether the failure is permanent, and the tests
|
55
|
-
* should not be re-run.
|
122
|
+
* @param testResults - reports about test files
|
56
123
|
*/
|
57
|
-
|
58
|
-
|
124
|
+
reportTestResults(testResults: DetoxTestFileReport[]): Promise<void>;
|
125
|
+
//#endregion
|
59
126
|
|
60
127
|
readonly config: RuntimeConfig;
|
61
128
|
readonly log: Detox.Logger;
|
62
|
-
readonly trace: Detox.Tracer;
|
63
129
|
readonly session: SessionState;
|
130
|
+
readonly tracing: {
|
131
|
+
/**
|
132
|
+
* Creates a readable stream of the currently recorded events in Chrome Trace Event format.
|
133
|
+
*
|
134
|
+
* @see {@link https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU}
|
135
|
+
* @see {import('trace-event-lib').DurationBeginEvent}
|
136
|
+
* @see {import('trace-event-lib').DurationEndEvent}
|
137
|
+
* @see {import('trace-event-lib').InstantEvent}
|
138
|
+
*/
|
139
|
+
createEventStream(): NodeJS.ReadableStream;
|
140
|
+
};
|
141
|
+
|
142
|
+
/**
|
143
|
+
* Not documented on purpose.
|
144
|
+
* Provides direct access to the object which holds the device driver, websocket client, matchers, expectations, etc.
|
145
|
+
*/
|
146
|
+
readonly worker: Worker;
|
147
|
+
}
|
64
148
|
|
65
|
-
|
149
|
+
interface Worker extends Detox.DetoxExportWrapper {
|
150
|
+
readonly id: string;
|
66
151
|
}
|
67
152
|
|
68
|
-
type
|
153
|
+
type DetoxInitOptions = {
|
69
154
|
cwd: string;
|
155
|
+
/**
|
156
|
+
* @internal
|
157
|
+
*/
|
70
158
|
argv: Record<string, unknown>;
|
71
159
|
testRunnerArgv: Record<string, unknown>;
|
72
160
|
override: Partial<Detox.DetoxConfig>;
|
161
|
+
/** @inheritDoc */
|
162
|
+
global: NodeJS.Global | {};
|
163
|
+
/**
|
164
|
+
* Worker ID. Used to distinguish allocated workers in parallel test execution environment.
|
165
|
+
*
|
166
|
+
* If explicitly set to null, tells {@link Facade#init} to skip {@link Facade#installWorker} call.
|
167
|
+
* Useful for complex test runner integrations, where you have to install the worker via a separate call,
|
168
|
+
* when the environment is ready for that.
|
169
|
+
*
|
170
|
+
* @default 'worker'
|
171
|
+
*/
|
172
|
+
workerId: string | null;
|
73
173
|
};
|
74
174
|
|
75
|
-
type
|
76
|
-
|
77
|
-
|
175
|
+
type DetoxInstallWorkerOptions = {
|
176
|
+
/**
|
177
|
+
* Used for integration with sandboxed test environments.
|
178
|
+
* {@link DetoxInternals.Facade#setup} might override {@link Console} methods
|
179
|
+
* to integrate it with Detox loggeing subsystem.
|
180
|
+
*/
|
181
|
+
global: NodeJS.Global | {};
|
182
|
+
/**
|
183
|
+
* Worker ID. Used to distinguish allocated workers in parallel test execution environment.
|
184
|
+
*
|
185
|
+
* @default 'worker'
|
186
|
+
*/
|
187
|
+
workerId: string;
|
188
|
+
};
|
189
|
+
|
190
|
+
type DetoxTestFileReport = {
|
191
|
+
/**
|
192
|
+
* Global or relative path to the failed test file.
|
193
|
+
*/
|
194
|
+
testFilePath: string;
|
195
|
+
/**
|
196
|
+
* Whether the test passed or not.
|
197
|
+
*/
|
198
|
+
success: boolean;
|
199
|
+
/**
|
200
|
+
* Top-level error if the entire test file failed.
|
201
|
+
*/
|
202
|
+
testExecError?: { name?: string; message: string; stack?: string; };
|
203
|
+
/**
|
204
|
+
* If the test failed, it should tell whether the failure is permanent.
|
205
|
+
* Permanent failure means that the test file should not be re-run.
|
206
|
+
*
|
207
|
+
* @default false
|
208
|
+
* @see {Detox.DetoxTestRunnerConfig#retries}
|
209
|
+
*/
|
210
|
+
isPermanentFailure?: boolean;
|
78
211
|
};
|
79
212
|
|
80
213
|
type SessionState = Readonly<{
|
81
|
-
|
82
|
-
|
214
|
+
/**
|
215
|
+
* Randomly generated ID for the entire Detox test session, including retries.
|
216
|
+
*/
|
217
|
+
id: string;
|
218
|
+
/**
|
219
|
+
* Results of test file executions. Primarily used for Detox CLI retry mechanism.
|
220
|
+
*/
|
221
|
+
testResults: DetoxTestFileReport[];
|
222
|
+
/**
|
223
|
+
* Retry index of the test session: 0..retriesCount.
|
224
|
+
*/
|
83
225
|
testSessionIndex: number;
|
226
|
+
/**
|
227
|
+
* Count of Detox contexts with a worker installed.
|
228
|
+
* Oversimplified, it reflects the count of allocated devices in the current test session.
|
229
|
+
*
|
230
|
+
* @see {Facade#init}
|
231
|
+
* @see {Facade#installWorker}
|
232
|
+
*/
|
84
233
|
workersCount: number;
|
85
234
|
}>;
|
86
235
|
|
@@ -93,16 +242,29 @@ declare global {
|
|
93
242
|
* or equal to "default" if the name is not configured.
|
94
243
|
*/
|
95
244
|
apps: Record<string, Readonly<Detox.DetoxAppConfig>>;
|
96
|
-
artifacts: Readonly<
|
245
|
+
artifacts: Readonly<RuntimeArtifactsConfig>;
|
97
246
|
behavior: Readonly<Detox.DetoxBehaviorConfig>;
|
98
|
-
cli: Readonly<
|
247
|
+
cli: Readonly<CLIConfig>;
|
99
248
|
device: Readonly<Detox.DetoxDeviceConfig>;
|
100
249
|
logger: Readonly<Detox.DetoxLoggerConfig>;
|
101
250
|
testRunner: Readonly<Detox.DetoxTestRunnerConfig>;
|
102
251
|
session: Readonly<Detox.DetoxSessionConfig>;
|
103
252
|
}>;
|
104
253
|
|
105
|
-
type
|
254
|
+
type RuntimeArtifactsConfig = {
|
255
|
+
rootDir: string;
|
256
|
+
pathBuilder: string;
|
257
|
+
plugins: Readonly<{
|
258
|
+
log: Readonly<Detox.DetoxLogArtifactsPluginConfig>;
|
259
|
+
screenshot: Readonly<Detox.DetoxScreenshotArtifactsPluginConfig>;
|
260
|
+
video: Readonly<Detox.DetoxVideoArtifactsPluginConfig>;
|
261
|
+
instruments: Readonly<Detox.DetoxInstrumentsArtifactsPluginConfig>;
|
262
|
+
uiHierarchy: Readonly<Detox.DetoxUIHierarchyArtifactsPluginConfig>;
|
263
|
+
[pluginId: string]: unknown;
|
264
|
+
}>;
|
265
|
+
};
|
266
|
+
|
267
|
+
type CLIConfig = Readonly<Partial<{
|
106
268
|
appLaunchArgs: string;
|
107
269
|
artifactsLocation: string;
|
108
270
|
captureViewHierarchy: string;
|
package/local-cli/build.js
CHANGED
@@ -65,7 +65,7 @@ module.exports.handler = async function build(argv) {
|
|
65
65
|
}
|
66
66
|
|
67
67
|
if (app.binaryPath && !fs.existsSync(app.binaryPath)) {
|
68
|
-
detox.log.warn('
|
68
|
+
detox.log.warn('After running the build command, Detox could not find your app at the given binary path:\n\t' + app.binaryPath + "\nMake sure it is correct, otherwise you'll get an error on an attempt to install your app.\n");
|
69
69
|
}
|
70
70
|
}
|
71
71
|
};
|
package/local-cli/cli.js
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
+
const fs = require('fs');
|
3
|
+
|
4
|
+
const _ = require('lodash');
|
2
5
|
const yargs = require('yargs');
|
3
6
|
|
7
|
+
const logger = require('../internals').log.child({ cat: 'cli' });
|
4
8
|
const DetoxError = require('../src/errors/DetoxError');
|
5
|
-
const logger = require('../src/utils/logger').child({ __filename });
|
6
9
|
|
7
10
|
yargs
|
8
11
|
.scriptName('detox')
|
@@ -25,12 +28,14 @@ yargs
|
|
25
28
|
.wrap(yargs.terminalWidth() * 0.9)
|
26
29
|
.fail(function(msg, err, program) {
|
27
30
|
if (err) {
|
28
|
-
const
|
29
|
-
|
30
|
-
logger.error(
|
31
|
+
const message = DetoxError.format(err);
|
32
|
+
if (message) {
|
33
|
+
logger.error(message);
|
34
|
+
process.stderr.write('\n');
|
31
35
|
}
|
32
|
-
|
33
|
-
|
36
|
+
|
37
|
+
// @ts-ignore
|
38
|
+
_.attempt(() => fs.unlinkSync(logger.file));
|
34
39
|
// eslint-disable-next-line no-process-exit
|
35
40
|
process.exit(1);
|
36
41
|
}
|
package/local-cli/init.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
const fs = require('fs');
|
2
2
|
const path = require('path');
|
3
|
+
const util = require('util');
|
3
4
|
|
4
5
|
const detox = require('../internals');
|
5
6
|
|
@@ -8,10 +9,11 @@ const jestTemplates = require('./templates/jest');
|
|
8
9
|
let exitCode = 0;
|
9
10
|
|
10
11
|
module.exports.command = 'init';
|
11
|
-
module.exports.desc = '
|
12
|
+
module.exports.desc = 'Creates template files to get you started with Detox';
|
12
13
|
module.exports.builder = {};
|
13
14
|
|
14
15
|
module.exports.handler = async function init() {
|
16
|
+
createDetoxConfig();
|
15
17
|
createJestFolderE2E();
|
16
18
|
process.exit(exitCode); // eslint-disable-line
|
17
19
|
};
|
@@ -51,44 +53,66 @@ function createFile(filename, content) {
|
|
51
53
|
|
52
54
|
function createJestFolderE2E() {
|
53
55
|
createFolder('e2e', {
|
54
|
-
'config.
|
56
|
+
'jest.config.js': jestTemplates.runnerConfig,
|
55
57
|
'starter.test.js': jestTemplates.starter,
|
56
58
|
});
|
59
|
+
}
|
57
60
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
...createDefaultConfigurations(),
|
66
|
-
}, null, 2));
|
61
|
+
function createDetoxConfig() {
|
62
|
+
createFile('.detoxrc.js',
|
63
|
+
'/** @type {Detox.DetoxConfig} */\n' +
|
64
|
+
'module.exports = ' +
|
65
|
+
util.inspect(createDefaultConfigurations(), { compact: false, depth: Infinity }) +
|
66
|
+
';\n'
|
67
|
+
);
|
67
68
|
}
|
68
69
|
|
70
|
+
/** @returns {Detox.DetoxConfig} */
|
69
71
|
function createDefaultConfigurations() {
|
70
72
|
return {
|
71
73
|
testRunner: {
|
72
74
|
args: {
|
73
75
|
$0: 'jest',
|
74
|
-
config: 'e2e/config.
|
76
|
+
config: 'e2e/jest.config.js',
|
77
|
+
},
|
78
|
+
jest: {
|
79
|
+
setupTimeout: 120000,
|
75
80
|
},
|
76
81
|
},
|
77
82
|
apps: {
|
78
|
-
ios: {
|
83
|
+
'ios.debug': {
|
79
84
|
type: 'ios.app',
|
80
|
-
binaryPath: '
|
85
|
+
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/YOUR_APP.app',
|
86
|
+
build: 'xcodebuild -workspace ios/YOUR_APP.xcworkspace -scheme YOUR_APP -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build',
|
87
|
+
},
|
88
|
+
'ios.release': {
|
89
|
+
type: 'ios.app',
|
90
|
+
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/YOUR_APP.app',
|
91
|
+
build: 'xcodebuild -workspace ios/YOUR_APP.xcworkspace -scheme YOUR_APP -configuration Release -sdk iphonesimulator -derivedDataPath ios/build',
|
92
|
+
},
|
93
|
+
'android.debug': {
|
94
|
+
type: 'android.apk',
|
95
|
+
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
|
96
|
+
build: 'cd android ; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug ; cd -',
|
97
|
+
reversePorts: [8081],
|
81
98
|
},
|
82
|
-
android: {
|
99
|
+
'android.release': {
|
83
100
|
type: 'android.apk',
|
84
|
-
binaryPath: '
|
101
|
+
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
|
102
|
+
build: 'cd android ; ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release ; cd -',
|
85
103
|
},
|
86
104
|
},
|
87
105
|
devices: {
|
88
106
|
simulator: {
|
89
107
|
type: 'ios.simulator',
|
90
108
|
device: {
|
91
|
-
type: 'iPhone
|
109
|
+
type: 'iPhone 12',
|
110
|
+
},
|
111
|
+
},
|
112
|
+
attached: {
|
113
|
+
type: 'android.attached',
|
114
|
+
device: {
|
115
|
+
adbName: '.*',
|
92
116
|
},
|
93
117
|
},
|
94
118
|
emulator: {
|
@@ -99,13 +123,29 @@ function createDefaultConfigurations() {
|
|
99
123
|
},
|
100
124
|
},
|
101
125
|
configurations: {
|
102
|
-
ios: {
|
126
|
+
'ios.sim.debug': {
|
127
|
+
device: 'simulator',
|
128
|
+
app: 'ios.debug',
|
129
|
+
},
|
130
|
+
'ios.sim.release': {
|
103
131
|
device: 'simulator',
|
104
|
-
app: 'ios',
|
132
|
+
app: 'ios.release',
|
133
|
+
},
|
134
|
+
'android.att.debug': {
|
135
|
+
device: 'attached',
|
136
|
+
app: 'android.debug',
|
137
|
+
},
|
138
|
+
'android.att.release': {
|
139
|
+
device: 'attached',
|
140
|
+
app: 'android.release',
|
141
|
+
},
|
142
|
+
'android.emu.debug': {
|
143
|
+
device: 'emulator',
|
144
|
+
app: 'android.debug',
|
105
145
|
},
|
106
|
-
android: {
|
146
|
+
'android.emu.release': {
|
107
147
|
device: 'emulator',
|
108
|
-
app: 'android',
|
148
|
+
app: 'android.release',
|
109
149
|
},
|
110
150
|
},
|
111
151
|
};
|
@@ -4,7 +4,7 @@ const path = require('path');
|
|
4
4
|
|
5
5
|
const fs = require('fs-extra');
|
6
6
|
|
7
|
-
const log = require('../src/utils/logger').child({
|
7
|
+
const log = require('../src/utils/logger').child({ cat: 'cli' });
|
8
8
|
|
9
9
|
module.exports.command = 'rebuild-framework-cache';
|
10
10
|
module.exports.desc = 'Rebuilds a cached Detox framework for the current environment in ~/Library/Detox. The cached framework is unique for each combination of Xcode and Detox version. (macOS only)';
|
@@ -0,0 +1,16 @@
|
|
1
|
+
const { log } = require('../internals');
|
2
|
+
const DeviceRegistry = require('../src/devices/DeviceRegistry');
|
3
|
+
const { getDetoxLibraryRootPath } = require('../src/utils/environment');
|
4
|
+
|
5
|
+
|
6
|
+
module.exports.command = 'reset-lock-file';
|
7
|
+
module.exports.desc = 'Resets all Detox lock files. Useful when you need to run multiple `detox test` commands in parallel with --keepLockFile.';
|
8
|
+
|
9
|
+
module.exports.handler = async function resetLockFile() {
|
10
|
+
await Promise.all([
|
11
|
+
DeviceRegistry.forIOS().reset(),
|
12
|
+
DeviceRegistry.forAndroid().reset(),
|
13
|
+
]);
|
14
|
+
|
15
|
+
log.info(`Cleaned lock files from: ${getDetoxLibraryRootPath()}`);
|
16
|
+
};
|
@@ -1,15 +1,18 @@
|
|
1
1
|
const firstTestContent = require('./firstTestContent');
|
2
2
|
|
3
|
-
const runnerConfig =
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
const runnerConfig = `\
|
4
|
+
/** @type {import('@jest/types').Config.InitialOptions} */
|
5
|
+
module.exports = {
|
6
|
+
rootDir: '..',
|
7
|
+
testMatch: ['<rootDir>/e2e/**/*.test.js'],
|
8
|
+
testTimeout: 120000,
|
9
|
+
maxWorkers: 1,
|
10
|
+
globalSetup: 'detox/runners/jest/globalSetup',
|
11
|
+
globalTeardown: 'detox/runners/jest/globalTeardown',
|
12
|
+
reporters: ['detox/runners/jest/reporter'],
|
13
|
+
testEnvironment: 'detox/runners/jest/testEnvironment',
|
14
|
+
verbose: true,
|
15
|
+
};
|
13
16
|
`;
|
14
17
|
|
15
18
|
exports.starter = firstTestContent;
|
package/local-cli/test.js
CHANGED
@@ -3,24 +3,30 @@ const detox = require('../internals');
|
|
3
3
|
const TestRunnerCommand = require('./testCommand/TestRunnerCommand');
|
4
4
|
|
5
5
|
module.exports.command = 'test';
|
6
|
-
module.exports.desc = 'Run your test
|
6
|
+
module.exports.desc = 'Run your test suites with the test runner specified in the project\'s Detox config';
|
7
7
|
module.exports.builder = require('./testCommand/builder');
|
8
8
|
module.exports.middlewares = require('./testCommand/middlewares').default;
|
9
9
|
|
10
10
|
module.exports.handler = async function test({ detoxArgs, runnerArgs }) {
|
11
11
|
try {
|
12
|
-
|
12
|
+
const opts = {
|
13
13
|
argv: detoxArgs,
|
14
14
|
testRunnerArgv: runnerArgs,
|
15
|
-
|
15
|
+
workerId: null,
|
16
|
+
};
|
17
|
+
|
18
|
+
const config = await detox.resolveConfig(opts);
|
19
|
+
if (!config.cli.inspectBrk) {
|
20
|
+
await detox.init(opts);
|
21
|
+
}
|
16
22
|
|
17
|
-
const runnerCommand = new TestRunnerCommand(
|
18
|
-
|
19
|
-
.
|
20
|
-
|
23
|
+
const runnerCommand = new TestRunnerCommand({
|
24
|
+
config,
|
25
|
+
env: process.env,
|
26
|
+
});
|
21
27
|
|
22
28
|
await runnerCommand.execute();
|
23
29
|
} finally {
|
24
|
-
await detox.
|
30
|
+
await detox.cleanup();
|
25
31
|
}
|
26
32
|
};
|