fetch-mock
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -1,1 +0,1 @@ | ||
{"name":"fetch-mock","version":"2.2.0","description":"Mock http requests made using fetch (or isomorphic-fetch)","main":"server.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"https://github.com/wheresrhys/fetch-mock.git"},"keywords":["fetch","http","mock","testing","spy"],"author":"Rhys Evans","license":"ISC","bugs":{"url":"https://github.com/wheresrhys/fetch-mock/issues"},"homepage":"https://github.com/wheresrhys/fetch-mock","dependencies":{"node-fetch":"^1.2.0","debug":"^2.2.0"},"devDependencies":{"babelify":"^6.3.0","browserify":"^10.0.0","chai":"^2.3.0","coveralls":"^2.11.2","debowerify":"^1.2.1","es6-promise":"^2.1.1","karma":"^0.12.31","karma-browserify":"^4.1.2","karma-chai":"^0.1.0","karma-chrome-launcher":"^0.1.8","karma-mocha":"^0.1.10","mocha":"^2.2.4","mocha-lcov-reporter":"0.0.2","npm-prepublish":"^1.2.0","sinon":"^1.17.0"}} | ||
{"name":"fetch-mock","version":"2.2.1","description":"Mock http requests made using fetch (or isomorphic-fetch)","main":"server.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"https://github.com/wheresrhys/fetch-mock.git"},"keywords":["fetch","http","mock","testing","spy"],"author":"Rhys Evans","license":"ISC","bugs":{"url":"https://github.com/wheresrhys/fetch-mock/issues"},"homepage":"https://github.com/wheresrhys/fetch-mock","dependencies":{"node-fetch":"^1.2.0","debug":"^2.2.0"},"devDependencies":{"babelify":"^6.3.0","browserify":"^10.0.0","chai":"^2.3.0","coveralls":"^2.11.2","debowerify":"^1.2.1","es6-promise":"^2.1.1","karma":"^0.12.31","karma-browserify":"^4.1.2","karma-chai":"^0.1.0","karma-chrome-launcher":"^0.1.8","karma-mocha":"^0.1.10","mocha":"^2.2.4","mocha-lcov-reporter":"0.0.2","npm-prepublish":"^1.2.0","sinon":"^1.17.0"}} |
@@ -35,11 +35,15 @@ # fetch-mock [![Build Status](https://travis-ci.org/wheresrhys/fetch-mock.svg?branch=master)](https://travis-ci.org/wheresrhys/fetch-mock) [![Coverage Status](https://coveralls.io/repos/wheresrhys/fetch-mock/badge.svg)](https://coveralls.io/r/wheresrhys/fetch-mock) | ||
### `mock(config)` | ||
Replaces `fetch()` with a stub which records it's calls, grouped by route, and optionally returns a stub response or passes the call through to `fetch()`. `config` is an optional* object with the following properties. | ||
Replaces `fetch()` with a stub which records it's calls, grouped by route, and optionally returns a stub response or passes the call through to `fetch()`. | ||
#### *Shorthand notation for simplest use cases* | ||
The following are also accepted by mock() | ||
`config` is an optional (when persistent routes are already defined using `registerRoute`) object with properties as below: | ||
> ##### *Shorthand notation for simplest use cases* | ||
The following are also accepted by mock() and translated into `config` objects with the `routes` property defined using the values passed in to mock as follows: | ||
* `mock(name, matcher, response)` - configuration for a single named route to be mocked | ||
* `mock(matcher, response)` - configuration for a single unnamed route to be mocked. To access details of its calls `fetchMock.calls()` should be called without passing a parameter | ||
* `mock(response)` - configuration object for a single route | ||
* `mock(responses` - array of route configuration objects | ||
* `mock(route)` - configuration object for a single route | ||
* `mock(routes)` - array of route configuration objects | ||
* `routes`: Either a single object or an array of similar objects each defining how the mock handles a given request. If multiple routes are specified the first matching route will be used to define the response. Each route object must have the following properties. | ||
@@ -82,5 +86,2 @@ * `name`: A unique string naming the route | ||
\* `config` is optional only when preconfigured routes have already been setup | ||
### `restore()` | ||
@@ -87,0 +88,0 @@ Restores `fetch()` to its unstubbed state and clears all data recorded for its calls |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47381
263