configure jasmine to not run tests randomly

Viewed 12304

i just upgraded to jasmine 3.3 and now my tests by default run in random order. Is there a way to configure karma and jasmine to make tests run like they used to before upgrading to this new version?

2 Answers

A well-written unit test case should provide the same result independent of its execution order. However, We can change the execution order of Jasmine

Example 1- Add command line flag if you are just using Jasmine

jasmine test/sample.test.js  --random=false //global installation 
npx jasmine test/sample.test.js  --random=false //local installation

Example 2- with karma add this to your config object.

 module.exports = function (config) {
   config.set({
    client:{
      jasmine:{
       random:false
     }
   },
  // rest of karma configuration goes here 
  
};

//tested with karma 6.3.4 and jasmine v3.8.0

Related