// tsconfig.json
{
...
"baseUrl": "src",
"paths": {
"@alias/*": [ 'path/to/alias/*' ]
}
...
}
//then your jest.config.js needs to provide those paths in moduleNameMapper in the following format:
// jest.config.js
module.exports = {
'roots': [
'<rootDir>/src'
],
'transform': {
'^.+.tsx?$': 'ts-jest'
},
'moduleNameMapper': {
'@alias/(.*)': '<rootDir>/src/path/to/alias/$1'
}
};
//Example tsconfig.json
{
"baseUrl": "./",
"paths": {
"@/*": ["src/*"],
},
}
//Example jest.config.json
"moduleNameMapper": {
"@/(.*)": "<rootDir>/src/$1",
}