Skip to content

Commit 918f3bf

Browse files
authored
Incrementing README.md with Jest usage.
Just inserted new section explaining how we can use this package with Jest.
1 parent 07a6b80 commit 918f3bf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,21 @@ module.exports = {
143143
}
144144
```
145145

146+
## Usage with Jest
147+
148+
If you use jest to test your application, you can structure this kind of configuration to run tests:
149+
150+
```
151+
"jest": {
152+
"moduleNameMapper": {
153+
"@root/(.*)": "<rootDir>/$1",
154+
"@client/(.*)": "<rootDir>/src/client/$1"
155+
},
156+
}
157+
```
158+
159+
Just put it on `package.json` or in yout `jest.config.js`
160+
146161
## How it works?
147162

148163
In order to register an alias it modifies the internal `Module._resolveFilename` method so that when you use `require` or `import` it first checks whether the given string starts with one of the registered aliases, if so, it replaces the alias in the string with the target path of the alias.

0 commit comments

Comments
 (0)