jeudi 2 juin 2016

SBT exit on Failed Karma Tests

I have an angular app running on the Play framework. I have added in my Karma/Jasmine test suite and run it as part of "sbt test" with the following build.sbt config...

// run the angular JS unit tests (karma & jasmine)
lazy val jsTest = taskKey[Int]("jsTest")
jsTest in Test := {
    "test/js/node_modules/karma/bin/karma start karma.conf.js" !
}
test := Def.taskDyn {
    val exitCode = (jsTest in Test).value
    if (exitCode == 0)
    Def.task {
        (test in Test).value
    }
    else Def.task()
}.value

However if one of the tests fails, sbt does not seem to exit...

Chrome 50.0.2661 (Mac OS X 10.10.5): Executed 90 of 90 (1 FAILED) (0.512 secs / 0.453 secs)
[success] Total time: 3 s, completed 02-Jun-2016 12:11:13

After running sbt test I also run sbt dist and I don't want this to happen if any of the tests fail. I want sbt to exit if either the JS or scala tests fail.

Thanks!

Aucun commentaire:

Enregistrer un commentaire