https://kotlinlang.org logo
Title
m

Mikhail Buzuverov

05/05/2021, 3:52 AM
Hello all! Could you let me a bit more details about running kotest in multiplatform project (JVM + JS)? According documentation I added into build.gradle.kts:
val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
                implementation("io.kotest:kotest-framework-engine:$kotestVersion") //<< This dependency
            }
        }
And wrote test:
class OperationResultSerializationTest: FunSpec({

    val json = Json {
        serializersModule = SerializersModule {
            polymorphic(Any::class) {
                subclass(TestPayload::class)
            }
        }
    }

    test("success action result should be serialized and deserialized") {
        val actionSuccessJson = json.encodeToString<ActionResult>(ActionSuccess)
        val actionSuccessDeserialized = json.decodeFromString<ActionResult>(actionSuccessJson)

        actionSuccessDeserialized shouldBe null //<<Should FAIL here (intentionally)
    }
})
But when I run it using gradlew check I get in IDEA just row:
It looks like my test haven't been executed at all. If I add
kotest-runner-junit5
dependency then server tests executed (and this test fails as expected). But how can I execute common tests in JS platform?
s

sam

05/05/2021, 11:04 AM
You should be able to use the gradle tasks to execute "check"
Hmmm that's what you've done. Can you try adding the
io.kotest:kotest-framework-engine-js:version
dependency to the jsTest sourceset? It shouldn't be needed but ...
a

Ashish Kumar Joy

05/05/2021, 1:01 PM
Are you using IR backend for JS?
m

Mikhail Buzuverov

05/05/2021, 1:02 PM
Yes, I use IR compiler, because legacy have bug in serialization
a

Ashish Kumar Joy

05/05/2021, 1:03 PM
m

Mikhail Buzuverov

05/05/2021, 1:04 PM
Oh. Thank you.
s

sam

05/05/2021, 1:04 PM
@Ashish Kumar Joy can you try 4.5 final ?
a

Ashish Kumar Joy

05/05/2021, 1:04 PM
sure
s

sam

05/05/2021, 1:04 PM
and if that fails, I'm doing a PR atm for kotlin 1.5 which might help
a

Ashish Kumar Joy

05/05/2021, 1:14 PM
Same result with 4.5.0
Just merged that. So if you want to take the next snapshot and try ?
Would be 4.6.0.224-SNAPSHOT
a

Ashish Kumar Joy

05/05/2021, 2:23 PM
Still same result with the above snapshot version
s

sam

05/05/2021, 2:25 PM
hmmm how weird
any ideas ?
a

Ashish Kumar Joy

05/05/2021, 2:47 PM
No idea why js test are not getting register/discovered.
s

sam

05/05/2021, 3:41 PM
I wonder if in IR js they changed the way the compiler discovers tests
in standard it looks for tests annotated with @JsTest or something, can't remember what I did now