Is there a way to run tests with `androidx.compose...
# compose-desktop
m
Is there a way to run tests with
androidx.compose.ui.test
visible (so that I can see them)? I’m having trouble with something and it would help to be able to see the UI as the test is trying to execute.
🔥 1
a
We don’t have a public API for that at the moment, but you can grab the source of our internal test API from androidx.compose.ui.window.TestUtils and use that.
It’s a very bare-bones API though - it doesn’t have the event dispatching or node-finding APIs.
m
Thank you very much. I’ll check that out 👍
Where can I get the source for this? Is it publicly accessible or only for internal JetBrains use? I can’t seem to find it via Google anywhere.
a
Turns out I was wrong and, as I think you found, we do have an experimental testing API.
g
I have same question. Could you clarify how androidx.compose.ui.window.TestUtils can be used to show the window? will be even more happy for an example. Currently I have something like this
Copy code
class FilePickTest {

	@get:Rule
	val rule = createComposeRule()

	@Test
	fun blah() {
		rule.setContent {
			Button(onClick = {
				println("button clicked")
			}) {
				Text("print stuff")
			}
		}

		rule.onNodeWithText("print stuff").performClick()
		runBlocking { delay(5_000) }
	}
}
I'd like to see the button and if possible interact with it
a
You can’t. The test API draws into an offscreen buffer. There’s no actual window involved.