问题 如何从Gradle运行JS Karma测试


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


11046
2018-03-11 21:00


起源



答案:


的package.json

"scripts": {
   "test-unit": "karma start test/unit/conf/karma.js"
}

的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

11
2018-06-03 09:41



这是没有gradle-node-plugin dep的另一种方法: stackoverflow.com/a/23116656/573389 - djKianoosh


答案:


的package.json

"scripts": {
   "test-unit": "karma start test/unit/conf/karma.js"
}

的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

11
2018-06-03 09:41



这是没有gradle-node-plugin dep的另一种方法: stackoverflow.com/a/23116656/573389 - djKianoosh