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?

2 Answers 2

0

Try to change testRegex to something like that:

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.