karma-runner / karma-jasmine

A Karma plugin - adapter for Jasmine testing framework.
MIT License
541 stars 163 forks source link

Issue with random flag #194

Open alexboisselle-rd opened 6 years ago

alexboisselle-rd commented 6 years ago

Currently using 1.1.1

When setting the random flag to false in the karma conf file:

 client: {
      jasmine: {
        random: false
      }
    }

The createStartFn function in adapter.js (pasted below) fails because jasmineEnv.randomizeTests is not defined. The function isn't predicted to call a randomizer, however the issue is the function is throwing errors since I used "false" (boolean) in as the flag value and we're only validating against "null" (object) and for some reason JS is allowing the "set(option)" to run, although set is undefined, therefor throwing errors.

When using "null" or "undefined", the we get random executing again, meaning the flag didn't work.

Perhaps I'm missing something, any hint would be great.

function createStartFn (karma, jasmineEnv) {

  return function () {
    var clientConfig = karma.config || {}
    var jasmineConfig = clientConfig.jasmine || {}

    jasmineEnv = jasmineEnv || window.jasmine.getEnv()

    setOption(jasmineConfig.stopOnFailure, jasmineEnv.throwOnExpectationFailure)
    setOption(jasmineConfig.seed, jasmineEnv.seed)
    setOption(jasmineConfig.random, jasmineEnv.randomizeTests)

    jasmineEnv.addReporter(new KarmaReporter(karma, jasmineEnv))
    jasmineEnv.execute()
  }

  function setOption (option, set) {
    if (option != null) {
      set(option)
    }
  }
}
alexboisselle-rd commented 6 years ago

bump any word on this? It's a hinder to the workflow.

fadc80 commented 6 years ago

What jasmine version are you using?