WasmJs Unit testing What is the status of unit te...
# webassembly
a
WasmJs Unit testing What is the status of unit testing on WasmJs? I have a WasmJs only project and unit tests didn’t work out the box (KMP wizard). By accident I found a Karma config snippet in Jetpack Compose project that enabled them, but breakpoints and clear method call traces are still not supported.
a
@Ilya Goncharov [JB] ^^
i
Hi, tI have checked and in 2.0.20 it is going to be fixed and tests could be run as expected. Breakpoints are feature of IDE, and it takes a while (maybe @Artem Kobzar you know about it) As for stack traces, it is still not supported, we need some time to understand how it should be done correctly
1
👍 2
c
Is there any special configuration needed with 2.0.20? I’m using the RC and I’m seeing the wasmJs tests hang with:
Copy code
client-view-model-lib:wasmJsBrowserTest > 06 08 2024 10:20:06.793:INFO [Chrome Headless 127.0.6533.89 (Mac OS 10.15.7)]: Connected on socket GyV0EfzpbfyfnUjGAAAB with id 92026954 > 0 tests completed
Before it finally times out
Copy code
> Task :client-view-model-lib:wasmJsBrowserTest
Disconnected (0 times) , because no message in 30000 ms.
i
Hm, I tested with new project from KMP wizard, and it works Could you please share your project?
c
wasmJs tests work in some modules, but fails in others in the same project. The main difference I can discern in the modules that fail is application of the Compose and Compose Compiler plugins. The module I’m looking at right now is mostly ViewModels, although there are some Compose factory functions. None of these factory methods are tested in the automated tests though. As part of a large multi-module project, it will take some doing to distill down something that I can share.
i
Which versions of compose do you use?
c
Copy code
1.7.0-alpha02
i
Hm, strange it works for me. Previously the error was because Karma does not consider all output files of webpack, which is used to bundle full application. So maybe try
clean
all
build
folders. And maybe you have directories
karma.config.d
or
webpack.config.d
?
c
Deleting build folders does not make a difference. There’s no config directory for karma or webpack. Let me see if I can narrow it down with an example and get back to you
🙏 1
min-repro.zip
This is a stripped down project that reproduces the issue
i
So we investigated the case. The problem is with transitive dependency
skiko
version
0.8.4
. It has problem with import function
AreMetricsLinear
. It is already fixed in new skiko 0.8.9. We can see dependency
Copy code
api(libs.androidx.lifecycle.viewmodel.compose)
It has transitive dependency on
org.jetbrains.compose.ui:ui
and based on it, skiko is added. So you can either add explicit dependency on
skiko
implementation("org.jetbrains.skiko:skiko-wasm-js:0.8.9")
onto
wasmJsMain
or you can just explicit add dependency on
org.jetbrains.compose.ui:ui:1.7.0-alpha02
I think it should be fixed with release of new viewmodel with transitive dependency on new
ui
c
Thank you. I added an explicit dependency to
org.jetbrains.compose.ui:ui:1.7.0-alpha02
which resolved this issue and avoids the stall of tests that I was experiencing.
K 1