Skip to content

Commit 4396dde

Browse files
authoredJul 31, 2018
Merge pull request #641 from jeznag/patch-1
Add more details on using module name mapper
2 parents b38e4ca + 7d78123 commit 4396dde

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
 

‎README.md

+21
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)
Please sign in to comment.