Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run JS Karma tests from Gradle

I am trying to add a Gradle task to my project to run Karma tests. The tests have been run manually from command line so far. I found a Gradle JS plugin but it doesn't seem to have Karma integration. Any solution besides executing them from a command?

like image 770
Giovanni Botta Avatar asked Mar 11 '14 21:03

Giovanni Botta


1 Answers

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
like image 90
sergiu Avatar answered Oct 11 '22 10:10

sergiu