如何从Gradle运行JS Karma测试

Gio*_*tta 11 javascript gradle karma-runner

我正在尝试将Gradle任务添加到我的项目中以运行Karma测试.到目前为止,测试已从命令行手动运行.我发现了一个Gradle JS插件,但似乎没有Karma集成.除了从命令执行它们之外的任何解决方案

小智 11

的package.json

"scripts": {
   "test-unit": "karma start test/unit/conf/karma.js"
}
Run Code Online (Sandbox Code Playgroud)

的build.gradle

apply plugin: 'node'

buildscript {
    dependencies {
        classpath 'com.moowork.gradle:gradle-node-plugin:0.4'
    }
}



// javascript unit testing
task testUnit(type: NpmTask) {
    args = ['run', 'test-unit']

}
//include js unit tests into project build lifecycle
test.dependsOn testUnit
Run Code Online (Sandbox Code Playgroud)