Skip to content

Commit 0a8d4ad

Browse files
authored
Merge pull request #77 from diogocezar/dev
Incrementing README.md with Jest usage.
2 parents 40773e8 + ae7a2bd commit 0a8d4ad

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,19 @@ module.exports = {
145145

146146
More details on the [official documentation](https://webpack.js.org/configuration/resolve).
147147

148+
## Usage with Jest
149+
150+
Unfortunately, `module-alias` itself would not work from Jest due to a custom behavior of Jest's `require`. But you can use it's own aliasing mechanism instead. The configuration can be defined either in `package.json` or `jest.config.js`. The example below is for `package.json`:
151+
152+
```js
153+
"jest": {
154+
"moduleNameMapper": {
155+
"@root/(.*)": "<rootDir>/$1",
156+
"@client/(.*)": "<rootDir>/src/client/$1"
157+
},
158+
}
159+
```
160+
148161
## Known incompatibilities
149162

150163
This module does not play well with:

0 commit comments

Comments
 (0)