首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用kotlin kotest瞄准js?

如何用kotlin kotest瞄准js?
EN

Stack Overflow用户
提问于 2021-02-24 22:08:30
回答 1查看 75关注 0票数 1

我一直在尝试在kotlin多平台项目中设置kotest。在kotest入门指南上,它说要将此依赖项添加到commonTest

代码语言:js
复制
implementation 'io.kotest:kotest-framework-engine:$version'

不幸的是,这不能解决

代码语言:javascript
复制
Could not resolve io.kotest:kotest-framework-engine:4.4.1.
Required by:
    project :**strong text**

如果仅将此依赖项添加到jvmTest它会解决的。我找不到任何指南来为多平台设置kotest。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-25 23:15:55

看起来kotest还不支持Kotlin编译器针对JS的IR后端。这是kotest issue 2037..。如果您为您的JS多平台设置配置了传统编译器后端,它应该可以工作。

Kotest's快速Start](https://kotest.io/docs/quickstart) 当您在每个部分中选择最右侧的选项卡(“多平台”)时,文档实际上涵盖了多平台配置。

这些是来自build.gradle.kts将kotest与JVM上的IR后端以及JS上的遗留后端一起使用的脚本:

代码语言:javascript
复制
val kotestVersion = "4.4.1"

kotlin {
    jvm("backend") {
        compilations.all {
            kotlinOptions.useIR = true
        }
        withJava()
    }
    js("frontend", LEGACY) {
        browser {
            binaries.executable()
            testTask {
                useKarma {
                    useChromeHeadless()
                    webpackConfig.cssSupport.enabled = true
                }
            }
        }
    }
    sourceSets {
        val commonTest by getting {
            dependencies {
                implementation("io.kotest:kotest-framework-engine:$kotestVersion")
                implementation("io.kotest:kotest-assertions-core:$kotestVersion")
                implementation("io.kotest:kotest-property:$kotestVersion")
            }
        }
        val backendTest by getting {
            dependencies {
                implementation("io.kotest:kotest-runner-junit5:$kotestVersion")
            }
        }
    }
}

tasks {
    // Tests
    withType {
        useJUnitPlatform()
    }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66352525

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档