Typescript paths not resolving when running jest?

I wanted to resolve modules paths starting with ~/ to my <baseUrl>/<moduleName>.

Thank to OJ Kwon link I solved it with (give him point).

tsconfig.json

see module-resolution path-mapping doc

{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "~/*": ["*"]
    }
  },
}

jest config

Then we need to tell jest to resolve the paths too. It’s done with the following config:

"moduleNameMapper": {
  "~/(.*)": "<rootDir>/src/$1"
},

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)