You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ui/src/views/installation.mdx
+136Lines changed: 136 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -152,6 +152,142 @@ In the tsconfig.json you can add the config options next to the transformer name
152
152
]
153
153
```
154
154
155
+
## `jest` + `ts-jest` + `ts-patch`
156
+
157
+
### Steps
158
+
159
+
1. Install the dependencies
160
+
161
+
```
162
+
npm install jest ts-jest typescript ts-patch jest-ts-auto-mock ts-auto-mock
163
+
```
164
+
165
+
you need to have `ts-patch` installed to patch and enable the TypeScript-runtime to apply the transformer.
166
+
167
+
2. Add the transformer to your `tsconfig.json`
168
+
169
+
```json
170
+
...
171
+
"compilerOptions": {
172
+
...
173
+
"plugins": [0
174
+
{
175
+
"transform": "ts-auto-mock/transformer",
176
+
"cacheBetweenTests": false
177
+
}
178
+
]
179
+
...
180
+
}
181
+
...
182
+
```
183
+
184
+
- Remember to set `cacheBetweenTests` to `false` because Jest runs tests in parallel and ts-auto-mock doesn't yet support caching across parallel tests
185
+
186
+
- You can find a JSON example [here](https://github.com/Typescript-TDD/jest-ts-auto-mock/blob/master/examples/ts-jest-ttypescript/tsconfig.json)
187
+
188
+
3. Add `ts-jest` to the transformation pattern in the Jest config
189
+
190
+
#### **`package.json` / `jest.config.js` (without the `jest` scope)**
191
+
```json
192
+
...
193
+
"jest": {
194
+
"transform": {
195
+
".(ts|tsx)": "ts-jest"
196
+
}
197
+
}
198
+
...
199
+
```
200
+
201
+
- You can find a JSON example [here](https://github.com/Typescript-TDD/jest-ts-auto-mock/blob/master/examples/ts-jest-ttypescript/package.json)
202
+
203
+
4. Add `ts-patch install` to your prepare script in the package json
204
+
205
+
#### **`package.json`**
206
+
```json
207
+
...
208
+
"scripts": {
209
+
...,
210
+
"prepare": "ts-patch install -s",
211
+
...
212
+
}
213
+
...
214
+
```
215
+
- You can find a JSON example [here](https://github.com/Typescript-TDD/jest-ts-auto-mock/blob/master/examples/ts-jest-ts-patch/package.json#L9)
216
+
217
+
5. Add `jest-ts-auto-mock` config file as your setup file
218
+
219
+
#### **`package.json` / `jest.config.js` (without the `jest` scope)**
0 commit comments