When autoRespond is true, respond to requests after this number of milliseconds. Default is 10.
If set to true, server will find _method parameter in POST body and recognize that as the actual method. Supports a pattern common to Ruby on Rails applications. For custom HTTP method faking, override server.getHTTPMethod(request).
You can inspect the server.requests to verify request ordering, find unmatched requests or check that no requests has been done. server.requests is an array of all the FakeXMLHttpRequest objects that have been created.
If set, the server will respond to every request immediately and synchronously. This is ideal for faking the server from within a test without having to call server.respond() after each request made in that test. As this is synchronous and immediate, this is not suitable for simulating actual network latency in tests or mockups. To simulate network latency with automatic responses, see server.autoRespond and server.autoRespondAfter.
Used internally to determine the HTTP method used with the provided request. By default this method simply returns request.method. When server.fakeHTTPMethods is true, the method will return the value of the _method parameter if the method is “POST”. This method can be overridden to provide custom behavior.
Causes all queued asynchronous requests to receive a response. If none of the responses added through respondWith match, the default response is [404, {}, ""]. Synchronous requests are responded to immediately, so make sure to call respondWith upfront. If called with arguments, respondWith will be called with those arguments before responding to requests.
Causes the server to respond to any request not matched by another response with the provided data. The default catch-all response is [404, {}, ""]. A String representing the response body An Array with status, headers and response body, e.g. [200, { "Content-Type": "text/html", "Content-Length": 2 }, "OK"] A Function. Default status is 200 and default headers are none. When the response is a Function, it will be passed the request object. You must manually call respond on it to complete the request.
A String representing the response body
Causes the server to respond to any request not matched by another response with the provided data. The default catch-all response is [404, {}, ""]. Default status is 200 and default headers are none. When the response is a Function, it will be passed the request object. You must manually call respond on it to complete the request.
An Array with status, headers and response body, e.g. [200, { "Content-Type": "text/html", "Content-Length": 2 }, "OK"]
Causes the server to respond to any request not matched by another response with the provided data. The default catch-all response is [404, {}, ""]. Default status is 200 and default headers are none. When the response is a Function, it will be passed the request object. You must manually call respond on it to complete the request.
A Function.
Responds to all requests to given URL, e.g. /posts/1.
Responds to all requests to given URL, e.g. /posts/1.
Responds to all requests to given URL, e.g. /posts/1.
Responds to all method requests to the given URL with the given response. method is an HTTP verb.
Responds to all method requests to the given URL with the given response. method is an HTTP verb.
Responds to all method requests to the given URL with the given response. method is an HTTP verb.
URL may be a regular expression, e.g. /\/post\//\d+ If the response is a Function, it will be passed any capture groups from the regular expression along with the XMLHttpRequest object:
URL may be a regular expression, e.g. /\/post\//\d+ If the response is a Function, it will be passed any capture groups from the regular expression along with the XMLHttpRequest object:
URL may be a regular expression, e.g. /\/post\//\d+ If the response is a Function, it will be passed any capture groups from the regular expression along with the XMLHttpRequest object:
Responds to all method requests to URLs matching the regular expression.
Responds to all method requests to URLs matching the regular expression.
Responds to all method requests to URLs matching the regular expression.
When set to true, causes the server to automatically respond to incoming requests after a timeout. The default timeout is 10ms but you can control it through the autoRespondAfter property. Note that this feature is intended to help during mockup development, and is not suitable for use in tests.