8

I'm using the following jest.unittest.json file (used via jest --config option):

{
  "bail": false,
  "verbose": true,
  "transform": {
    "^.+\\.(ts|tsx)$": "typescript-babel-jest"
  },
  "testPathIgnorePatterns": [
    "<rootDir>/lib",
    "<rootDir>/lib_es6",
    "/node_modules/",
    "fixtures.ts",
    "/fixtures/"
  ],
  "moduleFileExtensions": [
    "js", "jsx", "ts", "tsx", "node"
  ],
  "roots": [
    "<rootDir>/src/__unittests__/Logger",
    "<rootDir>/src/__unittests__/Renderer/renderer.test.ts"
  ],
  "testRegex": "<rootDir>/src/__unittests__/.*\\.test.(ts|tsx|js|jsx)$"
}

Note the test files are src/unittests/Renderer/renderer.test.ts, and so on.

It used to work until jest v19, but after upgrading to v20, this config no longer works.

When I do jest --config jest.unittest.json --verbose, I get:

Pattern: "" - 0 matches

Is there anything wrong with my config?

Dev Doomari
  • 943
  • 10
  • 19

2 Answers2

0

Try to change testRegex to something like that:

"(/src/__unittests__/.*|\\.(test|spec))\\.(ts|tsx|js)$"

Max
  • 404
  • 2
  • 17
  • 39
0

I'd say it's interesting, that you configure 2 roots and use only one path in your testRegex. Also in the documentation they catch the path and the file name without extension, which is not the way you do it. Catch the path and filename with the parenthesis. See the documentation there (I'd skip <rootDir> too as you probably want to use both roots): https://jestjs.io/docs/configuration#testregex-string--arraystring

Janos Vinceller
  • 1,208
  • 11
  • 25