Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document version added #548

Merged
merged 2 commits into from
May 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/_about/previous-versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Previous versions
position: 3
content_markdown: |-
v7, v8 & v9 are practically identical, only differing in their treatment of a few edge cases, or in compatibility with other libraries and environments.
v7, v8 & v9 are practically identical, only differing in their treatment of a few edge cases, or in compatibility with other libraries and environments. For clarity, each section of the documentation tells you which version a feature was added with a <small class="version-added">version</small> label.

For previous versions follow the documentation below:

Expand Down
1 change: 1 addition & 0 deletions docs/_api-inspection/called.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: .called(filter, options)
navTitle: .called()
position: 1
versionAdded: 1.0.0
description: |-
Returns a Boolean indicating whether any calls to `fetch` matched the given `filter` and `options`
---
1 change: 1 addition & 0 deletions docs/_api-inspection/calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: .calls(filter, options)
navTitle: .calls()
position: 2
versionAdded: 1.0.0
description: |-
Returns an array of all calls to fetch matching the given `filter` and `options`. Each call is returned as a `[url, options]` array. If `fetch` was called using a `Request` instance, the `url` and `options` will be inferred from it, and the original `Request` will be available as a `request` property on this array.
---
1 change: 1 addition & 0 deletions docs/_api-inspection/done.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: .done(filter)
navTitle: .done()
position: 6
versionAdded: 5.3.0
description: |-
Returns a Boolean indicating whether `fetch` was called the expected number of times (or has been called at least once if `repeat` is undefined for the route). It does not take into account whether the `fetches` completed successfully.
parameters:
Expand Down
13 changes: 11 additions & 2 deletions docs/_api-inspection/fundamentals.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ parameters:
options:
- types:
- undefined
versionAdded: 6.0.0
content: |-
Retrieve all calls made to `fetch`
- types:
- true
- '"matched"'
versionAdded: 6.0.0
content: |-
Retrieve all calls to `fetch` matched by some route defined by `fetch-mock`. The string `'matched'` can be used instead of `true` to make tests more readable
examples:
Expand All @@ -27,33 +28,41 @@ parameters:
fetchMock.calls(MATCHED)
- types:
- false
- '"unmatched"'
versionAdded: 6.0.0
content: |-
Retrieve all calls to `fetch` not matched by some route defined by `fetch-mock`. The string `'unmatched'` can be used instead of `false` to make tests more readable
examples:
- |-
const {UNMATCHED, fetchMock} = require('fetch-mock');
...
fetchMock.calls(UNMATCHED)
- types:
- '"matched"'
- '"unmatched"'
versionAdded: 9.0.0
content: Aliases for `true` and `false`
- name: routeIdentifier
types:
- String
- RegExp
- function
versionAdded: 2.0.0
content: |-
All routes have an identifier:
- If it's a [named route](#api-mockingmock_options), the identifier is the route's `name`
- If the route is unnamed, the identifier is the value of the `matcher` argument that was passed in to `.mock()`

All calls that were handled by the route with the given identifier will be retrieved
- name: matcher
versionAdded: 7.0.0
types:
- String
- RegExp
- function
content: |-
Any matcher compatible with the [mocking api](#api-mockingmock_matcher) can be passed in to filter the calls arbitrarily. The matcher will be executed using exactly the same rules as the mocking api
- name: options
versionAdded: 7.0.0
types:
- Object
- String
Expand Down
1 change: 1 addition & 0 deletions docs/_api-inspection/lastCall.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: .lastCall(filter, options)
navTitle: .lastCall()
position: 3
versionAdded: 4.0.0
description: |-
Returns the arguments for the last call to `fetch` matching the given `filter` and `options`. The call is returned as a `[url, options]` array. If `fetch` was called using a `Request` instance, the `url` and `options` will be inferred from it, and the original `Request` will be available as a `request` property on this array.
---
1 change: 1 addition & 0 deletions docs/_api-inspection/lastOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: .lastOptions(filter, options)
navTitle: .lastOptions()
position: 5
versionAdded: 4.0.0
description: |-
Returns the options for the call to `fetch` matching the given `filter` and `options`. If `fetch` was last called using a `Request` instance, a set of `options` inferred from the `Request` will be returned
---
1 change: 1 addition & 0 deletions docs/_api-inspection/lastUrl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: .lastUrl(filter, options)
navTitle: .lastUrl()
position: 4
versionAdded: 4.0.0
description: |-
Returns the url for the last call to `fetch` matching the given `filter` and `options`. If `fetch` was last called using a `Request` instance, the url will be inferred from this
---
1 change: 1 addition & 0 deletions docs/_api-lifecycle/flush.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: .flush(waitForBody)
navTitle: '.flush()'
position: 2
versionAdded: 5.11.0
description: |-
Returns a `Promise` that resolves once all fetches handled by fetch-mock have resolved
content_markdown: |-
Expand Down
1 change: 1 addition & 0 deletions docs/_api-lifecycle/resetBehavior.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: .resetBehavior()
position: 5
versionAdded: 7.0.0
description: |-
Removes all mock routes from the instance of `fetch-mock`, and restores `fetch` to its original implementation if movcking globally. Will not clear data recorded for `fetch`'s calls.
content_markdown: |-
Expand Down
1 change: 1 addition & 0 deletions docs/_api-lifecycle/resetHistory.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: .resetHistory()
position: 4
versionAdded: 7.0.0
description: |-
Clears all data recorded for `fetch`'s calls. It _will not_ restore fetch to its default implementation
content_markdown: |-
Expand Down
1 change: 1 addition & 0 deletions docs/_api-lifecycle/restore_reset.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: .restore(), .reset()
navTitle: .restore(), .reset()
position: 3
versionAdded: 7.0.0
description: |-
Resets `fetch()` to its unstubbed state and clears all data recorded for its calls. `restore()` is an alias for `reset()`
content_markdown: |-
Expand Down
1 change: 1 addition & 0 deletions docs/_api-lifecycle/sandbox.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: '.sandbox()'
position: 1.0
versionAdded: 5.6.0
description: |-
Returns a function that can be used as a drop-in replacement for `fetch`. Pass this into your mocking library of choice. The function returned by `sandbox()` has all the methods of `fetch-mock` exposed on it and maintains its own state independent of other instances, so tests can be run in parallel.
left_code_blocks:
Expand Down
16 changes: 0 additions & 16 deletions docs/_api-mocking/_defaults.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/_api-mocking/add-matcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: ".addMatcher({name, usesBody, matcher})"
navTitle: .addMatcher()
position: 1.9
versionAdded: 9.3.0
description: |-
Allows adding your own, reusable custom matchers to fetch-mock, for example a matcher for interacting with GraphQL queries, or an `isAuthorized` matcher that encapsulates the exact authorization conditions for the API you are mocking, and only requires a `true` or `false` to be input
parentMethodGroup: mocking
Expand Down
1 change: 1 addition & 0 deletions docs/_api-mocking/catch.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: '.catch(response)'
navTitle: .catch()
position: 8
versionAdded: 5.0.0
description: |-
Specifies how to respond to calls to `fetch` that don't match any mocks.
parentMethodGroup: mocking
Expand Down
1 change: 1 addition & 0 deletions docs/_api-mocking/getAnyOnce_postAnyOnce.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: '.getAnyOnce(), .postAnyOnce(), .putAnyOnce(), .deleteAnyOnce(), .headAnyOnce(), .patchAnyOnce()'
navTitle: .getAnyOnce(), .postAnyOnce() ...
position: 7
versionAdded: 9.2.0
description: |-
Shorthands for `anyOnce()` that only respond to requests using a particular http method.
parentMethodGroup: mocking
Expand Down
1 change: 1 addition & 0 deletions docs/_api-mocking/getAny_postAny.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: '.getAny(), .postAny(), .putAny(), .deleteAny(), .headAny(), .patchAny()'
navTitle: .getAny(), .postAny() ...
position: 5.5
versionAdded: 9.2.0
description: |-
Shorthands for `any()` that only respond to requests using a particular http method.
parentMethodGroup: mocking
Expand Down
1 change: 1 addition & 0 deletions docs/_api-mocking/getOnce_postOnce.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: '.getOnce(), .postOnce(), .putOnce(), .deleteOnce(), .headOnce(), .patchOnce()'
navTitle: .getOnce(), .postOnce() ...
position: 4
versionAdded: 5.3.0
description: |-
Shorthands for `mock()` that create routes that only respond to requests using a particular http method, and that can only mock a single request.
parentMethodGroup: mocking
Expand Down
1 change: 1 addition & 0 deletions docs/_api-mocking/get_post.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: '.get(), .post(), .put(), .delete(), .head(), .patch()'
navTitle: .get(), .post() ...
position: 2
versionAdded: 5.0.0
description: |-
Shorthands for `mock()` that create routes that only respond to requests using a particular http method.
parentMethodGroup: mocking
Expand Down
5 changes: 5 additions & 0 deletions docs/_api-mocking/mock.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: '.mock(matcher, response, options)'
navTitle: .mock()
position: 1
versionAdded: 2.0.0
versionAddedDetails: Callable with no arguments since v7.6.0
description: |
Check out the new [cheatsheet](https://github.com/wheresrhys/fetch-mock/blob/master/docs/cheatsheet.md)
{: .info}
Expand All @@ -12,13 +14,15 @@ description: |
{: .warning}
parameters:
- name: matcher
versionAdded: 2.0.0
types:
- String
- Regex
- Function
- Object
content: Criteria for which calls to `fetch` should match this route
- name: response
versionAdded: 2.0.0
types:
- String
- Object
Expand All @@ -27,6 +31,7 @@ parameters:
- Response
content: Response to send when a call is matched
- name: options
versionAdded: 2.0.0
types:
- Object
content: More options to configure matching and responding behaviour
Expand Down
1 change: 1 addition & 0 deletions docs/_api-mocking/mock_any.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: '.any(response, options)'
navTitle: .any()
position: 5
versionAdded: 9.2.0
description: |-
Shorthand for `mock()` which creates a route that will return a response to any fetch request.
parentMethodGroup: mocking
Expand Down
1 change: 1 addition & 0 deletions docs/_api-mocking/mock_any_once.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: '.anyOnce(response, options)'
navTitle: .anyOnce()
position: 6
versionAdded: 9.2.0
description: |-
Shorthand for `mock()` which creates a route that will return a response to any single fetch request.
parentMethodGroup: mocking
Expand Down
Loading