I am currently working on setting up Jest in a TypeScript project.
In our tsconfig.json file, we are using path aliases like so:
"baseUrl": ".",
"paths": {
"@eddystone-shared/*": [ "../shared/*" ],
"@eddystone-firebase-helpers/*": [ "src/helpers/firebase-helpers/*" ],
"@eddystone-func-config": ["src/config/config"],
These aliases function as follows:
- Referencing all files in the parent directory.
- Referencing all files in the src subdirectory.
- Referencing one specific file.
I have come across information on Jest's GitHub stating that the Jest moduleNameMapper
is the configuration to use for this. I have attempted to convert it like this:
"moduleNameMapper": {
"^@eddystone-shared/(.*)$": "<rootDir>../shared/$1",
"^@eddystone-firebase-helpers/(.*)$": "<rootDir>/src/helpers/firebase-helpers/$1",
"^@eddystone-func-config/(.*)$": "<rootDir>/src/config/config",
However, I am encountering issues specifically with the @eddystone-func-config
alias. So, my question is: How can I create a moduleNameMapper
entry for a specific file?