jest aliases typescript storybook

The solution for “jest aliases typescript storybook” can be found here. The following code will assist you in solving the problem.

// 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’: [
/src’
],
‘transform’: {
‘^.+\\.tsx?$’: ‘ts-jest’
},
‘moduleNameMapper’: {
‘@alias/(.*)’: ‘/src/path/to/alias/$1′
}
};

//Example tsconfig.json
{
“baseUrl”: “./”,
“paths”: {
“@/*”: [“src/*”],
},
}

//Example jest.config.json
“moduleNameMapper”: {
“@/(.*)”: “/src/$1″,
}

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in