Corey Cole
Corey Cole

Reputation: 2432

Jest --runTestsByPath two or more different paths

I'm using the jest cli to run my tests. Jest has a cli option called --runTestsByPath that I'm using to specify where my tests are.

I have unit tests spread across my repository in different directories, but I want to run them all in one command. One option is to && different jest commands:

{
  "name": "node-project",
  "version": "0.0.0",
  "scripts": {
    "test": "jest --runTestsByPath ./__tests__/tests/over/here/*_test.ts && jest --runTestsByPath ./tests/over/__tests__/here/*_test.ts",
  },
  "devDependencies": {
    "jest": "24.8.0",
    "ts-jest": "24.0.2",
    "ts-node": "8.3.0",
    "typescript": "2.9.2"
  }
}

But, I then lose the functionality like coverage that I get from running them all from 1 jest command.

I'm wondering, because it is not documented anywhere, or answered here on SO, how can I pass two or more different paths to --runTestsByPath?

Upvotes: 4

Views: 4997

Answers (1)

Corey Cole
Corey Cole

Reputation: 2432

We can pass multiple paths to jests --runTestsByPath cli option:

jest --runTestsByPath ./__tests__/tests/over/here/*_test.ts ./tests/over/__tests__/here/*_test.ts

Upvotes: 3

Related Questions