Skip to content

Commit

Permalink
docs: fix broken link
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Jul 20, 2024
1 parent 6be0483 commit c742b39
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
52 changes: 52 additions & 0 deletions docs/docs/@fetch-mock/core/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
sidebar_position: 6
---

# Configuration

On any `fetch-mock` instance, set configuration options directly on the `fetchMock.config` object. e.g.

```js
const fetchMock = require('fetch-mock');
fetchMock.config.sendAsJson = false;
```

## Available options

Options marked with a `` can also be overridden for individual calls to `.mock(matcher, response, options)` by setting as properties on the `options` parameter

### sendAsJson<sup>†</sup>

`{Boolean}` default: `true`

Always convert objects passed to `.mock()` to JSON strings before building reponses. Can be useful to set to `false` globally if e.g. dealing with a lot of `ArrayBuffer`s. When `true` the `Content-Type: application/json` header will also be set on each response.

### includeContentLength<sup>†</sup>

`{Boolean}` default: `true`

Sets a `Content-Length` header on each response.

### matchPartialBody

`{Boolean}` default: `false`

Match calls that only partially match a specified body json. Uses the [is-subset](https://www.npmjs.com/package/is-subset) library under the hood, which implements behaviour the same as jest's [.objectContaining()](https://jestjs.io/docs/en/expect#expectobjectcontainingobject) method.

### Custom fetch implementations

`fetch`, `Headers`, `Request`, `Response` can all be set on the configuration object, allowing fetch-mock to mock any implementation of `fetch`, e.g. `node-fetch`. e.g.

```js

import { default as fetch, Headers, Request, Response } from 'node-fetch';

import fetchMock from 'fetch-mock';

fetchMock.config = Object.assign(fetchMock.config, {
Request,
Response,
Headers,
fetch,
});
```
2 changes: 1 addition & 1 deletion docs/docs/@fetch-mock/core/route/matcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ When matching a body, this option ignores any properties not mentioned in the ma
}
```

This option can also be [set in the global configuration](/dummy)
This option can also be [set in the global configuration](/fetch-mock/docs/@fetch-mock/core/configuration)

## Function matchers

Expand Down

0 comments on commit c742b39

Please sign in to comment.