Is there a good way to write automated tests for C...
# compose-web
c
Is there a good way to write automated tests for Compose Web? I see some resources mentioned for Compose Desktop but not sure where I might look for Web.
👍 2
o
We use Selenium for some tests of compose-web components. There are of course other tools to help with integration tests. But with Selenium we can use Kotlin. For some rather simple cases we use just kotlin/js tests. I'm not sure our setup of Selenium tests is the best example of testing web apps. https://github.com/JetBrains/compose-jb/tree/master/web/integration-core/src/jvmTest/kotlin/org/jetbrains/compose/web/tests/integration But it might give some direction.
c
Thank you, I’ll look into that example. So far I’m using plain kotlin-js tests for asserts for models, viewmodels, etc although I expect some of the UI itself will need more sophistication.
Also is there anything you’re using for coverage? Right now I’m putting as much as I can under commonMain and adding a jvm target and generating coverage reports with jacoco. But it leaves a gap for things under jsMaim.
o
You are right. When it comes to web UI tests some tools like Selenium, puppeteer or others could be used.
No, we didn't add anything for coverage yet. But it's a good thing to have of course. I'll need to think about it. The most of compose code is in jsMain, and i don't know how to measure its coverage so far
c
Thanks—I know things are early for Compose Web. Although I’ve been doing Kotlin on Android and the JVM for years, I’m a noob at what’s going on in Javascript so I don’t have as much knowledge to draw upon. Are you doing anything for screenshot automation? That would also help speed up testing, so a human can quickly review that things look OK.
o
Screenshot automation is also something we consider worth doing especially for widgets. Although we don't have it yet.
b
You could use jest for coverage. Although that needs source maps to be useful
🙏 1