How to make karma.js crash on test fail?

I am looking for a way to make karma.js crash when my tests fail so that my build process gets interrupted since that is easier to monitor in a remote building server.

I am using mocha as a reporter and jasmine as the test processor engine.

Is there any option or particular variable in the karma.conf.js file maybe that would allow me to "crash on test fail"

Upvotes: 0

Views: 507

Answers (3)

Louis
Louis

Reputation: 151561

There is no need for a "crash on failure".

Your build process should check the exit code of the Karma process that it launches. If all test pass, the code will be 0. If there is a test failure, the code will be non-zero. (I've just checked and it was 1 when I tried.)

Upvotes: 3

vpsingh016
vpsingh016

Reputation: 703

you can use grunt as automation tool to run your karma test case so that whenever any grunt job(test case) failed it will by default stop execution.

Upvotes: 0

Tom
Tom

Reputation: 2641

You may be able to get a plugin for karma for your build server that will report the results of your tests.

For example, there's a plugin for karma/teamcity (karma-teamcity-reporter) which allows you to fail the build step, preventing the application from publishing if you have it set up that way.

Upvotes: 1

Related Questions