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"
},