{"_id":"xhr-mocklet","_rev":"9-46ec08ff760b3254645a9cca25d9f320","name":"xhr-mocklet","description":"Utility for mocking XMLHttpRequests in the browser or nodejs.","dist-tags":{"latest":"1.2.3"},"versions":{"1.0.0":{"name":"xhr-mocklet","version":"1.0.0","main":"lib/cjs/index.js","module":"lib/es/index.js","typings":"lib/cjs/index.d.ts","description":"Utility for mocking XMLHttpRequests in the browser or nodejs.","license":"MIT","keywords":["mock","xhr","test","fake","request","ajax","browser","xmlhttprequest"],"repository":{"type":"git","url":"git://github.com/marvinhagemeister/xhr-mocklet.git"},"scripts":{"clean":"rimraf dist/ lib/","lint":"tslint 'src/**/*.ts'","watch":"tsc -w","build":"npm run clean && tsc && tsc --module es6 --outDir lib/es/","test":"mocha --compilers ts:ts-node/register 'src/**/__tests__/*.spec.ts'","test-watch":"npm t -- -w -R min","coverage":"nyc npm t","prepublish":"npm run lint && npm t && npm run build","precommit":"./scripts/pre-commit.sh"},"dependencies":{"global":"^4.3.1"},"devDependencies":{"@types/chai":"^3.4.35","@types/mocha":"^2.2.40","@types/node":"^7.0.8","@types/sinon":"^1.16.35","chai":"^3.5.0","husky":"^0.13.2","mocha":"^3.2.0","nyc":"^10.1.2","rimraf":"^2.6.1","sinon":"^1.17.7","ts-node":"^2.1.0","tslint":"^4.5.1","typescript":"^2.2.1"},"nyc":{"include":["src/*.ts","src/**/*.ts"],"exclude":["typings","node_modules/","**/__tests__/**","__tests__/**","**/*.d.ts"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["json","html","text","text-summary","lcovonly"],"all":true},"gitHead":"42a4fda7d769aff98f0c20bd35c08dbe9575846e","bugs":{"url":"https://github.com/marvinhagemeister/xhr-mocklet/issues"},"homepage":"https://github.com/marvinhagemeister/xhr-mocklet#readme","_id":"xhr-mocklet@1.0.0","_shasum":"39d32b4d282a959d9dbc98fc031d22329fbc5836","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.6.0","_npmUser":{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"},"dist":{"shasum":"39d32b4d282a959d9dbc98fc031d22329fbc5836","tarball":"https://registry.npmjs.org/xhr-mocklet/-/xhr-mocklet-1.0.0.tgz","integrity":"sha512-Onky+ZJmLVrk2VumyGv8CounrXbQYSv+W0unJnrI8Us3/F26Sn1fgvIWDLYOtD1cf53HS4FCsyZrHwMBFWOMRA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAfje6NwhFZ1X+PS14p2kxVupu4Vr2r2snY5qV7vf1NxAiAGzblylNebpC0gImrNPJ5Ey+FFrk7K+uGaRUCfFT4+dg=="}]},"maintainers":[{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/xhr-mocklet-1.0.0.tgz_1489423388496_0.7606278408784419"},"directories":{}},"1.1.0":{"name":"xhr-mocklet","version":"1.1.0","main":"lib/cjs/index.js","module":"lib/es/index.js","typings":"lib/cjs/index.d.ts","description":"Utility for mocking XMLHttpRequests in the browser or nodejs.","license":"MIT","keywords":["mock","xhr","test","fake","request","ajax","browser","xmlhttprequest"],"repository":{"type":"git","url":"git://github.com/marvinhagemeister/xhr-mocklet.git"},"scripts":{"clean":"rimraf dist/ lib/","lint":"tslint 'src/**/*.ts'","watch":"tsc -w","build":"npm run clean && tsc && tsc --module es6 --outDir lib/es/","test":"mocha --compilers ts:ts-node/register 'src/**/__tests__/*.spec.ts'","test-watch":"npm t -- -w -R min","coverage":"nyc npm t","prepublish":"npm run lint && npm t && npm run build","precommit":"./scripts/pre-commit.sh"},"dependencies":{"global":"^4.3.1"},"devDependencies":{"@types/chai":"^3.4.35","@types/mocha":"^2.2.40","@types/node":"^7.0.8","@types/sinon":"^1.16.35","chai":"^3.5.0","husky":"^0.13.2","mocha":"^3.2.0","nyc":"^10.1.2","rimraf":"^2.6.1","sinon":"^1.17.7","ts-node":"^2.1.0","tslint":"^4.5.1","typescript":"^2.2.1"},"nyc":{"include":["src/*.ts","src/**/*.ts"],"exclude":["typings","node_modules/","**/__tests__/**","__tests__/**","**/*.d.ts"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["json","html","text","text-summary","lcovonly"],"all":true},"gitHead":"9bb8347322a991d8e454c4c29351b9f577b47771","bugs":{"url":"https://github.com/marvinhagemeister/xhr-mocklet/issues"},"homepage":"https://github.com/marvinhagemeister/xhr-mocklet#readme","_id":"xhr-mocklet@1.1.0","_shasum":"390abb04fda1cefb5b11c132785e38de976a5542","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.2","_npmUser":{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"},"dist":{"shasum":"390abb04fda1cefb5b11c132785e38de976a5542","tarball":"https://registry.npmjs.org/xhr-mocklet/-/xhr-mocklet-1.1.0.tgz","integrity":"sha512-pgwHJ0htBCN1z1G0F6uK1+DAxZAW2nLESPKrGvYXtVneEZhUJl0xyy41/wFWhTX41NRaO1vR2pNbvRDyCRPYLg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBtfcS7ZBfVtGpHIWqnoPp9mLNkmZ0vuHxOoFWqUwuFoAiEA6pqHa4b52E5XaV9am3zeaKSCugmW+sFOzF3/E4UD0A0="}]},"maintainers":[{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/xhr-mocklet-1.1.0.tgz_1489510373822_0.3490956202149391"},"directories":{}},"1.2.0":{"name":"xhr-mocklet","version":"1.2.0","main":"lib/cjs/index.js","module":"lib/es/index.js","typings":"lib/cjs/index.d.ts","description":"Utility for mocking XMLHttpRequests in the browser or nodejs.","license":"MIT","keywords":["mock","xhr","test","fake","request","ajax","browser","xmlhttprequest"],"repository":{"type":"git","url":"git://github.com/marvinhagemeister/xhr-mocklet.git"},"scripts":{"clean":"rimraf dist/ lib/","lint":"tslint 'src/**/*.ts'","watch":"tsc -w","build":"npm run clean && tsc && tsc --module es6 --outDir lib/es/","test":"mocha --compilers ts:ts-node/register 'src/**/__tests__/*.spec.ts'","test-watch":"npm t -- -w -R min","coverage":"nyc npm t","prepublish":"npm run lint && npm t && npm run build","precommit":"./scripts/pre-commit.sh"},"dependencies":{"@types/event-emitter":"^0.3.0","event-emitter":"^0.3.5","global":"^4.3.1"},"devDependencies":{"@types/chai":"^3.4.35","@types/mocha":"^2.2.40","@types/node":"^7.0.8","@types/sinon":"^1.16.35","chai":"^3.5.0","husky":"^0.13.2","mocha":"^3.2.0","nyc":"^10.1.2","rimraf":"^2.6.1","sinon":"^1.17.7","ts-node":"^3.3.0","tslint":"^5.7.0","typescript":"^2.4.2"},"nyc":{"include":["src/*.ts","src/**/*.ts"],"exclude":["typings","node_modules/","**/__tests__/**","__tests__/**","**/*.d.ts"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["json","html","text","text-summary","lcovonly"],"all":true},"gitHead":"178fb4cad88a93b24e0f82c9610728164910b6f6","bugs":{"url":"https://github.com/marvinhagemeister/xhr-mocklet/issues"},"homepage":"https://github.com/marvinhagemeister/xhr-mocklet#readme","_id":"xhr-mocklet@1.2.0","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"},"dist":{"integrity":"sha512-fihaqaHITY065JXbAvX0Plat/EuHgP1uXWV4J4QGjTq6l1fH5TVZbDvQKeF+lx2pu0D0Dpm6D7HMFvn20U18Sw==","shasum":"b949755689d95d6e497ef5b78bb28a7ee3845b5a","tarball":"https://registry.npmjs.org/xhr-mocklet/-/xhr-mocklet-1.2.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIACZWT5B59mD/yH1eJYgUNBBaM3LegMKyjgJjbEu7mdaAiEA1IBxQwlMgw0VczkHXM7r1hdFVr6oZmJp97KGQ0FlD18="}]},"maintainers":[{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xhr-mocklet-1.2.0.tgz_1504009055905_0.13269820343703032"},"directories":{}},"1.2.1":{"name":"xhr-mocklet","version":"1.2.1","main":"lib/cjs/index.js","module":"lib/es/index.js","typings":"lib/cjs/index.d.ts","description":"Utility for mocking XMLHttpRequests in the browser or nodejs.","license":"MIT","keywords":["mock","xhr","test","fake","request","ajax","browser","xmlhttprequest"],"repository":{"type":"git","url":"git://github.com/marvinhagemeister/xhr-mocklet.git"},"scripts":{"clean":"rimraf dist/ lib/","lint":"tslint 'src/**/*.ts'","watch":"tsc -w","build":"npm run clean && tsc && tsc --module es6 --outDir lib/es/","test":"mocha --compilers ts:ts-node/register 'src/**/__tests__/*.spec.ts'","test-watch":"npm t -- -w -R min","coverage":"nyc npm t","prepublish":"npm run lint && npm t && npm run build","precommit":"./scripts/pre-commit.sh"},"dependencies":{"@types/event-emitter":"^0.3.0","event-emitter":"^0.3.5","global":"^4.3.1"},"devDependencies":{"@types/chai":"^3.4.35","@types/mocha":"^2.2.40","@types/node":"^7.0.8","@types/sinon":"^1.16.35","chai":"^3.5.0","husky":"^0.13.2","mocha":"^3.2.0","nyc":"^10.1.2","rimraf":"^2.6.1","sinon":"^1.17.7","ts-node":"^3.3.0","tslint":"^5.7.0","typescript":"^2.4.2"},"nyc":{"include":["src/*.ts","src/**/*.ts"],"exclude":["typings","node_modules/","**/__tests__/**","__tests__/**","**/*.d.ts"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["json","html","text","text-summary","lcovonly"],"all":true},"gitHead":"345a36f6b725edccdec14d95793d9c7dfc37ffce","bugs":{"url":"https://github.com/marvinhagemeister/xhr-mocklet/issues"},"homepage":"https://github.com/marvinhagemeister/xhr-mocklet#readme","_id":"xhr-mocklet@1.2.1","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"},"dist":{"integrity":"sha512-ga3R0nO9Z4ivjJh6XP1xbAK6lFoHw3XOYY69vnm1g8cBr2MzeZAalFcmNMS0y4e3l3A+sQFZuVfay7WPDmxERg==","shasum":"c9ecfa00cf6b150a5611f492e5dfa11fc2ea7a00","tarball":"https://registry.npmjs.org/xhr-mocklet/-/xhr-mocklet-1.2.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICJM2pwJ1psp/VV6rzuLepI5AWQJEn4WEN0LznM+62ccAiA0oK54sNFbfmJWJS03iq/P5hIa0IGimqJYN88+51xVPA=="}]},"maintainers":[{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xhr-mocklet-1.2.1.tgz_1504197059189_0.9154399167746305"},"directories":{}},"1.2.2":{"name":"xhr-mocklet","version":"1.2.2","main":"lib/cjs/index.js","module":"lib/es/index.js","typings":"lib/cjs/index.d.ts","description":"Utility for mocking XMLHttpRequests in the browser or nodejs.","license":"MIT","keywords":["mock","xhr","test","fake","request","ajax","browser","xmlhttprequest"],"repository":{"type":"git","url":"git://github.com/marvinhagemeister/xhr-mocklet.git"},"scripts":{"clean":"rimraf dist/ lib/","lint":"tslint 'src/**/*.ts'","watch":"tsc -w","build":"npm run clean && tsc && tsc --module es6 --outDir lib/es/","test":"mocha --compilers ts:ts-node/register 'src/**/__tests__/*.spec.ts'","test-watch":"npm t -- -w -R min","coverage":"nyc npm t","prepublishOnly":"npm run lint && npm t && npm run build","precommit":"./scripts/pre-commit.sh"},"dependencies":{"@types/event-emitter":"^0.3.0","event-emitter":"^0.3.5","global":"^4.3.1"},"devDependencies":{"@types/chai":"^3.4.35","@types/mocha":"^2.2.40","@types/node":"^7.0.8","@types/sinon":"^1.16.35","chai":"^3.5.0","husky":"^0.13.2","mocha":"^3.2.0","nyc":"^10.1.2","rimraf":"^2.6.1","sinon":"^1.17.7","ts-node":"^3.3.0","tslint":"^5.7.0","typescript":"^2.4.2"},"nyc":{"include":["src/*.ts","src/**/*.ts"],"exclude":["typings","node_modules/","**/__tests__/**","__tests__/**","**/*.d.ts"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["json","html","text","text-summary","lcovonly"],"all":true},"gitHead":"8fee54efdc3c40c3f4d4c063bd6108b16e5a51ad","bugs":{"url":"https://github.com/marvinhagemeister/xhr-mocklet/issues"},"homepage":"https://github.com/marvinhagemeister/xhr-mocklet#readme","_id":"xhr-mocklet@1.2.2","_npmVersion":"5.6.0","_nodeVersion":"9.5.0","_npmUser":{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"},"dist":{"integrity":"sha512-B79kBVZXcEakuZfYd+yYnrBJjaWcA7YrthMwaVA49jd3/IxVpcEKvUBkrI4tE+lYc1xgdUQohUn9ccNYF131Fw==","shasum":"d10a11996a85c3d622ea36ee02956148adab0225","tarball":"https://registry.npmjs.org/xhr-mocklet/-/xhr-mocklet-1.2.2.tgz","fileCount":54,"unpackedSize":136867,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDd862wD5YWtQdMVyytUX7JQjYePsvgf07pQqaDIUNhlgIhAPOiPT7H7WvTrmZADP6jMi58MC79J/bH+l/67JDw7StA"}]},"maintainers":[{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xhr-mocklet_1.2.2_1521800832066_0.6697125217275044"},"_hasShrinkwrap":false},"1.2.3":{"name":"xhr-mocklet","version":"1.2.3","main":"lib/cjs/index.js","module":"lib/es/index.js","typings":"lib/cjs/index.d.ts","description":"Utility for mocking XMLHttpRequests in the browser or nodejs.","license":"MIT","keywords":["mock","xhr","test","fake","request","ajax","browser","xmlhttprequest"],"repository":{"type":"git","url":"git://github.com/marvinhagemeister/xhr-mocklet.git"},"scripts":{"clean":"rimraf dist/ lib/","lint":"tslint 'src/**/*.ts'","watch":"tsc -w","build":"npm run clean && tsc && tsc --module es6 --outDir lib/es/","test":"mocha --compilers ts:ts-node/register 'src/**/__tests__/*.spec.ts'","test-watch":"npm t -- -w -R min","coverage":"nyc npm t","prepublishOnly":"npm run lint && npm t && npm run build","precommit":"./scripts/pre-commit.sh"},"dependencies":{"@types/event-emitter":"^0.3.0","event-emitter":"^0.3.5","global":"^4.3.1"},"devDependencies":{"@types/chai":"^3.4.35","@types/mocha":"^2.2.40","@types/node":"^7.0.8","@types/sinon":"^1.16.35","chai":"^3.5.0","husky":"^0.13.2","mocha":"^3.2.0","nyc":"^10.1.2","rimraf":"^2.6.1","sinon":"^1.17.7","ts-node":"^3.3.0","tslint":"^5.7.0","typescript":"^2.4.2"},"nyc":{"include":["src/*.ts","src/**/*.ts"],"exclude":["typings","node_modules/","**/__tests__/**","__tests__/**","**/*.d.ts"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["json","html","text","text-summary","lcovonly"],"all":true},"gitHead":"183b8d67d3cbc2eb3dbb1a3efd94eca6c7fdc029","bugs":{"url":"https://github.com/marvinhagemeister/xhr-mocklet/issues"},"homepage":"https://github.com/marvinhagemeister/xhr-mocklet#readme","_id":"xhr-mocklet@1.2.3","_npmVersion":"6.4.1","_nodeVersion":"9.11.1","_npmUser":{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"},"dist":{"integrity":"sha512-Otet4VNBSLTubWOKdSjwwbUwoP6CGG3ztxYCQ0dgTVcKF6dAqxp/W1LawQYJgaLKvO9ZHhlCCAqQ1+HTv2GM6g==","shasum":"d0ef32e2f431929674549c0d39f51ca9e655c954","tarball":"https://registry.npmjs.org/xhr-mocklet/-/xhr-mocklet-1.2.3.tgz","fileCount":54,"unpackedSize":137267,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb9AjOCRA9TVsSAnZWagAAJpwQAITCAvYn3C7qNsUu03qT\nxTK+mwoVlYeort6xa3sn2YGS32iii1o4U923HUKdMtK3GW7ge7IDEPvlei5U\ni4z1jo9W5ewQT6bCv4SwTqg2d4yEuJtclcvspmtv3UloaDDKGLUF+4VaC5Fc\n8EYHRvU5IeGFhkmjYwRDd/xridk3UyPrvJjcOX2McUuqnTDQLEJ9GqZ9nkOv\nQciGCfhMXQZnxiaLhGEFDy0ZNqE0rVxglCNm2TDrlAWl5Zpct34H1YDeXHRy\n7Ch/IlsFTQqVj3UQdp1dgrw6YDQWF1iSU6cFpCJjGIo0t19sXGkGy/EytSSl\nb9zU+rojc+bKsG0mmI0Dwf5Y+lzA7koAa51SmWW+TQZJ7d/fBvnHQeRuWXTX\nm4hngsecGeCKh93RAs2OuPW/T5tz4ZEu9MmMnq6uL8tCOF3KFhz+7ff5/Toi\npp0iXST9LIu+zfgvY5dQln6G2nnciTmFZcdExDGRFUrwuXfD+OntSHYl2787\nWzulhn0UHifVofj6SlroVpry9irmn+xSrM8YTW60QWaFfk/cQwSgwtBe346l\nWO6fE5pklWrMNMzX7LwofLGkzClsDE1XkWEF32GhT7unsmtHI9RlqesIP8Oe\nkeTAzgO7chtZ4UwX15E+kpBszNAtIm/NshuUmdgtmfwQXS/LS7/wl/nAESAy\nCXyE\r\n=jyDv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCfJWTYYcZf9qSgOt0ycouNmE3ewBWmW9aawLKKUqSfmQIgBv5dhgE7qu+9jBffXL/2xS7wqUWkceTIzE6KezIbSUo="}]},"maintainers":[{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xhr-mocklet_1.2.3_1542719694254_0.6418230933698157"},"_hasShrinkwrap":false}},"readme":"# XMLHttpRequest mocking\n\n[![Build Status](https://travis-ci.org/marvinhagemeister/xhr-mocklet.svg?branch=master)](https://travis-ci.org/marvinhagemeister/xhr-mocklet) [![MIT](https://img.shields.io/npm/l/inferno.svg?style=flat-square)](https://github.com/marvinhagemeister/xhr-mocklet/blob/master/LICENSE.md)\n[![NPM Version](https://img.shields.io/npm/v/xhr-mocklet.svg?style=flat-square)](https://www.npmjs.com/package/xhr-mocklet)\n\nUtility for mocking XMLHttpRequests both in the browser and nodejs. It's primary\nuse case is for unit tests, allowing you to respond with mock responses, trigger\ntimeouts, etc.\n\nThis library comes with complete TypeScript declaration files.\n\n## Installation\n\n```bash\n# NPM\nnpm install --save --dev xhr-mocklet\n\n# Or via yarn:\nyarn add --dev xhr-mocklet\n```\n\n## Usage\n\n```js\nconst mock = require('xhr-mocklet');\n\n// Replace the real XHR object with the mock XHR object\nmock.setup();\n\n// Mock a response for all POST requests to http://localhost/api/user\nmock.post('http://localhost/api/user', (req, res) => {\n  return res\n    .status(201)\n    .header('Content-Type', 'application/json')\n    .body({\n      lastName: 'John',\n      firstName: 'Smith'\n    });\n});\n\n// Restore the original XHR object when all your tests are done.\nmock.teardown();\n```\n\n### Simulating an error\n\nSimply return `null` from your response handler:\n\n```js\nmock.post('http://localhost/foo', (req, res) => null);\n```\n\n### Simulate a timeout\n\n```js\nmock.post('http://localhost/foo', (req, res) => res.timeout(true));\n```\n\n### Use mocked `XMLHttpRequest`\n\nYou can even use a mocked `XMLHttpReqeuest` instance to create Requests:\n\n```js\n// Create an instance of the (mock) XHR object and use as per normal\nconst xhr = new XMLHttpRequest();\n\nxhr.onreadystatechange = () => {\n  if (xhr.readyState === xhr.DONE) {\n    // when you're finished put the real XHR object back\n    mock.teardown();\n  }\n}\n```\n\n## API\n\n### Builder\n\n| Method | Description |\n|---|---|\n| `setup()` | Replace the global `XMLHttpRequest` object with the `MockXMLHttpRequest`. |\n| `teardown()` | Restore the global `XMLHttpRequest` object to its original state. |\n| `reset()` | Remove all request handlers. |\n| `get(url: string \\| regex, callback)` | Create `GET` mock response for a specific url. |\n| `post(url: string \\| regex, callback)` | Create `POST` mock response for a specific url. |\n| `put(url: string \\| regex, callback)` | Create `PUT` mock response for a specific url. |\n| `patch(url: string \\| regex, callback)` | Create `PATCH` mock response for a specific url. |\n| `delete(url: string \\| regex, callback)` | Create `DELETE` mock response for a specific url. |\n| `mock(callback)` | Register mock response for every request. |\n\n### MockXMLHttpRequest\n\nThe api is practically similar to the native [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest).\n\n### MockRequest\n\n| Method | Description |\n|---|---|\n| `method(): string` | Get the request method. |\n| `url(): string` | Get the request URL. |\n| `query(): object` | Get the parsed query part of the request URL. |\n| `header(name: string): string` | Get a request header. |\n| `headers(): object` | Get all request headers. |\n| `body(): string` | Get the request body. |\n\n### MockResponse\n\n| Method | Description |\n|---|---|\n| `status(): number` | Get the response status. |\n| `status(code: number)` | Set the response status. |\n| `header(name: string): string` | Get a response header. |\n| `header(name: string, value: string)` | Set a response header. |\n| `headers(): object` | Get response headers. |\n| `headers(headers: obejct)` | Set response headers. |\n| `body(): string` | Get response body. |\n| `body(body: string)` | Set response body. |\n| `timeout(): boolean \\| number` | Get weather the response will trigger a timeout. |\n| `timeout(ms: boolean \\| number)` | Set a timeout, otherwise default to the value set on the XHR object. |\n| `progress(loaded: number, total: number, lengthComputable: boolean)` | Trigger progress event. Pass in loaded size, total size and if event is lengthComputable. |\n\n## Special Thanks\n\nSpecial thanks goes to [James Newell](https://github.com/jameslnewell/) for his\n[xhr-mock](https://github.com/jameslnewell/xhr-mock) library. `xhr-mocklet`\nstarted out as a fork of his work.\n","maintainers":[{"name":"marvinhagemeister","email":"marvin@marvinhagemeister.de"}],"time":{"modified":"2022-06-29T05:10:59.306Z","created":"2017-03-13T16:43:10.426Z","1.0.0":"2017-03-13T16:43:10.426Z","1.1.0":"2017-03-14T16:52:55.851Z","1.2.0":"2017-08-29T12:17:36.929Z","1.2.1":"2017-08-31T16:31:00.264Z","1.2.2":"2018-03-23T10:27:12.388Z","1.2.3":"2018-11-20T13:14:54.384Z"},"homepage":"https://github.com/marvinhagemeister/xhr-mocklet#readme","keywords":["mock","xhr","test","fake","request","ajax","browser","xmlhttprequest"],"repository":{"type":"git","url":"git://github.com/marvinhagemeister/xhr-mocklet.git"},"bugs":{"url":"https://github.com/marvinhagemeister/xhr-mocklet/issues"},"license":"MIT","readmeFilename":"README.md"}