With a child stack, what is the best way to genera...
# decompose
f
With a child stack, what is the best way to generate different components during tests? Below the child function references DefaultComponent, how do I get it to return a TestComponent?
Copy code
private fun child(
        config: AboutConfig,
        componentContext: ComponentContext
    ): AboutComponent.Child =
        when (config) {
            is AboutConfig.Main -> AboutComponent.Child.Main(
                DefaultAboutMainComponent(
                    componentContext = componentContext,
                    onBack = ::onBackClicked,
                    factory = koin::get
                )
            )
        }
a
First: create a test implementation of that component. Second: provide a factory function to the parent component via its constructor. Third: return the test component in your test. Here is an example: https://github.com/IlyaGulya/TodoAppDecomposeMviKotlin/blob/e8a6490f07882a11c6ee420aab2111810c82e061/common/root/src/commonTest/kotlin/example/todo/common/root/integration/TodoRootTest.kt#L28
f
Thankyou @Arkadii Ivanov legend!
🙌 1