karma-jasmine icon indicating copy to clipboard operation
karma-jasmine copied to clipboard

Issue with random flag

Open alexboisselle-rd opened this issue 6 years ago • 2 comments

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 avatar Feb 28 '18 21:02 alexboisselle-rd

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

alexboisselle-rd avatar Mar 23 '18 18:03 alexboisselle-rd

What jasmine version are you using?

fadc80 avatar Jun 22 '18 09:06 fadc80