I'm trying to write Scenario() with composeTestRule in Kaspresso, but I get an error:
Test not setup properly. Use a ComposeTestRule in your test to be able to interact with composables
My scenario for example:
class FillOtp(
) : Scenario() {
override val steps: TestContext<Unit>.() -> Unit = {
val baseTest = BaseTest()
step("Write 0000") {
baseTest.composeTestRule
.onNodeWithTag("test")
.performClick()
MyScreen {
pinEdit {
typeText("0000")
}
continueBtn.click()
}
}
}
}
}
But I have added composeTestRule in BaseTest() class. And composeTestRule works successfully in tests without Scenario()
could you help me solve the problem ?
On another site I was offered the answer:
You can pass it to the constructor from the test:
class MyScenario(semanticsProvider: SemanticsNodeInteractionsProvider) : Scenario() {
override val steps: TestContext<Unit>.() -> Unit = {
semanticsProvider.onNode(...)
}
}
And in test:
scenario(MyScenario(composeTestRule))