user220409
user220409

Reputation: 184

incorrect test execution queue

// file.spec.js
describe('[test]', () => {
    it('first', () => {
        expect(true).toBeTruthy();
    });
    it('second', () => {
        expect(true).toBeTruthy();
    });
});

in file.spec.js -> ctrl + S (first save):

[test]
   first
   second

in file.spec.js -> ctrl + S (second save):

[test]
   second
   first

Is it normal that the test execution queue is broken?

UPD:0.0.1

part package.json with version libraries-
part package.json with version libraries- part package.json with version libraries- part package.json with version libraries-

{
  "devDependencies": {
    "@types/enzyme": "^3.1.9",
    "@types/enzyme-adapter-react-16": "^1.0.2",
    "@types/jasmine": "^2.8.6",
    "@types/react": "^16.1.0",
    "@types/react-redux": "^5.0.15",
    "@types/redux": "^3.6.0",
    "awesome-typescript-loader": "^5.0.0-1",
    "cross-env": "^5.1.4",
    "css-loader": "^0.28.11",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "html-webpack-plugin": "^3.1.0",
    "jasmine": "^3.1.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^2.0.0",
    "karma-chrome-launcher": "^2.2.0",
    "karma-jasmine": "^1.1.1",
    "karma-jasmine-html-reporter": "^1.0.0",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-spec-reporter": "0.0.32",
    "karma-webpack": "^4.0.0-beta.0",
    "node-sass": "^4.8.3",
    "object-assign": "^4.1.1",
    "sass-loader": "^6.0.7",
    "style-loader": "^0.20.3",
    "typescript": "^2.8.1",
    "webpack": "^4.4.1"
  }
}

Upvotes: 0

Views: 58

Answers (3)

jay rangras
jay rangras

Reputation: 144

Update package

karma-jasmine:"^2.0.1"

and update your karma.conf.js.

client:{
  jasmine: {
    random: false // disable the random running order
  }
},

Upvotes: 0

TraxX
TraxX

Reputation: 382

Before I'm using the latest version of jasmine-core and I also found that the execution was not in order and after a day or two, I found out the it was because of the jasmine version. Now my jasmine version is 2.3.4 and it executes the tests in order. There is a downside to this approach.

You can't use the other benefits of future versions like toBeGreaterThanOrEqual or other availableMatchers that jasmine provides out-of-the-box. Although you can create your own jasmine matchers, there are more other functionalities that they can add. Who knows what are those right?

So if you want your tests to be in order then feel free to use version 2.3.4 (I'm using this one along with karma-spec-reporter and tweak a bit) or if not, you can use the latest version.

Upvotes: 1

Alexander Elgin
Alexander Elgin

Reputation: 6965

Yes. Your test cases should be independent. Their results should not depend on the execution order

Upvotes: 1

Related Questions