Skip to content

Commit 1e287f3

Browse files
authored
Add more details on using module name mapper
1 parent db590d2 commit 1e287f3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,27 @@ If you *have* explicitly set the `module` property but to a different value than
168168

169169
If you use ["baseUrl"](https://www.typescriptlang.org/docs/handbook/module-resolution.html) and "paths" options for the compiler, see ["moduleNameMapper"](https://facebook.github.io/jest/docs/en/configuration.html#modulenamemapper-object-string-string) option on Jest docs.
170170

171+
For example, with the below config in your tsconfig:
172+
```
173+
"paths": {
174+
"@App/*": [
175+
"src/*"
176+
],
177+
"@Shared/*": [
178+
"src/Shared/*"
179+
]
180+
},
181+
```
182+
183+
Here's what your jest config should look like:
184+
185+
```
186+
"moduleNameMapper": {
187+
"@App/(.*)": "<rootDir>/src/$1",
188+
"@Shared/(.*)": "<rootDir>/src/Shared/$1"
189+
}
190+
```
191+
171192
### Skipping Babel
172193
If you don't use mocks, or synthetic default imports you can skip the babel-transpilation step.
173194
This means `jest.mock()` calls will not be hoisted to the top,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy