-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* try new node-fetch * more prototypey implementation * removed ability to pas Promise to sandbox * set implementations on the config object * set implementations on the config object * fix remaining tests for config options * remove configure and setImplementations methods * fix order of things on server * Override Matcher Feature Why: * To provide to ability to override the response for a given matcher How: * Added logic to check for duplicate matchers when adding them. If a duplicate is found, then delete the old one and add the new one. * Added unit tests to verify overriding behavior for string, regex, and function matchers. * Removed the test for falling-back to previous matcher because it directly conflicts with the overriding feature. * Modified the route name creation to include the method so that GET and POST mocks don't register as the same matcher * Refactored compile-route.js to provide two named exports * change a few options * times -> repeat * more thoughts on fallback warnings * deprecate ^ * fix sandbox docs * fix a load of tests * create lib directory * a little file splitting * more file splitting * more file splitting * simplify header matching * refactor compile-route * simplify url matching * simplified route creation * simplified route creation * stuff * simpler url matcher again * revert * tidy up and adding isMock * introduce some async to fetchMock * tidying of holding promises for flush * implement warn on fallback * sensible reorg of building a response * response builder is a class * tidied new response builder implementation * some renaming in sandbox internals * rename a few files * a little reorganising of top level tests * sketched out structure for tests * some tests for methods * allocated all tests to new test groups * re-enabled tests for .mock(), .get() etc * another little test tidyup * testing behaviour when mocking global fetch * seandbox tests and forking * a few routing tests * tidied up a few routing tests * get rid of unecessary promise.all * method matchig * unmatched calls * final few routing tests * placeholder tests for route overriding * changed call filtering behaviour * fixed tests to use new inspection regime * updated flush tests * tweak behaviour when inspecting calls made using Request * tests for repeat and done * tests for generating responses * fixing a few test niggles * start work on custom implementations tests * tests for using custom Promise, Headers etc... * added placeholder tests for remaining options * tests for fallbackToNetwork * tests for fallbackToNetwork * tests for fallbackToNetwork * reinstated basic content length tests * json tests, and json response sets content-type * more json tests * dryer promise/function race resolution * cleaner response builder initialisation * rename test files * tests for includeContentLength * fix some docs for options * test for sendAsJson * added failing tests for overwriting routes * fix all tests to deal with overwriing behaviour * setting overwrite behaviour globally * more forgiving of routes that don't share a method * failing test for whitelisting non-json response props * whitelisting of body props implemented * tidy header setting * call ordering * simpler .mock() implementation * less nesting in router code * tests for call order * filter calls by exact url * fix browser tests * lint * simplify compile-route function * update node version * drop phantomjs * formatting * docs * beta 2 * fix bug matching Requests with a function * 6.0.0-beta.3 * query string matching * 6.0.0-beta.4 * documentation * inspecting: filter by method * update version in README.md * 6.0.0-beta.5 * tweak badges * 6.0.0-beta.6 * 6.0.0-beta.7 * a little more testing and documentation * slight tidy of spy() * simplify route overriding * fix jobs * fix node-fetch 1 tests * no firefox tests * Update config.yml * only deploy on tags * npmrc * tighten tag regex * enable build on tag * extend properly * more extension * rename overrideRoutes to overwriteRoutes (#247) * Update README.md
- Loading branch information
1 parent
a7995c4
commit f6b027d
Showing
38 changed files
with
2,825 additions
and
2,414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
/bower_components/ | ||
/test/fixtures/built-sw.js | ||
/es5/ | ||
package-lock.json | ||
/node_modules/ | ||
npm-debug.log | ||
/es5/ | ||
/dist/ | ||
test/fixtures/built-sw.js | ||
_site | ||
.sass-cache | ||
.jekyll-metadata | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sudo: false | ||
language: node_js | ||
script: npm test | ||
node_js: | ||
- '8' | ||
before_install: | ||
- export CHROME_BIN=chromium-browser | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
# fetch-mock | ||
Mock http requests made using fetch | ||
|
||
Mock http requests made using fetch | ||
[Documentation](http://www.wheresrhys.co.uk/fetch-mock/) | ||
|
||
[![npm version](https://badge.fury.io/js/fetch-mock.svg)](https://badge.fury.io/js/fetch-mock) | ||
Try v6 beta - `npm install [email protected]` | ||
|
||
[![npm version](https://badge.fury.io/js/fetch-mock.svg)](https://badge.fury.io/js/fetch-mock) | ||
[![maintainability](https://api.codeclimate.com/v1/badges/7f8abbf54ec9f3d07df3/maintainability)](https://codeclimate.com/github/wheresrhys/fetch-mock/maintainability) | ||
[![Build Status](https://travis-ci.org/wheresrhys/fetch-mock.svg?branch=master)](https://travis-ci.org/wheresrhys/fetch-mock) | ||
[![CircleCI](https://circleci.com/gh/wheresrhys/fetch-mock.svg?style=svg)](https://circleci.com/gh/wheresrhys/fetch-mock) | ||
[![Coverage Status](https://coveralls.io/repos/github/wheresrhys/fetch-mock/badge.svg?branch=rhys%2Fcoveralls)](https://coveralls.io/github/wheresrhys/fetch-mock?branch=rhys%2Fcoveralls) | ||
|
||
[![bitHound Overall Score](https://www.bithound.io/github/wheresrhys/fetch-mock/badges/score.svg)](https://www.bithound.io/github/wheresrhys/fetch-mock) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ As well as shorthand methods for the simplest use cases, it offers a flexible AP | |
|
||
## These docs are for the v6 beta | ||
|
||
**Please try v6 beta -** `npm install [email protected].1` | ||
**Please try v6 beta -** `npm install [email protected].6` | ||
|
||
- [v5 docs](/fetch-mock/v5) | ||
- [V5 - V6 upgrade guide](/fetch-mock/v5-v6-upgrade) | ||
|
@@ -15,4 +15,4 @@ As well as shorthand methods for the simplest use cases, it offers a flexible AP | |
- [Installation and usage ](/fetch-mock/installation) | ||
- [API documentation](/fetch-mock/api) | ||
- [Troubleshooting](/fetch-mock/troubleshooting) | ||
- [Examples](/fetch-mock/examples) | ||
- [Examples](/fetch-mock/examples) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,11 @@ Feedback gratefully received when in beta - please raise an issue :-) | |
|
||
To try it out: | ||
``` | ||
<<<<<<< HEAD | ||
npm install [email protected] | ||
======= | ||
npm install [email protected] | ||
>>>>>>> a7995c45182455fa46f83d0a21ae057cb6a25c22 | ||
``` | ||
(Bear in mind that the docs may still include a few inaccuracies) | ||
|
||
|
@@ -24,7 +28,7 @@ npm install [email protected] | |
|
||
## Routing | ||
- `^` is no longer a valid way of matching the beginnig of strings; use `begin:` instead | ||
- `overrideRoutes` option allows for existing routes in a mock to be overwritten. It's also possible to define multiple routes with 'the same' matcher. Default behaviour is to error | ||
- `overwriteRoutes` option allows for existing routes in a mock to be overwritten. It's also possible to define multiple routes with 'the same' matcher. Default behaviour is to error | ||
|
||
## Responses | ||
- `Content-Length` header generated by default for all responses (can be configured to not do so globally or per response.) | ||
|
@@ -38,4 +42,4 @@ npm install [email protected] | |
+ `true` for matched calls only | ||
+ `false` for unmatched calls only | ||
+ `undefined` includes all calls to `fetch` in order | ||
- When `fetch` was last called with a `Request` object, `lastUrl()` and `lastOpts()` give easier access to the `url` and full `Request` object | ||
- When `fetch` was last called with a `Request` object, `lastUrl()` and `lastOpts()` give easier access to the `url` and full `Request` object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
'use strict'; | ||
|
||
const FetchMock = require('./fetch-mock'); | ||
const statusTextMap = require('./status-text'); | ||
const FetchMock = require('./lib/index'); | ||
const statusTextMap = require('./lib/status-text'); | ||
const theGlobal = typeof window !== 'undefined' ? window : self; | ||
|
||
FetchMock.global = theGlobal; | ||
FetchMock.statusTextMap = statusTextMap; | ||
|
||
FetchMock.setImplementations({ | ||
FetchMock.config = Object.assign(FetchMock.config, { | ||
Promise: theGlobal.Promise, | ||
Request: theGlobal.Request, | ||
Response: theGlobal.Response, | ||
Headers: theGlobal.Headers | ||
}); | ||
|
||
module.exports = new FetchMock() | ||
module.exports = FetchMock.createInstance(); |
Oops, something went wrong.