Jest test not running sequentially

Viewed 225

I would like to run my test in the below order:

Test1.test.js
Test2.test.js
Test3.test.js
Test4.test.js

But each run I'm getting different order, please find my files and config below - could you please help what am I missing here?

My folder structure

my-app/
├─ node_modules/
├─ tests/integration
│  ├─ Test1.test.js
│  ├─ Test2.test.js
│  ├─ Test3.test.js
│  ├─ Test4.test.js
├─ jest.config.js
├─ package.json
├─ package-lock.json

Test1.test.js

describe("Test-1", () => {
    test("Run Test-1", async () => {
    });

});

Note: I've similar code for Test2.test.js and so on.

jest.config.js

'use strict';

module.exports = {
    testMatch: [
        '**/integration/*.test.js'
    ]
};

package.json

{
  "name": "com.test.jest",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "jest -i"
  },
  "devDependencies": {
    "jest": "^26.6.3"
  },
  "author": "",
  "license": "asdf"
}

I tried below option too but no luck :(

  "scripts": {
    "test": "jest --runInBand"
  }

Test Output:

 PASS  tests/integration/Test1.test.js
 PASS  tests/integration/Test4.test.js
 PASS  tests/integration/Test2.test.js
 PASS  tests/integration/Test3.test.js

My expected order for each run is below one but I'm not getting in this order

 PASS  tests/integration/Test1.test.js
 PASS  tests/integration/Test2.test.js
 PASS  tests/integration/Test3.test.js
 PASS  tests/integration/Test4.test.js

It would be really appreciated if someone can help me to resolve this issue.

Thanks!

0 Answers
Related