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: docs/src/content/docs/fetch-mockers/creating-fetch-mocker.mdx
+60-62
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,13 @@ title: Creating a Fetch Mocker
3
3
description: Learn how to create a fetch mocker to mock the fetch() function
4
4
---
5
5
6
-
A *fetch mocker* in Mentoss is how you create a mocked version of a `fetch()` function. Fetch mockers are used to intercept calls to `fetch()` and return responses that you've defined in your mock servers. This allows you to test your code without making real network requests.
6
+
A _fetch mocker_ in Mentoss is how you create a mocked version of a `fetch()` function. Fetch mockers are used to intercept calls to `fetch()` and return responses that you've defined in your mock servers. This allows you to test your code without making real network requests.
7
7
8
8
## Create a new `FetchMocker` instance
9
9
10
10
To get started, import the `FetchMocker` class and create a new instance. The only argument is an object with the following properties:
11
11
12
-
*`servers` (required) - an array of `MockServer` instances to use for mocking fetch requests
12
+
-`servers` (required) - an array of `MockServer` instances to use for mocking fetch requests
@@ -74,44 +73,43 @@ In this example, the `fetch()` function is extracted from the `mocker` instance
74
73
75
74
If you want to mock the global `fetch()` function, you can use the `mockGlobal()` and `unmockGlobal()` methods provided by the fetch mocker. Here's an example:
0 commit comments