Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify `random:true` through karma-jasmine

I'm having difficulty figuring out how/where to specify config data for Jasmine runs (which normally goes in a config file specified in Jasmine settings or through the loaded library). Specifically, I'm looking to set random:true through jasmine or karma-jasmine config.

Here the docs specify where you can add it in a config file, but I have not been able to integrate the two configuations (or tell jasmine as run through karma where to find a config file).

like image 649
Mishap Avatar asked Sep 26 '16 00:09

Mishap


People also ask

Does Jasmine run tests in order?

Currently (v2. x) Jasmine runs tests in the order they are defined.

Why do we use Karma and Jasmine?

We can run Jasmine tests in a browser ourselves by setting up and loading a HTML file, but more commonly we use a command-line tool called Karma. Karma handles the process of creating HTML files, opening browsers and running tests and returning the results of those tests to the command line.

What is Jasmine & karma?

Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests. Karma is a test runner that fits all our needs in the angular framework.


1 Answers

You can pass it through as client.jasmine in the configuration. The karma-jasmine docs say like so:

module.exports = function(config) {
  config.set({
    client: {
      jasmine: {
        random: true
      }
    }
  })
}

I have successfully used this via grunt-karma v2.0.0 with karma-jasmine v1.1.0. Annoyingly for me, grunt-karma isn't outputting the seed used each time, but I can see that the specs are randomised.

like image 51
Henry Blyth Avatar answered Sep 23 '22 01:09

Henry Blyth