{"_id":"chai-fetch","_rev":"9-4a38b96a61cd605df5f5f89fc20f3863","name":"chai-fetch","description":"Chai matchers to make matching fetch responses clear & easy","dist-tags":{"latest":"0.3.1"},"versions":{"0.1.0":{"name":"chai-fetch","version":"0.1.0","description":"Chai matchers to make matching fetch responses clear & easy Edit","main":"dist/index.js","types":"src/index.ts","files":["dist/","src/"],"scripts":{"build":"tsc -p src","pretest":"npm run build","test":"mocha -r ts-node/register 'test/*.spec.ts'"},"repository":{"type":"git","url":"git+https://github.com/pimterry/chai-fetch.git"},"keywords":["fetch","chai","chai-plugin","assertions","node-fetch","fetch-polyfill","fetch-ponyfill","testing"],"author":{"name":"Tim Perry","email":"pimterry@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/pimterry/chai-fetch/issues"},"homepage":"https://github.com/pimterry/chai-fetch#readme","devDependencies":{"@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node-fetch":"^1.6.7","chai":"^4.1.2","http-server-mock":"^0.2.0","mocha":"^4.0.1","node-fetch":"^1.7.3","ts-node":"^3.3.0","typescript":"^2.5.3"},"gitHead":"ce8b2b4635bb3699e752091f17ed191c8da882bd","_id":"chai-fetch@0.1.0","_shasum":"663ed3d02c11907c3c8fdb306c3211387eedc93e","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"pimterry","email":"pimterry@gmail.com"},"dist":{"shasum":"663ed3d02c11907c3c8fdb306c3211387eedc93e","tarball":"https://registry.npmjs.org/chai-fetch/-/chai-fetch-0.1.0.tgz","integrity":"sha512-TM0zU+53S/DM7jxCVBAZi8xBcsa9uh94wPTOSvlwZ/lum9Z0ep6VX2IPeKJxcUkknz4YPiyFnwzpcZ8TGAfnnQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC5B9O++Ejk5EC/6yU2Fhx+Dul7jKXrVrcz9v2xoFbDvwIgBBC+W0REv/pP4UuSaXBfseqE9rj6MNkxGeeLDia8WSI="}]},"maintainers":[{"name":"pimterry","email":"pimterry@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-fetch-0.1.0.tgz_1508077179520_0.04559413134120405"},"directories":{}},"0.1.1":{"name":"chai-fetch","version":"0.1.1","description":"Chai matchers to make matching fetch responses clear & easy Edit","main":"dist/index.js","types":"src/index.ts","files":["dist/","src/"],"scripts":{"build":"tsc -p src","pretest":"npm run build","test":"mocha -r ts-node/register 'test/*.spec.ts'"},"repository":{"type":"git","url":"git+https://github.com/pimterry/chai-fetch.git"},"keywords":["fetch","chai","chai-plugin","assertions","node-fetch","fetch-polyfill","fetch-ponyfill","testing"],"author":{"name":"Tim Perry","email":"pimterry@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/pimterry/chai-fetch/issues"},"homepage":"https://github.com/pimterry/chai-fetch#readme","devDependencies":{"@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node-fetch":"^1.6.7","chai":"^4.1.2","http-server-mock":"^0.2.0","mocha":"^4.0.1","node-fetch":"^1.7.3","ts-node":"^3.3.0","typescript":"^2.5.3"},"gitHead":"1598296869dee5a3208a2cb0cc7538181400d84c","_id":"chai-fetch@0.1.1","_shasum":"0b34c88652c90a1322450e5b06953c2ed3da3280","_from":".","_npmVersion":"4.6.1","_nodeVersion":"4.8.3","_npmUser":{"name":"pimterry","email":"pimterry@gmail.com"},"dist":{"shasum":"0b34c88652c90a1322450e5b06953c2ed3da3280","tarball":"https://registry.npmjs.org/chai-fetch/-/chai-fetch-0.1.1.tgz","integrity":"sha512-UhpruOeOhQflBRxss4yTbDKGidRUhAZYZeaykAQnJRuVek8TLeb6JZyXNlfGsBD9Cg0bs6/YePS1MfW2mVmOjw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQClr4h3yeFiFaXiB5RRURVdsqzNTp0TAxmU7eoz0syXlAIgWHnZCvaXXUeWXFvIre+uyhiiCNufhDKOLUE91kNaKrQ="}]},"maintainers":[{"name":"pimterry","email":"pimterry@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-fetch-0.1.1.tgz_1508079742007_0.1157370584551245"},"directories":{}},"0.2.0":{"name":"chai-fetch","version":"0.2.0","description":"Chai matchers to make matching fetch responses clear & easy Edit","main":"dist/index.js","types":"src/index.ts","files":["dist/","src/"],"scripts":{"build":"tsc -p src","pretest":"npm run build","test":"mocha -r ts-node/register 'test/*.spec.ts'"},"repository":{"type":"git","url":"git+https://github.com/pimterry/chai-fetch.git"},"keywords":["fetch","chai","chai-plugin","assertions","node-fetch","fetch-polyfill","fetch-ponyfill","testing"],"author":{"name":"Tim Perry","email":"pimterry@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/pimterry/chai-fetch/issues"},"homepage":"https://github.com/pimterry/chai-fetch#readme","devDependencies":{"@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node-fetch":"^1.6.7","chai":"^4.1.2","http-server-mock":"^0.2.0","mocha":"^4.0.1","node-fetch":"^1.7.3","ts-node":"^3.3.0","typescript":"^2.5.3"},"gitHead":"dfea250bb5780d59172a522c99c484640e0cf349","_id":"chai-fetch@0.2.0","_shasum":"824edbab2f9c0d557533f459a93c0f037f680d95","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"pimterry","email":"pimterry@gmail.com"},"dist":{"shasum":"824edbab2f9c0d557533f459a93c0f037f680d95","tarball":"https://registry.npmjs.org/chai-fetch/-/chai-fetch-0.2.0.tgz","integrity":"sha512-arafXaEQ9YbcNICxBgW+mps+nTVDVOOxt9h7tNrzaDV3wbv3UxiiEPsKashIfDIhSGTyyq1JfdYq2X6cXzyZkg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDf6Jr7A7SVzEIVD35HmbHMFGJyJMo43pXDm2QW2dpQJAiBqqOyGjovlLDrxd/iRTsxIBpJ7NaEQTp2nB+kTWTQpGQ=="}]},"maintainers":[{"name":"pimterry","email":"pimterry@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-fetch-0.2.0.tgz_1508087847378_0.7002825315576047"},"directories":{}},"0.2.1":{"name":"chai-fetch","version":"0.2.1","description":"Chai matchers to make matching fetch responses clear & easy","main":"dist/index.js","types":"src/index.ts","files":["dist/","src/"],"scripts":{"build":"tsc -p src","pretest":"npm run build","test":"mocha -r ts-node/register 'test/*.spec.ts'"},"repository":{"type":"git","url":"git+https://github.com/pimterry/chai-fetch.git"},"keywords":["fetch","chai","chai-plugin","assertions","node-fetch","fetch-polyfill","fetch-ponyfill","testing"],"author":{"name":"Tim Perry","email":"pimterry@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/pimterry/chai-fetch/issues"},"homepage":"https://github.com/pimterry/chai-fetch#readme","devDependencies":{"@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node-fetch":"^1.6.7","chai":"^4.1.2","http-server-mock":"^0.2.0","mocha":"^4.0.1","node-fetch":"^1.7.3","ts-node":"^3.3.0","typescript":"^2.5.3"},"gitHead":"d7329029321fdc39919d669e905e27b6fb6db64f","_id":"chai-fetch@0.2.1","_shasum":"a744bce8c7657a34c82f1a34a26913d2ab83c7c4","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"pimterry","email":"pimterry@gmail.com"},"dist":{"shasum":"a744bce8c7657a34c82f1a34a26913d2ab83c7c4","tarball":"https://registry.npmjs.org/chai-fetch/-/chai-fetch-0.2.1.tgz","integrity":"sha512-i55zRFja7n6ll+Zw725Mf+L0PR3Kn+vTjkwHNhlBoxNlGCLhpLdxh01VGnT8HqCnVDcvK7w/AWPPbNDJf07YOg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCOCmbERx04lnJ219LOdd4ymAzoVzyzj7Ax4o6SDOlaRwIhAMkZHEfpGXOyKGt+W4NVl55NhK1oKaK0U9opFZOm71k9"}]},"maintainers":[{"name":"pimterry","email":"pimterry@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-fetch-0.2.1.tgz_1508150845970_0.5535281982738525"},"directories":{}},"0.3.0":{"name":"chai-fetch","version":"0.3.0","description":"Chai matchers to make matching fetch responses clear & easy","main":"dist/index.js","types":"src/index.ts","files":["dist/","src/"],"scripts":{"build":"tsc -p src","pretest":"npm run build","test":"mocha -r ts-node/register 'test/*.spec.ts'"},"repository":{"type":"git","url":"git+https://github.com/pimterry/chai-fetch.git"},"keywords":["fetch","chai","chai-plugin","assertions","node-fetch","fetch-polyfill","fetch-ponyfill","testing"],"author":{"name":"Tim Perry","email":"pimterry@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/pimterry/chai-fetch/issues"},"homepage":"https://github.com/pimterry/chai-fetch#readme","devDependencies":{"@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node-fetch":"^1.6.7","chai":"^4.1.2","http-server-mock":"^0.2.0","mocha":"^4.0.1","node-fetch":"^1.7.3","ts-node":"^3.3.0","typescript":"^2.5.3"},"gitHead":"17d09192502fb70db6c2b074ae1d8422655c31d2","_id":"chai-fetch@0.3.0","_shasum":"6d4c27f679f9fb58fa7c7f7b7b81e6358a19b89e","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"pimterry","email":"pimterry@gmail.com"},"dist":{"shasum":"6d4c27f679f9fb58fa7c7f7b7b81e6358a19b89e","tarball":"https://registry.npmjs.org/chai-fetch/-/chai-fetch-0.3.0.tgz","integrity":"sha512-Zat2qRjDhuCtPfpHQwg34RsDwcWhXknmdKB/UtiPnm/1mzX86lX8wu07Yr7+jWdS7a1rj9pfiDE3+D3N/NAD1w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDt3akxvCSUijQPDNWrnK0TcvPCuvVIZSYWhr38bWD8UwIgCnHAR1C39CodbtyGhfOoBe2PNBrRvRyOwCTlVcmI/fk="}]},"maintainers":[{"name":"pimterry","email":"pimterry@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-fetch-0.3.0.tgz_1508311556125_0.8329521012492478"},"directories":{}},"0.3.1":{"name":"chai-fetch","version":"0.3.1","description":"Chai matchers to make matching fetch responses clear & easy","main":"dist/index.js","types":"src/index.ts","files":["dist/","src/"],"scripts":{"build":"tsc -p src","pretest":"npm run build","test":"mocha -r ts-node/register 'test/*.spec.ts'"},"repository":{"type":"git","url":"git+https://github.com/pimterry/chai-fetch.git"},"keywords":["fetch","chai","chai-plugin","assertions","node-fetch","fetch-polyfill","fetch-ponyfill","testing"],"author":{"name":"Tim Perry","email":"pimterry@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/pimterry/chai-fetch/issues"},"homepage":"https://github.com/pimterry/chai-fetch#readme","devDependencies":{"@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node-fetch":"^1.6.7","chai":"^4.1.2","mocha":"^4.0.1","mockttp":"^0.8.1","node-fetch":"^1.7.3","ts-node":"^3.3.0","typescript":"^2.5.3"},"gitHead":"6c38a82e507f8213cf7d65b2d0258c726667d226","_id":"chai-fetch@0.3.1","_npmVersion":"6.1.0","_nodeVersion":"8.11.1","_npmUser":{"name":"pimterry","email":"pimterry@gmail.com"},"dist":{"integrity":"sha512-crVP0nU9SFdLAUfLsdgeJs6PL418Q32CLGfaQVKH9BHXcPgrCSg/EA1Am3IK0idcWdJdTZBbXtisWoMdID36AA==","shasum":"86457313fd3cfb8cd1d47a0433f906dc6296ab10","tarball":"https://registry.npmjs.org/chai-fetch/-/chai-fetch-0.3.1.tgz","fileCount":6,"unpackedSize":12424,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbS82rCRA9TVsSAnZWagAA0AMP/2ZqSaJ7jVGkIl1V9M3b\nw4gUMsp8XW1yLtvT8u60r2EvvSHkqV4meCcKDt4umlywiXGQIzGtUpdFLFgD\n9PmzyS2H5A4ZZK1j8A5Wut4TwqUj4A+1JlaXxWGT4Htkvn7GgjE2CzrWrc39\nmXf0Nmw/qiUttwmIaE7aHc4c92StySqUfDgPvGCbufZQKvYUt+XzDxbSfbYP\nqJ7jihUtaTG8POdPeB+Byx/o6j019s4ghsy49Y9H2bPT7gFexdF8FnL/0ZTB\nDVhLY4/vqcPB/9aGM0wjjQyndVdcx9/mkAjYAFxnZTxNWFZbSznV+CAzHrDX\nON7I1I6tvHBQ7HHLz9b/jumnh09MKNal6LL3uCqhKSa2Y03eMOZlX5wMGCa3\nWVVm0L7/s3NlXfmuTdoO+7t5wk/8PjA24C/A4GqPf9vnDy/qrJIF+1Mkx2hd\ntee0RH17YP4s1bmw8em/qtndiik+Ynuh3MjDwOBzL+xtrFtsFTookPZstU5f\nOZFgG67SzcrJYL8F2TAGrLz1GUZcf3aDFz9KIxj+7Qn9vMl6a/dczKaEJ0bd\nxThChCPjoxw/qdbgEQKb8+CYFjMhtbNlTPagI7ApTp2vejV4UatglOqQrTZh\nP8zNY7I61GZzLaNIxC8qlSZqT1Y28R5/80tS8JeIJ8eUa6/4z/fwfvwim/5y\nt47V\r\n=3MFT\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDbCJH8ybk9Su4/w12ix13UskqZ9I8hxgBA6m+RSyVRpAiEA7t8WObBpjM2r7vrT6ohXvS/nLzqY/bC9hLLzkAJmFJA="}]},"maintainers":[{"name":"pimterry","email":"pimterry@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-fetch_0.3.1_1531694507705_0.2565215905731948"},"_hasShrinkwrap":false}},"readme":"# chai-fetch [![Travis Build Status](https://img.shields.io/travis/pimterry/chai-fetch.svg)](https://travis-ci.org/pimterry/chai-fetch)\n\nChai matchers to make matching fetch responses clear &amp; easy\n\n`fetch('http://example.com').then((response) => response.text()).then((text) => expect(text).to.equal('hi there'))`\nis pretty much the simplest way to assert on the body of a fetch response, and that's a huge horrible mess. This\nlibrary takes away that pain, and makes life easier.\n\n## Getting started\n\nInstall `chai-fetch` with:\n\n```js\nnpm install --save-dev chai-fetch\n```\n\nChai-fetch is a commonjs module, and should work out of the box in node, or with\nbundling tools like browserify & webpack.\n\nChai-fetch is written in TypeScript, so will work completely fine with JS, but\nif you're using TypeScript too you'll also get working typings out of the box.\n\nAn example test using this (with [http-server-mock](https://github.com/pimterry/http-server-mock)\nto fake HTTP responses) would look like:\n\n```js\nconst chai = require('chai');\nconst chaiFetch = require('chai-fetch');\nchai.use(chaiFetch);\n\nconst { expect } = chai;\n\ndescribe('Chai-fetch', () => {\n    beforeEach(() => mockServer.start(8080));\n    afterEach(() => mockServer.stop());\n\n    describe('.responseText', () => {\n        it('should match responses with matching bodies', () => {\n            mockServer.get('/match').thenReply(200, 'matching body')\n            .then(() =>\n                expect(fetch('http://localhost:8080/match')).to.have.responseText('matching body')\n            );\n        });\n    });\n});\n```\n\n## Tips\n\n* Remember that the assertions here are all asynchronous, so you need to `return` or `.then` or `await` on them, to\n  ensure that your test framework waits for the result and catches failures.\n\n* Take a look at [http-server-mock](https://github.com/pimterry/http-server-mock) to mock your server responses.\n\n* If you're writing HTTP tests like this, and you're using Babel, TypeScript or just some very modern JS engines,\nyou can make them a little more readable with async/await:\n\n    ```js\n    it('should match responses with matching bodies', async () => {\n        await mockServer.get('/match').thenReply(200, 'matching body');\n\n        await expect(fetch('http://localhost:8080/match')).to.have.responseText('matching body');\n    });\n    ```\n\n## API\n\n### `.responseText(expectedText)`\n\ne.g. `expect(fetch('http://example.com')).to.have.responseText('hi there')`\n\nIf the object being tested is a fetch response, or a promise for a fetch response, this asserts that the full text\nof the body is equal to the text given.\n\nYou can also pass a regular expression: `.responseText(/match a substring/)`.\n\nThis does _not_ test the status code (just like fetch itself doesn't), but both normal and negated tests will fail\nif a passed response promise is rejected entirely (e.g. if you have a network error).\n\n### `.status(expectedStatus)`\n\ne.g. `expect(fetch('http://example.com')).to.have.status(200)`\n\nIf the object being tested is a fetch response, or a promise for a fetch response, this asserts that the status of\nthe response is the status given.\n\n### More to come (file an issue!)","maintainers":[{"name":"pimterry","email":"pimterry@gmail.com"}],"time":{"modified":"2022-06-13T05:50:57.836Z","created":"2017-10-15T14:19:40.453Z","0.1.0":"2017-10-15T14:19:40.453Z","0.1.1":"2017-10-15T15:02:23.077Z","0.2.0":"2017-10-15T17:17:28.313Z","0.2.1":"2017-10-16T10:47:26.885Z","0.3.0":"2017-10-18T07:25:57.030Z","0.3.1":"2018-07-15T22:41:47.785Z"},"homepage":"https://github.com/pimterry/chai-fetch#readme","keywords":["fetch","chai","chai-plugin","assertions","node-fetch","fetch-polyfill","fetch-ponyfill","testing"],"repository":{"type":"git","url":"git+https://github.com/pimterry/chai-fetch.git"},"author":{"name":"Tim Perry","email":"pimterry@gmail.com"},"bugs":{"url":"https://github.com/pimterry/chai-fetch/issues"},"license":"MIT","readmeFilename":"README.md","users":{"pimterry":true}}