Skip to content

Commit

Permalink
Add more details on using module name mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
jeznag authored Jul 30, 2018
1 parent db590d2 commit 1e287f3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,27 @@ If you *have* explicitly set the `module` property but to a different value than

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.

For example, with the below config in your tsconfig:
```
"paths": {
"@App/*": [
"src/*"
],
"@Shared/*": [
"src/Shared/*"
]
},
```

Here's what your jest config should look like:

```
"moduleNameMapper": {
"@App/(.*)": "<rootDir>/src/$1",
"@Shared/(.*)": "<rootDir>/src/Shared/$1"
}
```

### Skipping Babel
If you don't use mocks, or synthetic default imports you can skip the babel-transpilation step.
This means `jest.mock()` calls will not be hoisted to the top,
Expand Down

0 comments on commit 1e287f3

Please sign in to comment.