Skip to content

Commit 03267f9

Browse files
committed
Add missed docs
1 parent 83c452b commit 03267f9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/contributing/frontend.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,31 @@ user.click(screen.getByRole("button"))
166166
const form = screen.getByTestId("form")
167167
user.click(within(form).getByRole("button"))
168168
```
169+
170+
#### `jest.spyOn` with the API is not working
171+
172+
For some unkown reason, we figured out the `jest.spyOn` is not able to mock the API function when they are passed directly into the services XState machine configuration.
173+
174+
❌ Does not work
175+
176+
```ts
177+
import { getUpdateCheck } from "api/api"
178+
179+
createMachine({ ... }, {
180+
services: {
181+
getUpdateCheck,
182+
},
183+
})
184+
```
185+
186+
✅ It works
187+
188+
```ts
189+
import { getUpdateCheck } from "api/api"
190+
191+
createMachine({ ... }, {
192+
services: {
193+
getUpdateCheck: () => getUpdateCheck(),
194+
},
195+
})
196+
```

0 commit comments

Comments
 (0)