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
@@ -1,75 +0,0 @@
|
|
1
|
-
package com.wix.detox.espresso.common
|
2
|
-
|
3
|
-
import android.view.View
|
4
|
-
import androidx.appcompat.widget.AppCompatSeekBar
|
5
|
-
import com.facebook.react.bridge.JavaOnlyMap
|
6
|
-
import com.facebook.react.uimanager.ReactStylesDiffMap
|
7
|
-
import com.facebook.react.views.slider.ReactSlider
|
8
|
-
import com.wix.detox.common.DetoxErrors.DetoxIllegalStateException
|
9
|
-
import com.wix.detox.espresso.action.common.ReflectUtils
|
10
|
-
import org.joor.Reflect
|
11
|
-
|
12
|
-
private const val CLASS_REACT_SLIDER_LEGACY = "com.facebook.react.views.slider.ReactSlider"
|
13
|
-
private const val CLASS_REACT_SLIDER_COMMUNITY = "com.reactnativecommunity.slider.ReactSlider"
|
14
|
-
|
15
|
-
abstract class SliderHelper(protected val slider: AppCompatSeekBar) {
|
16
|
-
fun getCurrentProgressPct(): Double {
|
17
|
-
val nativeProgress = slider.progress.toDouble()
|
18
|
-
val nativeMax = slider.max
|
19
|
-
return nativeProgress / nativeMax
|
20
|
-
}
|
21
|
-
|
22
|
-
// TODO Make this more testable (e.g. by delegating the set action away)
|
23
|
-
fun setProgressPct(valuePct: Double) {
|
24
|
-
val maxJSProgress = calcMaxJSProgress()
|
25
|
-
val valueJS = valuePct * maxJSProgress
|
26
|
-
setProgressJS(valueJS)
|
27
|
-
}
|
28
|
-
|
29
|
-
protected abstract fun setProgressJS(valueJS: Double)
|
30
|
-
|
31
|
-
private fun calcMaxJSProgress(): Double {
|
32
|
-
val nativeProgress = slider.progress.toDouble()
|
33
|
-
val nativeMax = slider.max
|
34
|
-
val toMaxFactor = nativeMax / nativeProgress
|
35
|
-
|
36
|
-
val jsProgress = getJSProgress()
|
37
|
-
return jsProgress * toMaxFactor
|
38
|
-
}
|
39
|
-
|
40
|
-
private fun getJSProgress(): Double =
|
41
|
-
Reflect.on(slider).call("toRealProgress", slider.progress).get() as Double
|
42
|
-
|
43
|
-
companion object {
|
44
|
-
fun create(view: View) =
|
45
|
-
maybeCreate(view)
|
46
|
-
?: throw DetoxIllegalStateException("Cannot handle this type of a seek-bar view (Class ${view.javaClass.canonicalName}). " +
|
47
|
-
"Only React Native sliders are currently supported.")
|
48
|
-
|
49
|
-
fun maybeCreate(view: View): SliderHelper? =
|
50
|
-
when {
|
51
|
-
ReflectUtils.isAssignableFrom(view, CLASS_REACT_SLIDER_LEGACY)
|
52
|
-
-> LegacySliderHelper(view as ReactSlider)
|
53
|
-
ReflectUtils.isAssignableFrom(view, CLASS_REACT_SLIDER_COMMUNITY)
|
54
|
-
-> CommunitySliderHelper(view as AppCompatSeekBar)
|
55
|
-
else
|
56
|
-
-> null
|
57
|
-
}
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
private class LegacySliderHelper(slider: AppCompatSeekBar): SliderHelper(slider) {
|
62
|
-
override fun setProgressJS(valueJS: Double) {
|
63
|
-
val reactSliderManager = com.facebook.react.views.slider.ReactSliderManager()
|
64
|
-
reactSliderManager.updateProperties(slider as ReactSlider, buildStyles("value", valueJS))
|
65
|
-
}
|
66
|
-
|
67
|
-
private fun buildStyles(vararg keysAndValues: Any) = ReactStylesDiffMap(JavaOnlyMap.of(*keysAndValues))
|
68
|
-
}
|
69
|
-
|
70
|
-
private class CommunitySliderHelper(slider: AppCompatSeekBar): SliderHelper(slider) {
|
71
|
-
override fun setProgressJS(valueJS: Double) {
|
72
|
-
val reactSliderManager = Class.forName("com.reactnativecommunity.slider.ReactSliderManager").newInstance()
|
73
|
-
Reflect.on(reactSliderManager).call("setValue", slider, valueJS)
|
74
|
-
}
|
75
|
-
}
|
@@ -1,39 +0,0 @@
|
|
1
|
-
package com.wix.detox.espresso.common
|
2
|
-
|
3
|
-
import com.facebook.react.views.slider.ReactSlider
|
4
|
-
import org.assertj.core.api.Assertions.assertThat
|
5
|
-
import org.junit.Before
|
6
|
-
import org.junit.Test
|
7
|
-
import org.junit.runner.RunWith
|
8
|
-
import org.mockito.kotlin.doReturn
|
9
|
-
import org.mockito.kotlin.mock
|
10
|
-
import org.mockito.kotlin.whenever
|
11
|
-
import org.robolectric.RobolectricTestRunner
|
12
|
-
|
13
|
-
/**
|
14
|
-
* Note: This only tests against the react *legacy* (non-community) slider in order
|
15
|
-
* to avoid having to install the community slider under node_modules just for this.
|
16
|
-
*/
|
17
|
-
@RunWith(RobolectricTestRunner::class)
|
18
|
-
class SliderHelperTest {
|
19
|
-
lateinit var slider: ReactSlider
|
20
|
-
lateinit var uut: SliderHelper
|
21
|
-
|
22
|
-
@Before
|
23
|
-
fun setup() {
|
24
|
-
slider = mock()
|
25
|
-
uut = SliderHelper.create(slider)
|
26
|
-
}
|
27
|
-
|
28
|
-
private fun givenNativeProgressTraits(current: Int, max: Int) {
|
29
|
-
whenever(slider.progress).doReturn(current)
|
30
|
-
whenever(slider.max).doReturn(max)
|
31
|
-
}
|
32
|
-
|
33
|
-
@Test
|
34
|
-
fun `should properly calculate current progress, in percentage`() {
|
35
|
-
givenNativeProgressTraits(current = 20, max = 100)
|
36
|
-
|
37
|
-
assertThat(uut.getCurrentProgressPct()).isEqualTo(0.2)
|
38
|
-
}
|
39
|
-
}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
const firstTestContent = require('./firstTestContent');
|
2
|
-
|
3
|
-
const mochaRcContent = JSON.stringify({
|
4
|
-
recursive: true,
|
5
|
-
timeout: 120000,
|
6
|
-
bail: true,
|
7
|
-
file: 'e2e/init.js',
|
8
|
-
}, null, 4);
|
9
|
-
|
10
|
-
const initjsContent = `const detox = require('detox');
|
11
|
-
const adapter = require('detox/runners/mocha/adapter');
|
12
|
-
|
13
|
-
before(async () => {
|
14
|
-
await detox.init();
|
15
|
-
});
|
16
|
-
|
17
|
-
beforeEach(async function () {
|
18
|
-
await adapter.beforeEach(this);
|
19
|
-
});
|
20
|
-
|
21
|
-
afterEach(async function () {
|
22
|
-
await adapter.afterEach(this);
|
23
|
-
});
|
24
|
-
|
25
|
-
after(async () => {
|
26
|
-
await detox.cleanup();
|
27
|
-
});
|
28
|
-
`;
|
29
|
-
|
30
|
-
exports.initjs = initjsContent;
|
31
|
-
exports.firstTest = firstTestContent;
|
32
|
-
exports.runnerConfig = mochaRcContent;
|
@@ -1,107 +0,0 @@
|
|
1
|
-
const _ = require('lodash');
|
2
|
-
|
3
|
-
const { resolveJestCliArgs } = require('./jestInternals');
|
4
|
-
const testCommandArgs = require('./testCommandArgs');
|
5
|
-
|
6
|
-
function extractKnownKeys(yargsBuilder) {
|
7
|
-
return Object.entries(yargsBuilder).reduce(
|
8
|
-
(set, [key, option]) => {
|
9
|
-
if (option.alias) {
|
10
|
-
if (Array.isArray(option.alias)) {
|
11
|
-
for (const value of option.alias) {
|
12
|
-
set.add(value);
|
13
|
-
}
|
14
|
-
} else {
|
15
|
-
set.add(option.alias);
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
return set.add(key);
|
20
|
-
},
|
21
|
-
new Set()
|
22
|
-
);
|
23
|
-
}
|
24
|
-
|
25
|
-
function disengageBooleanArgs(argv, booleanKeys) {
|
26
|
-
const result = {};
|
27
|
-
const passthrough = [];
|
28
|
-
|
29
|
-
for (const entry of Object.entries(argv)) {
|
30
|
-
const [key, value] = entry;
|
31
|
-
if (key === '_' || key === '--') {
|
32
|
-
continue;
|
33
|
-
}
|
34
|
-
|
35
|
-
const positiveKey = key.startsWith('no-') ? key.slice(3) : key;
|
36
|
-
if (booleanKeys.has(positiveKey) && typeof value !== 'boolean') {
|
37
|
-
result[positiveKey] = key === positiveKey;
|
38
|
-
passthrough.push(value);
|
39
|
-
} else {
|
40
|
-
result[key] = value;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
return {
|
45
|
-
specs: passthrough.concat(argv._),
|
46
|
-
passthrough: {
|
47
|
-
_: argv['--'] || [],
|
48
|
-
...result,
|
49
|
-
},
|
50
|
-
};
|
51
|
-
}
|
52
|
-
|
53
|
-
function getJestBooleanArgs() {
|
54
|
-
return _(resolveJestCliArgs())
|
55
|
-
.thru(args => args.options)
|
56
|
-
.pickBy(({ type }) => type === 'boolean')
|
57
|
-
.thru(extractKnownKeys)
|
58
|
-
.value();
|
59
|
-
}
|
60
|
-
|
61
|
-
function getMochaBooleanArgs() {
|
62
|
-
const metadata = require('mocha/lib/cli/run-option-metadata');
|
63
|
-
|
64
|
-
return _(metadata.types.boolean)
|
65
|
-
.flatMap(key => [key, ...(metadata.aliases[key] || [])])
|
66
|
-
.thru(keys => new Set(keys))
|
67
|
-
.value();
|
68
|
-
}
|
69
|
-
|
70
|
-
function splitDetoxArgv(argv) {
|
71
|
-
const aliases = extractKnownKeys(testCommandArgs);
|
72
|
-
const isDetoxArg = (_value, key) => aliases.has(key);
|
73
|
-
|
74
|
-
const detoxArgs = _.pickBy(argv, isDetoxArg);
|
75
|
-
const runnerArgs = _.omitBy(argv, isDetoxArg);
|
76
|
-
runnerArgs._ = runnerArgs._.slice(1); // omit 'test' string, as in 'detox test'
|
77
|
-
if (typeof detoxArgs['debug-synchronization'] === 'string') {
|
78
|
-
const erroneousPassthrough = detoxArgs['debug-synchronization'];
|
79
|
-
detoxArgs['debug-synchronization'] = 3000;
|
80
|
-
runnerArgs._.unshift(erroneousPassthrough);
|
81
|
-
}
|
82
|
-
|
83
|
-
return { detoxArgs, runnerArgs };
|
84
|
-
}
|
85
|
-
|
86
|
-
function splitMochaArgv(argv) {
|
87
|
-
return disengageBooleanArgs(argv, getMochaBooleanArgs());
|
88
|
-
}
|
89
|
-
|
90
|
-
function splitJestArgv(argv) {
|
91
|
-
return realiasJestArgv(disengageBooleanArgs(argv, getJestBooleanArgs()));
|
92
|
-
}
|
93
|
-
|
94
|
-
function realiasJestArgv({ specs, passthrough }) {
|
95
|
-
if (passthrough.hasOwnProperty('t')) {
|
96
|
-
passthrough.testNamePattern = passthrough.t;
|
97
|
-
delete passthrough.t;
|
98
|
-
}
|
99
|
-
|
100
|
-
return { specs, passthrough };
|
101
|
-
}
|
102
|
-
|
103
|
-
module.exports = {
|
104
|
-
detox: splitDetoxArgv,
|
105
|
-
jest: splitJestArgv,
|
106
|
-
mocha: splitMochaArgv,
|
107
|
-
};
|
package/runners/integration.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
lifecycle: {
|
3
|
-
onRunStart: Symbol('run_start'),
|
4
|
-
onRunDescribeStart: Symbol('run_describe_start'),
|
5
|
-
onTestStart: Symbol('test_start'),
|
6
|
-
onHookStart: Symbol('hook_start'),
|
7
|
-
onHookFailure: Symbol('hook_failure'),
|
8
|
-
onHookSuccess: Symbol('hook_success'),
|
9
|
-
onTestFnStart: Symbol('test_fn_start'),
|
10
|
-
onTestFnFailure: Symbol('test_fn_failure'),
|
11
|
-
onTestFnSuccess: Symbol('test_fn_success'),
|
12
|
-
onTestDone: Symbol('test_done'),
|
13
|
-
onRunDescribeFinish: Symbol('run_describe_finish'),
|
14
|
-
onRunFinish: Symbol('run_finish'),
|
15
|
-
},
|
16
|
-
};
|
@@ -1,60 +0,0 @@
|
|
1
|
-
const DetoxAdapter = require('./DetoxAdapterImpl');
|
2
|
-
const { getFullTestName, hasTimedOut } = require('./utils');
|
3
|
-
|
4
|
-
class DetoxAdapterCircus {
|
5
|
-
constructor(detox) {
|
6
|
-
this._adapter = new DetoxAdapter(detox, DetoxAdapterCircus._describeInitError);
|
7
|
-
}
|
8
|
-
|
9
|
-
static _describeInitError() {
|
10
|
-
return {
|
11
|
-
message: 'Detox adapter to Jest is malfunctioning.',
|
12
|
-
hint: `Make sure you register it as a test-event listener inside init.js:\n` +
|
13
|
-
`-------------------------------------------------------------\n` +
|
14
|
-
'detoxCircus.getEnv().addEventsListener(adapter);',
|
15
|
-
};
|
16
|
-
}
|
17
|
-
|
18
|
-
async beforeEach() {
|
19
|
-
await this._adapter.beforeEach();
|
20
|
-
}
|
21
|
-
|
22
|
-
async afterAll() {
|
23
|
-
await this._adapter.afterAll();
|
24
|
-
}
|
25
|
-
|
26
|
-
async run_describe_start({ describeBlock: { name, children } }, state) { // eslint-disable-line no-unused-vars
|
27
|
-
if (children.length) await this._adapter.suiteStart({ name });
|
28
|
-
}
|
29
|
-
|
30
|
-
async run_describe_finish({ describeBlock: { name, children } }, state) { // eslint-disable-line no-unused-vars
|
31
|
-
if (children.length) await this._adapter.suiteEnd({ name });
|
32
|
-
}
|
33
|
-
|
34
|
-
test_start(event) {
|
35
|
-
const { test } = event;
|
36
|
-
if (test.mode === 'skip' || test.mode === 'todo' || test.errors.length > 0) {
|
37
|
-
return;
|
38
|
-
}
|
39
|
-
|
40
|
-
this._adapter.testStart({
|
41
|
-
title: test.name,
|
42
|
-
fullName: getFullTestName(test),
|
43
|
-
status: 'running',
|
44
|
-
});
|
45
|
-
}
|
46
|
-
|
47
|
-
test_done(event) {
|
48
|
-
const { test } = event;
|
49
|
-
this._adapter.testComplete({
|
50
|
-
status: test.errors.length ? 'failed' : 'passed',
|
51
|
-
timedOut: hasTimedOut(test)
|
52
|
-
});
|
53
|
-
}
|
54
|
-
|
55
|
-
test_skip(event) { // eslint-disable-line no-unused-vars
|
56
|
-
// Ignored (for clarity)
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
module.exports = DetoxAdapterCircus;
|
@@ -1,81 +0,0 @@
|
|
1
|
-
const DetoxRuntimeError = require('../../src/errors/DetoxRuntimeError');
|
2
|
-
const log = require('../../src/utils/logger').child({ __filename });
|
3
|
-
|
4
|
-
class DetoxAdapterImpl {
|
5
|
-
constructor(detox, describeInitErrorFn) {
|
6
|
-
if (process.env.DETOX_RERUN_INDEX) {
|
7
|
-
log.warn(
|
8
|
-
'While Detox CLI supports "-R <N>, --retries <N>" mechanism, ' +
|
9
|
-
'this outdated Jest integration does not — expect artifacts issues. ' +
|
10
|
-
'Please migrate to the new Jest Circus integration.\n\n' +
|
11
|
-
'See: https://wix.github.io/Detox/docs/api/guide/jest\n');
|
12
|
-
}
|
13
|
-
|
14
|
-
this.detox = detox;
|
15
|
-
this._describeInitError = describeInitErrorFn;
|
16
|
-
this._currentTest = null;
|
17
|
-
this._todos = [];
|
18
|
-
}
|
19
|
-
|
20
|
-
async beforeEach() {
|
21
|
-
if (!this._currentTest) {
|
22
|
-
throw new DetoxRuntimeError(this._describeInitError());
|
23
|
-
}
|
24
|
-
|
25
|
-
const currentTest = this._currentTest;
|
26
|
-
|
27
|
-
await this._flush();
|
28
|
-
await this.detox.beforeEach(currentTest);
|
29
|
-
}
|
30
|
-
|
31
|
-
async afterAll() {
|
32
|
-
await this._flush();
|
33
|
-
}
|
34
|
-
|
35
|
-
async suiteStart({ name }) {
|
36
|
-
this._enqueue(() => this.detox.suiteStart({ name }));
|
37
|
-
}
|
38
|
-
|
39
|
-
async suiteEnd({ name }) {
|
40
|
-
this._enqueue(() => this.detox.suiteEnd({ name }));
|
41
|
-
}
|
42
|
-
|
43
|
-
testStart({ title, fullName, status }) {
|
44
|
-
this._currentTest = {
|
45
|
-
title,
|
46
|
-
fullName,
|
47
|
-
status,
|
48
|
-
};
|
49
|
-
}
|
50
|
-
|
51
|
-
testComplete({ status, timedOut }) {
|
52
|
-
if (this._currentTest) {
|
53
|
-
const _test = {
|
54
|
-
...this._currentTest,
|
55
|
-
status,
|
56
|
-
timedOut,
|
57
|
-
};
|
58
|
-
|
59
|
-
this._currentTest = null;
|
60
|
-
this._enqueue(() => this._afterEach(_test));
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
async _afterEach(previousTest) {
|
65
|
-
await this.detox.afterEach(previousTest);
|
66
|
-
}
|
67
|
-
|
68
|
-
_enqueue(fn) {
|
69
|
-
this._todos.push(fn);
|
70
|
-
}
|
71
|
-
|
72
|
-
async _flush() {
|
73
|
-
const t = this._todos;
|
74
|
-
|
75
|
-
while (t.length > 0) {
|
76
|
-
await Promise.resolve().then(t.shift()).catch(()=>{});
|
77
|
-
}
|
78
|
-
}
|
79
|
-
}
|
80
|
-
|
81
|
-
module.exports = DetoxAdapterImpl;
|
@@ -1,67 +0,0 @@
|
|
1
|
-
const _ = require('lodash');
|
2
|
-
|
3
|
-
const DetoxAdapter = require('./DetoxAdapterImpl');
|
4
|
-
|
5
|
-
class DetoxAdapterJasmine /* extends JasmineReporter */ {
|
6
|
-
constructor(detox) {
|
7
|
-
this._adapter = new DetoxAdapter(detox, DetoxAdapterJasmine._describeInitError);
|
8
|
-
}
|
9
|
-
|
10
|
-
static _describeInitError() {
|
11
|
-
return {
|
12
|
-
message: 'Detox adapter to Jest is malfunctioning.',
|
13
|
-
hint: `Make sure you register it as Jasmine reporter inside init.js:\n` +
|
14
|
-
`-------------------------------------------------------------\n` +
|
15
|
-
'jasmine.getEnv().addReporter(adapter);',
|
16
|
-
};
|
17
|
-
}
|
18
|
-
|
19
|
-
async beforeEach() {
|
20
|
-
await this._adapter.beforeEach();
|
21
|
-
}
|
22
|
-
|
23
|
-
async afterAll() {
|
24
|
-
await this._adapter.afterAll();
|
25
|
-
}
|
26
|
-
|
27
|
-
async suiteStarted(result) {
|
28
|
-
await this._adapter.suiteStart({ name: result.description });
|
29
|
-
}
|
30
|
-
|
31
|
-
async suiteDone(result) {
|
32
|
-
await this._adapter.suiteEnd({ name: result.description });
|
33
|
-
}
|
34
|
-
|
35
|
-
specStarted(result) {
|
36
|
-
if (result.pendingReason) {
|
37
|
-
return;
|
38
|
-
}
|
39
|
-
|
40
|
-
this._adapter.testStart({
|
41
|
-
title: result.description,
|
42
|
-
fullName: result.fullName,
|
43
|
-
status: 'running',
|
44
|
-
});
|
45
|
-
}
|
46
|
-
|
47
|
-
specDone(result) {
|
48
|
-
if (result.status === 'disabled' || result.pendingReason) {
|
49
|
-
return;
|
50
|
-
}
|
51
|
-
|
52
|
-
this._adapter.testComplete({
|
53
|
-
status: result.status,
|
54
|
-
timedOut: this._hasTimedOut(result),
|
55
|
-
});
|
56
|
-
}
|
57
|
-
|
58
|
-
_hasTimedOut(result) {
|
59
|
-
return _.chain(result.failedExpectations)
|
60
|
-
.map('error')
|
61
|
-
.compact()
|
62
|
-
.some(e => _.includes(e.message, 'Timeout'))
|
63
|
-
.value();
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
|
-
module.exports = DetoxAdapterJasmine;
|
@@ -1,98 +0,0 @@
|
|
1
|
-
// @ts-nocheck
|
2
|
-
const { VerboseReporter: JestVerboseReporter } = require('@jest/reporters'); // eslint-disable-line node/no-extraneous-require
|
3
|
-
|
4
|
-
const DetoxRuntimeError = require('../../src/errors/DetoxRuntimeError');
|
5
|
-
|
6
|
-
class DetoxStreamlineJestReporter extends JestVerboseReporter {
|
7
|
-
|
8
|
-
constructor(globalConfig) {
|
9
|
-
super(globalConfig);
|
10
|
-
this._assertConfig();
|
11
|
-
}
|
12
|
-
|
13
|
-
/**
|
14
|
-
* Monkey patch for _wrapStdio method of Jest's DefaultReporter class
|
15
|
-
* https://github.com/facebook/jest/blob/84466b7bb187d33ffd336bd9fc76111bba511fe6/packages/jest-reporters/src/default_reporter.ts#L47
|
16
|
-
*
|
17
|
-
* The official implementation does the following:
|
18
|
-
* - For the <b>stderr</b> stream, it overrides the 'write' method with a simple bulked output mechanism,
|
19
|
-
* which aggregates output onto a buffer but flushes it immediately.
|
20
|
-
* - For the <b>stdout</b> stream, it overrides the 'write' method with a time-based bulked output mechanism,
|
21
|
-
* which aggregates output onto a buffer and flushes only in 100ms intervals.
|
22
|
-
*
|
23
|
-
* This gives priority, to a certain extent, to stderr output, over stdout.
|
24
|
-
* See: https://github.com/facebook/jest/blob/84466b7bb187d33ffd336bd9fc76111bba511fe6/packages/jest-reporters/src/default_reporter.ts#L73
|
25
|
-
*
|
26
|
-
* Typically, user logs are sent to stdout, and Jest reporter's (e.g. test-suite summary) - to stderr.
|
27
|
-
*
|
28
|
-
* ---
|
29
|
-
* Our goal is to have these 3 types of output streamlined in real time:
|
30
|
-
*
|
31
|
-
* 1. Jest suite-level lifecycle logging, typically done by the super-class' impl.
|
32
|
-
* Note: Jest does not notify spec-level events to reporters.
|
33
|
-
* 2. Jasmine real-time, spec-level lifecycle logging.
|
34
|
-
* 3. User in-test logging (e.g. for debugging).
|
35
|
-
*
|
36
|
-
* It's easy to see that this cannot be done while stderr and stdout are not of equal priority.
|
37
|
-
* Therefore, this hack enforces immediate-flushing approach to <b>both</b> stderr and stdout.
|
38
|
-
*/
|
39
|
-
_wrapStdio(stream) {
|
40
|
-
const originalWrite = stream.write;
|
41
|
-
let buffer = [];
|
42
|
-
|
43
|
-
const flushBufferedOutput = () => {
|
44
|
-
const string = buffer.join('');
|
45
|
-
buffer = []; // This is to avoid conflicts between random output and status text
|
46
|
-
|
47
|
-
this._clearStatus();
|
48
|
-
|
49
|
-
if (string) {
|
50
|
-
originalWrite.call(stream, string);
|
51
|
-
}
|
52
|
-
|
53
|
-
this._printStatus();
|
54
|
-
|
55
|
-
this._bufferedOutput.delete(flushBufferedOutput);
|
56
|
-
};
|
57
|
-
|
58
|
-
this._bufferedOutput.add(flushBufferedOutput);
|
59
|
-
|
60
|
-
stream.write = chunk => {
|
61
|
-
buffer.push(chunk);
|
62
|
-
flushBufferedOutput();
|
63
|
-
return true;
|
64
|
-
};
|
65
|
-
}
|
66
|
-
|
67
|
-
_assertConfig() {
|
68
|
-
if (!this._isVerboseEnabled()) {
|
69
|
-
// Non-verbose mode makes Jest swizzle 'console' with a buffered output impl, which prevents
|
70
|
-
// user and detox' jasmine-lifecycle logs from showing in real time.
|
71
|
-
throw new DetoxRuntimeError({
|
72
|
-
message: 'Cannot run properly unless Jest is in verbose mode',
|
73
|
-
hint: 'See https://jestjs.io/docs/en/configuration#verbose-boolean for more details',
|
74
|
-
});
|
75
|
-
}
|
76
|
-
|
77
|
-
if (this._hasDefaultReporter()) {
|
78
|
-
// This class overrides Jest's VerboseReporter, which is set by default. Can't have both.
|
79
|
-
throw new DetoxRuntimeError({
|
80
|
-
message: 'Cannot work alongside the default Jest reporter. Please remove it from the reporters list.',
|
81
|
-
hint: 'See https://jestjs.io/docs/en/configuration#reporters-array-modulename-modulename-options for more details',
|
82
|
-
});
|
83
|
-
}
|
84
|
-
}
|
85
|
-
|
86
|
-
_isVerboseEnabled() {
|
87
|
-
return !!this._globalConfig.verbose;
|
88
|
-
}
|
89
|
-
|
90
|
-
_hasDefaultReporter() {
|
91
|
-
return !!this._globalConfig.reporters.find(reporterDef => {
|
92
|
-
const [reporterName] = reporterDef;
|
93
|
-
return reporterName === 'default';
|
94
|
-
});
|
95
|
-
}
|
96
|
-
}
|
97
|
-
|
98
|
-
module.exports = DetoxStreamlineJestReporter;
|
@@ -1,16 +0,0 @@
|
|
1
|
-
const path = require('path');
|
2
|
-
|
3
|
-
const { saveLastFailedTests } = require('../../src/utils/lastFailedTests');
|
4
|
-
|
5
|
-
class FailingTestsReporter {
|
6
|
-
async onRunComplete(_contexts, { testResults }) {
|
7
|
-
const cwd = process.cwd();
|
8
|
-
const failedFiles = testResults
|
9
|
-
.filter(result => result.numFailingTests > 0)
|
10
|
-
.map(result => path.relative(cwd, result.testFilePath));
|
11
|
-
|
12
|
-
await saveLastFailedTests(failedFiles);
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
|
-
module.exports = FailingTestsReporter;
|
@@ -1,51 +0,0 @@
|
|
1
|
-
const argparse = require('../../src/utils/argparse');
|
2
|
-
|
3
|
-
const SpecReporter = require('./SpecReporterImpl');
|
4
|
-
|
5
|
-
class SpecReporterCircus {
|
6
|
-
constructor() {
|
7
|
-
this._specReporter = new SpecReporter();
|
8
|
-
}
|
9
|
-
|
10
|
-
run_describe_start(event) {
|
11
|
-
if (event.describeBlock.parent !== undefined) {
|
12
|
-
this._specReporter.onSuiteStart({
|
13
|
-
description: event.describeBlock.name,
|
14
|
-
});
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
run_describe_finish(event) {
|
19
|
-
if (event.describeBlock.parent !== undefined) {
|
20
|
-
this._specReporter.onSuiteEnd();
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
|
-
test_start(event) {
|
25
|
-
const { test } = event;
|
26
|
-
this._specReporter.onTestStart({
|
27
|
-
description: test.name,
|
28
|
-
invocations: test.invocations,
|
29
|
-
});
|
30
|
-
}
|
31
|
-
|
32
|
-
test_done(event) {
|
33
|
-
const { test } = event;
|
34
|
-
const testInfo = {
|
35
|
-
description: test.name,
|
36
|
-
invocations: test.invocations,
|
37
|
-
};
|
38
|
-
this._specReporter.onTestEnd(testInfo, test.errors.length ? 'failed' : 'success');
|
39
|
-
}
|
40
|
-
|
41
|
-
test_skip(event) {
|
42
|
-
const testInfo = {
|
43
|
-
description: event.test.name,
|
44
|
-
};
|
45
|
-
this._specReporter.onTestEnd(testInfo, 'skipped');
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
module.exports = argparse.getArgValue('reportSpecs') === 'true'
|
50
|
-
? SpecReporterCircus
|
51
|
-
: class {};
|