{"_id":"@bwilczek/hoverfly-client","_rev":"8-54f504957558f08ead3a008bb5960a00","name":"@bwilczek/hoverfly-client","dist-tags":{"latest":"0.0.10"},"versions":{"0.0.1":{"name":"@bwilczek/hoverfly-client","version":"0.0.1","keywords":["hoverfly"],"author":{"name":"Bartek Wilczek"},"license":"MIT","_id":"@bwilczek/hoverfly-client@0.0.1","maintainers":[{"name":"bwilczek","email":"bwilczek@gmail.com"}],"homepage":"https://github.com/bwilczek/hoverfly-client-node#readme","bugs":{"url":"https://github.com/bwilczek/hoverfly-client-node/issues"},"dist":{"shasum":"4b286e13f86058fbd8ad459588481a964ba3ce64","tarball":"https://registry.npmjs.org/@bwilczek/hoverfly-client/-/hoverfly-client-0.0.1.tgz","fileCount":3,"integrity":"sha512-2kZbAIDNv6AaGNvatpUr0VKHg3ll+y5ad80FFR0H0fZ+IlIzIHvwjX9qeBmUbmzasqCLAj0Nv+IbKO7jOWPYow==","signatures":[{"sig":"MEYCIQDpSQ98WyKbJ7nk6co+bwIyDtsnHbG7lzn71aTWcYlQPQIhAMQzN6VrS+SrGqCZaRJQnWSgvsj2VONXK8aSzI+wheAk","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1325},"main":"dist/index.js","types":"lib/index.d.ts","gitHead":"883446ac31de3c0877c945532563dcb3db928f68","scripts":{"lint":"eslint ./src","test":"jest","build":"tsc","format":"prettier ./src --write"},"_npmUser":{"name":"bwilczek","email":"bwilczek@gmail.com"},"repository":{"url":"git+https://github.com/bwilczek/hoverfly-client-node.git","type":"git"},"_npmVersion":"10.8.1","description":"Client lib for Hoverfly Proxy REST API","directories":{},"_nodeVersion":"20.15.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^9.13.0","ts-jest":"^29.2.5","prettier":"^3.3.3","@eslint/js":"^9.13.0","typescript":"^5.6.3","@types/jest":"^29.5.14","@eslint/eslintrc":"^3.1.0","jest-html-reporter":"^3.10.2","eslint-config-prettier":"^9.1.0","@typescript-eslint/parser":"^8.12.1","@typescript-eslint/eslint-plugin":"^8.12.1"},"_npmOperationalInternal":{"tmp":"tmp/hoverfly-client_0.0.1_1730194973136_0.9648534787936991","host":"s3://npm-registry-packages"}},"0.0.2":{"name":"@bwilczek/hoverfly-client","version":"0.0.2","keywords":["hoverfly"],"author":{"name":"Bartek Wilczek"},"license":"MIT","_id":"@bwilczek/hoverfly-client@0.0.2","maintainers":[{"name":"bwilczek","email":"bwilczek@gmail.com"}],"homepage":"https://github.com/bwilczek/hoverfly-client-node#readme","bugs":{"url":"https://github.com/bwilczek/hoverfly-client-node/issues"},"dist":{"shasum":"c07dee406cbffb90d7e571c0def4c042dc8b363c","tarball":"https://registry.npmjs.org/@bwilczek/hoverfly-client/-/hoverfly-client-0.0.2.tgz","fileCount":3,"integrity":"sha512-5mjaWNJtagGys0dU0zJDt374qLeP3+R5yeCSYd8mAeYqv7vkfDqOUg3Xxa+P53lpQWPK5//VSDGbCxTgQQ3SLA==","signatures":[{"sig":"MEUCIHokVgfYXAMAS99xTz+IX7bLtTKl61SO+FdMLGG+PzNbAiEA1+n9Rjx38C8OdLzJ2LXMuwGLOCEUbdRl/qvPAtosTao=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1326},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"d659177c195d343f604fa293aa31daa84419dbbe","scripts":{"lint":"eslint ./src","test":"jest","build":"tsc","format":"prettier ./src --write"},"_npmUser":{"name":"bwilczek","email":"bwilczek@gmail.com"},"repository":{"url":"git+https://github.com/bwilczek/hoverfly-client-node.git","type":"git"},"_npmVersion":"10.8.1","description":"Client lib for Hoverfly Proxy REST API","directories":{},"_nodeVersion":"20.15.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^9.13.0","ts-jest":"^29.2.5","prettier":"^3.3.3","@eslint/js":"^9.13.0","typescript":"^5.6.3","@types/jest":"^29.5.14","@eslint/eslintrc":"^3.1.0","jest-html-reporter":"^3.10.2","eslint-config-prettier":"^9.1.0","@typescript-eslint/parser":"^8.12.1","@typescript-eslint/eslint-plugin":"^8.12.1"},"_npmOperationalInternal":{"tmp":"tmp/hoverfly-client_0.0.2_1730195940453_0.9491003185163618","host":"s3://npm-registry-packages"}},"0.0.5":{"name":"@bwilczek/hoverfly-client","version":"0.0.5","keywords":["hoverfly"],"author":{"name":"Bartek Wilczek"},"license":"MIT","_id":"@bwilczek/hoverfly-client@0.0.5","maintainers":[{"name":"bwilczek","email":"bwilczek@gmail.com"}],"homepage":"https://github.com/bwilczek/hoverfly-client-node#readme","bugs":{"url":"https://github.com/bwilczek/hoverfly-client-node/issues"},"dist":{"shasum":"cfebbb4eec5111f34359019530bea9b18bdb4f96","tarball":"https://registry.npmjs.org/@bwilczek/hoverfly-client/-/hoverfly-client-0.0.5.tgz","fileCount":18,"integrity":"sha512-kbjhpg3nObUOYNxu0vMVDKkFtiIEXETGqvoZmfAKQnNMw/FWsWpC+x/0xQJYt1b6Vrt+ooJsOChRLvmn031Sbw==","signatures":[{"sig":"MEUCIHU0wUVg0m4S0DqUVji5JLSmd+fdCiqklns1Ro0Cj+bVAiEApKb9NPvQf9zpCC2QjwmLzQdF8TcKe4r7IHAYlrTTGcc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25387},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"ca04160dc223430621f7c87d7cb3e0def301e78f","scripts":{"lint":"eslint ./src","test":"jest","build":"tsc","format":"prettier ./src --write","pretest":"./bin/pretest.sh","checkall":"npm run lint && npm run format &&  npm run build && npm run test"},"_npmUser":{"name":"bwilczek","email":"bwilczek@gmail.com"},"repository":{"url":"git+https://github.com/bwilczek/hoverfly-client-node.git","type":"git"},"_npmVersion":"10.8.1","description":"Client lib for Hoverfly Proxy REST API","directories":{},"_nodeVersion":"20.15.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","axios":"^1.7.7","eslint":"^9.13.0","lodash":"^4.17.21","ts-jest":"^29.2.5","prettier":"^3.3.3","@eslint/js":"^9.13.0","typescript":"^5.6.3","@types/jest":"^29.5.14","@types/lodash":"^4.17.13","@eslint/eslintrc":"^3.1.0","jest-html-reporter":"^3.10.2","eslint-config-prettier":"^9.1.0","@typescript-eslint/parser":"^8.12.1","@typescript-eslint/eslint-plugin":"^8.12.1"},"_npmOperationalInternal":{"tmp":"tmp/hoverfly-client_0.0.5_1730751759293_0.4291516076356343","host":"s3://npm-registry-packages"}},"0.0.6":{"name":"@bwilczek/hoverfly-client","version":"0.0.6","keywords":["hoverfly"],"author":{"name":"Bartek Wilczek"},"license":"MIT","_id":"@bwilczek/hoverfly-client@0.0.6","maintainers":[{"name":"bwilczek","email":"bwilczek@gmail.com"}],"homepage":"https://github.com/bwilczek/hoverfly-client-node#readme","bugs":{"url":"https://github.com/bwilczek/hoverfly-client-node/issues"},"dist":{"shasum":"2040ba9a3979d6ce5cbe30b24bf64ede57763954","tarball":"https://registry.npmjs.org/@bwilczek/hoverfly-client/-/hoverfly-client-0.0.6.tgz","fileCount":18,"integrity":"sha512-emz+TDX6oYdXPx3rQrNq8WlaVET8Jgkfoa9CyDjK8V2tSfKfKobkloVAgsBJvCKp67YQnPWNOWOijia0gyK0mw==","signatures":[{"sig":"MEYCIQCcGDtFYbSt6AWDLRi5TPC/k1MgziLnvo7oIzS058mfmQIhALCds4cToDXTwN/t6zD7TsbuYMSujwXEuekO8/7r0CBn","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25387},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"24e9d24e288a2cb69533d402c52ac4691be2b54c","scripts":{"lint":"eslint ./src","test":"jest","build":"tsc","format":"prettier ./src --write","pretest":"./bin/pretest.sh","checkall":"npm run lint && npm run format &&  npm run build && npm run test"},"_npmUser":{"name":"bwilczek","email":"bwilczek@gmail.com"},"repository":{"url":"git+https://github.com/bwilczek/hoverfly-client-node.git","type":"git"},"_npmVersion":"10.8.1","description":"Client lib for Hoverfly Proxy REST API","directories":{},"_nodeVersion":"20.15.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","axios":"^1.7.7","eslint":"^9.13.0","lodash":"^4.17.21","ts-jest":"^29.2.5","prettier":"^3.3.3","@eslint/js":"^9.13.0","typescript":"^5.6.3","@types/jest":"^29.5.14","@types/lodash":"^4.17.13","@eslint/eslintrc":"^3.1.0","jest-html-reporter":"^3.10.2","eslint-config-prettier":"^9.1.0","@typescript-eslint/parser":"^8.12.1","@typescript-eslint/eslint-plugin":"^8.12.1"},"_npmOperationalInternal":{"tmp":"tmp/hoverfly-client_0.0.6_1730896647082_0.801944267823413","host":"s3://npm-registry-packages"}},"0.0.7":{"name":"@bwilczek/hoverfly-client","version":"0.0.7","keywords":["hoverfly"],"author":{"name":"Bartek Wilczek"},"license":"MIT","_id":"@bwilczek/hoverfly-client@0.0.7","maintainers":[{"name":"bwilczek","email":"bwilczek@gmail.com"}],"homepage":"https://github.com/bwilczek/hoverfly-client-node#readme","bugs":{"url":"https://github.com/bwilczek/hoverfly-client-node/issues"},"dist":{"shasum":"146db0b0deefd585a648d0bd68c229ab771567db","tarball":"https://registry.npmjs.org/@bwilczek/hoverfly-client/-/hoverfly-client-0.0.7.tgz","fileCount":18,"integrity":"sha512-lHYooKIbqAdth1k+rPpJvL592DzvroXiPsz+YnuzzQ0MAIv+ZZN7diaEZ4vjf8aDLtpRaMXS80lHughLw45Mpg==","signatures":[{"sig":"MEQCIHzhPerxW8Cs1rOUX/m+vmrSjlOG9bLpfZJ6Mvum6vikAiB3lxcYukw5FBuIfKcw0Y4B5kLL0niBLbKN92s9+F+ssQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":25711},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"ad25cd1b9557e86265a87753a5dc94f6130f9f40","scripts":{"lint":"eslint ./src","test":"jest","build":"tsc","format":"prettier ./src --write","pretest":"./bin/pretest.sh","checkall":"npm run lint && npm run format &&  npm run build && npm run test"},"_npmUser":{"name":"bwilczek","email":"bwilczek@gmail.com"},"repository":{"url":"git+https://github.com/bwilczek/hoverfly-client-node.git","type":"git"},"_npmVersion":"10.9.0","description":"Client lib for Hoverfly Proxy REST API","directories":{},"_nodeVersion":"22.11.0","dependencies":{"axios":"^1.7.7","lodash":"^4.17.21"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^9.13.0","ts-jest":"^29.2.5","prettier":"^3.3.3","@eslint/js":"^9.13.0","typescript":"^5.6.3","@types/jest":"^29.5.14","@types/lodash":"^4.17.13","@eslint/eslintrc":"^3.1.0","jest-html-reporter":"^3.10.2","eslint-config-prettier":"^9.1.0","@typescript-eslint/parser":"^8.12.1","@typescript-eslint/eslint-plugin":"^8.12.1"},"_npmOperationalInternal":{"tmp":"tmp/hoverfly-client_0.0.7_1755090557682_0.4297050325355818","host":"s3://npm-registry-packages-npm-production"}},"0.0.8":{"name":"@bwilczek/hoverfly-client","version":"0.0.8","keywords":["hoverfly"],"author":{"name":"Bartek Wilczek"},"license":"MIT","_id":"@bwilczek/hoverfly-client@0.0.8","maintainers":[{"name":"bwilczek","email":"bwilczek@gmail.com"}],"homepage":"https://github.com/bwilczek/hoverfly-client-node#readme","bugs":{"url":"https://github.com/bwilczek/hoverfly-client-node/issues"},"dist":{"shasum":"76a944201537d6ff5b2ac7584781727bc1f466a0","tarball":"https://registry.npmjs.org/@bwilczek/hoverfly-client/-/hoverfly-client-0.0.8.tgz","fileCount":20,"integrity":"sha512-e0hDuIkd+261D6dEQCmHX13owXbp5NglXaA0Xs5c2YF/yXxYvHtOIlDzJHLlwEIfbGenT4cwStEpw2g+0h0nKg==","signatures":[{"sig":"MEUCIQC/EUOQDeTHe1MJfqHvHRuuzqjDCBQPaadt+HLouitV4gIgGF+vDRUm2my4V1m18tgmvpvCgKpbZgMaPgVV85dVdaE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27673},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"93d939e578f0303cc43534dad16297b139364263","scripts":{"lint":"eslint ./src","test":"jest","build":"tsc","format":"prettier ./src --write","pretest":"./bin/pretest.sh","checkall":"npm run lint && npm run format &&  npm run build && npm run test"},"_npmUser":{"name":"bwilczek","email":"bwilczek@gmail.com"},"repository":{"url":"git+https://github.com/bwilczek/hoverfly-client-node.git","type":"git"},"_npmVersion":"10.9.0","description":"Client lib for Hoverfly Proxy REST API","directories":{},"_nodeVersion":"22.11.0","dependencies":{"axios":"^1.7.7","lodash":"^4.17.21"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^9.13.0","ts-jest":"^29.2.5","prettier":"^3.3.3","@eslint/js":"^9.13.0","typescript":"^5.6.3","@types/jest":"^29.5.14","@types/lodash":"^4.17.13","@eslint/eslintrc":"^3.1.0","jest-html-reporter":"^3.10.2","eslint-config-prettier":"^9.1.0","@typescript-eslint/parser":"^8.12.1","@typescript-eslint/eslint-plugin":"^8.12.1"},"_npmOperationalInternal":{"tmp":"tmp/hoverfly-client_0.0.8_1759140162124_0.3968392880236915","host":"s3://npm-registry-packages-npm-production"}},"0.0.9":{"name":"@bwilczek/hoverfly-client","version":"0.0.9","keywords":["hoverfly"],"author":{"name":"Bartek Wilczek"},"license":"MIT","_id":"@bwilczek/hoverfly-client@0.0.9","maintainers":[{"name":"bwilczek","email":"bwilczek@gmail.com"}],"homepage":"https://github.com/bwilczek/hoverfly-client-node#readme","bugs":{"url":"https://github.com/bwilczek/hoverfly-client-node/issues"},"dist":{"shasum":"f80ef04b02a27c576478bbbe7f63df6d50fff25f","tarball":"https://registry.npmjs.org/@bwilczek/hoverfly-client/-/hoverfly-client-0.0.9.tgz","fileCount":2,"integrity":"sha512-aY+9iVyYwjGP3Nph4FpG0blnMZqMo6/ahGc37fYNSJi4KpYZaV6Ip2RP3gL317moIFm7JaCtN1oT/yHYrbpomg==","signatures":[{"sig":"MEYCIQDOUbzXxGyBe1E8c4ARi9kD69uOwCZJMFtPDYo9qqDM+AIhALl2D0b53DQo/pgN/kTx4otebYQgAcnWetSsWCrdWlzu","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10762},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"a1068cf5fa02dcfefb2f8ac2fe183f4667e1bef9","scripts":{"lint":"eslint ./src","test":"jest","build":"tsc","format":"prettier ./src --write","pretest":"./bin/pretest.sh","checkall":"npm run lint && npm run format &&  npm run build && npm run test"},"_npmUser":{"name":"bwilczek","email":"bwilczek@gmail.com"},"repository":{"url":"git+https://github.com/bwilczek/hoverfly-client-node.git","type":"git"},"_npmVersion":"8.19.3","description":"Client lib for Hoverfly Proxy REST API","directories":{},"_nodeVersion":"18.13.0","dependencies":{"axios":"^1.7.7","lodash":"^4.17.21"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^9.13.0","ts-jest":"^29.2.5","prettier":"^3.3.3","@eslint/js":"^9.13.0","typescript":"^5.6.3","@types/jest":"^29.5.14","@types/lodash":"^4.17.13","@eslint/eslintrc":"^3.1.0","jest-html-reporter":"^3.10.2","eslint-config-prettier":"^9.1.0","@typescript-eslint/parser":"^8.12.1","@typescript-eslint/eslint-plugin":"^8.12.1"},"_npmOperationalInternal":{"tmp":"tmp/hoverfly-client_0.0.9_1765831732832_0.7672237613649886","host":"s3://npm-registry-packages-npm-production"}},"0.0.10":{"name":"@bwilczek/hoverfly-client","version":"0.0.10","description":"Client lib for Hoverfly Proxy REST API","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","lint":"eslint ./src","format":"prettier ./src --write","pretest":"./bin/pretest.sh","test":"jest","checkall":"npm run lint && npm run format &&  npm run build && npm run test"},"repository":{"type":"git","url":"git+https://github.com/bwilczek/hoverfly-client-node.git"},"keywords":["hoverfly"],"author":{"name":"Bartek Wilczek"},"license":"MIT","bugs":{"url":"https://github.com/bwilczek/hoverfly-client-node/issues"},"homepage":"https://github.com/bwilczek/hoverfly-client-node#readme","dependencies":{"axios":"^1.7.7","lodash":"^4.17.21"},"devDependencies":{"@eslint/eslintrc":"^3.1.0","@eslint/js":"^9.13.0","@types/jest":"^29.5.14","@types/lodash":"^4.17.13","@typescript-eslint/eslint-plugin":"^8.12.1","@typescript-eslint/parser":"^8.12.1","eslint":"^9.13.0","eslint-config-prettier":"^9.1.0","jest":"^29.7.0","jest-html-reporter":"^3.10.2","prettier":"^3.3.3","ts-jest":"^29.2.5","typescript":"^5.6.3"},"gitHead":"a0168ae18837961d8bf33fe71571bab787dd1586","_id":"@bwilczek/hoverfly-client@0.0.10","_nodeVersion":"18.13.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-Gh4LR7peDB5qfe6XGLsgiak8uZNZgsbecPjLgKnbFhF1chQgBYBIzzc9KYtshX0gPcu1heccjKZRVxu4SSgknA==","shasum":"a67f88f154623c383bc9d45cd9900d75af1c7a08","tarball":"https://registry.npmjs.org/@bwilczek/hoverfly-client/-/hoverfly-client-0.0.10.tgz","fileCount":20,"unpackedSize":27674,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICYrCYSlNKU1wG2pAeVTK9qsQdIFMbsK1bpl7ZqH0bjtAiBaIlWJRxi2yeI2MkTSMpcLfd6HT+lTGho3DCc0i0LGZw=="}]},"_npmUser":{"name":"bwilczek","email":"bwilczek@gmail.com"},"directories":{},"maintainers":[{"name":"bwilczek","email":"bwilczek@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/hoverfly-client_0.0.10_1765835354528_0.6481381710823797"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-29T09:42:53.032Z","modified":"2025-12-15T21:49:14.899Z","0.0.1":"2024-10-29T09:42:53.302Z","0.0.2":"2024-10-29T09:59:00.642Z","0.0.5":"2024-11-04T20:22:39.599Z","0.0.6":"2024-11-06T12:37:27.263Z","0.0.7":"2025-08-13T13:09:17.866Z","0.0.8":"2025-09-29T10:02:42.304Z","0.0.9":"2025-12-15T20:48:52.982Z","0.0.10":"2025-12-15T21:49:14.712Z"},"bugs":{"url":"https://github.com/bwilczek/hoverfly-client-node/issues"},"author":{"name":"Bartek Wilczek"},"license":"MIT","homepage":"https://github.com/bwilczek/hoverfly-client-node#readme","keywords":["hoverfly"],"repository":{"type":"git","url":"git+https://github.com/bwilczek/hoverfly-client-node.git"},"description":"Client lib for Hoverfly Proxy REST API","maintainers":[{"name":"bwilczek","email":"bwilczek@gmail.com"}],"readme":"# Overview\n\nThis repository contains a `node` client library for [Hoverfly Proxy REST API](https://docs.hoverfly.io/en/latest/pages/reference/api/api.html#).\n\nHoverfly is an HTTP Proxy service designed to support E2E testing of multi-service applications. It can:\n* serve pre-recorded responses for communication with external services\n* record communication with external services\n* simulate delays and outages in communication\n* and [much more](https://docs.hoverfly.io/en/latest/pages/keyconcepts/keyconcepts.html)\n\nIn order to make the application under test benefit from `Hoverfly` it has to be configured to route\nits HTTP requests through the proxy. In most cases setting up environment variables (`http_proxy`, `https_proxy`, `no_proxy`) is sufficient,\nbut some HTTP clients may require additional setup. `Hoverfly` exposes the proxy service on port 8500.\n\nOnce the application under test is configured to use the `Hoverfly` proxy on port 8500 the test code can control the proxy behavior\nusing the REST interface exposed on port 8888. This is where this library comes in.\n\n# Usage\n\n## Setup\n\nInstallation of the node package is standard:\n\n```shell\n# with npm\nnpm install -D @bwilczek/hoverfly-client\n\n# with yarn\nyarn add --dev @bwilczek/hoverfly-client\n```\n\n`Hoverfly` can be started locally using `docker`:\n\n```\ndocker run --name hoverfly -d -p 8888:8888 -p 8500:8500 spectolabs/hoverfly:latest\n```\n\n### SSL Certificate\n\n`Hoverfly` comes bundled with an SSL certificate that is required to proxy traffic to secure websites.\nHowever, as it is a testing tool, this certificate is self signed, and needs to be explicitly marked as trusted.\nA copy of Hoverfly's `pem` file can be found in `tests/res/cert.pem`.\n\nMarking it as trusted can vary depending on the OS or HTTP client. Here are some examples:\n\n* System setting in `debian` family: `cp tests/res/cert.pem /usr/local/share/ca-certificates/hoverfly.crt && update-ca-certificates`\n* Python's `requests` package: `REQUESTS_CA_BUNDLE=tests/res/cert.pem`\n* Node's extra CA setting: `NODE_EXTRA_CA_CERTS=tests/res/cert.pem`\n* Curl's extra CA setting: `CURL_CA_BUNDLE=tests/res/cert.pem` (it should respect system settings though)\n* Others may vary and depend on the package\n\n## Sample workflow\n\nLet's use `curl` to demonstrate how to use and control `Hoverfly` proxy.\n\n### Capturing an example request to `httpbingo.org`.\n\n```typescript\nimport { Client } from \"@bwilczek/hoverfly-client\"\n\nconst client = new Client(\"http://127.0.0.1:8888\")\nawait client.setMode({mode: 'capture'})\n```\n\n`Hoverfly` proxy will be capturing the request/response pairs and storing them internally as a [Simulation](https://docs.hoverfly.io/en/latest/pages/keyconcepts/simulations/simulations.html).\n\nNow let's perform the request:\n\n```shell\nexport http_proxy=http://127.0.0.1:8500\nexport https_proxy=http://127.0.0.1:8500\nexport no_proxy=127.0.0.1,localhost\nexport CURL_CA_BUNDLE=tests/res/cert.pem # if cert is not added to system store\n\ncurl https://httpbingo.org/status/418  # displays \"I'm a teapot!\"\n```\n\nAt this stage Hoverfly has the request-response pair recorded and stored in process memory.\n\nThis pair can now be stored for further use:\n\n```shell\ncurl http://127.0.0.1:8888/api/v2/simulation > teapot.json\n```\nor alternatively\n```typescript\nimport { saveSimulationToFile } from \"@bwilczek/hoverfly-client\"\n\nconst sim = await client.getSimulation()\nsaveSimulationToFile(sim, 'teapot.json')\n```\n\n### Serving prepared responses\n\nIn order to make `Hoverfly` serve a specific response proper Simulation object needs to be uploaded.\nThere are two ways to craft a simulation:\n\n#### Edit the JSON file\n\nOpen the `teapot.json` file created in the previous step in any text editor. Format it, introduce the changes, and save.\nFor this example let's change the response body from `I'm a teapot!` to `I used to be a teapot!`.\n\nAfter the file is saved uploading it to `Hoverfly` can be achieved with:\n\n```typescript\nimport { buildSimulationFromFile } from \"@bwilczek/hoverfly-client\"\n\nconst sim = buildSimulationFromFile('teapot.json')\nawait client.uploadSimulation(sim)\n```\n\n#### Craft Simulation programmatically\n\n```typescript\nimport { buildSimulation, ResponseData, RequestMatcher } from \"@bwilczek/hoverfly-client\"\n\nconst response: ResponseData = {\n  status: 200,\n  body: 'I used to be a teapot!',\n  encodedBody: false,\n  templated: false\n}\n\nconst request: RequestMatcher = {\n  path: [{ matcher: 'exact', value: '/status/418' }],\n  destination: [{ matcher: 'exact', value: 'httpbingo.org' }],\n}\n\nconst pair = { request: request, response: response }\n\nconst sim = buildSimulation([pair])\nawait client.uploadSimulation(sim)\n```\n\nNow, in order to make `Hoverfly` serve the responses from the uploaded simulation\nits operation mode needs to be changed from `capture` to `simulate`:\n\n```typescript\nawait client.setMode({mode: 'simulate'})\n```\n\nA this stage `curl` will receive the forged response from `Hoverfly`, and no traffic to external service will take a place.\n\n```shell\nexport http_proxy=http://127.0.0.1:8500\nexport https_proxy=http://127.0.0.1:8500\nexport no_proxy=127.0.0.1,localhost\nexport CURL_CA_BUNDLE=tests/res/cert.pem # if cert is not added to system store\n\ncurl https://httpbingo.org/status/418  # displays \"I used to be a teapot!\"\n```\n\n## Managing Simulations\n\nIn more complex test suites there will be multiple request/response pairs\nthat will be activated, modified or deactivated during the test suite execution.\nHere's how to deal with such use cases.\n\n```typescript\nimport { buildSimulationFromFile, Client } from \"@bwilczek/hoverfly-client\"\n\nconst client = new Client(\"http://127.0.0.1:8888\")\n\n// upload a set of request/response pairs that should be always active\nawait client.uploadSimulation(buildSimulationFromFile('always_active_stubs.json'))\n\n// add request/response pair that will simulate specific condition\nawait client.appendSimulation(buildSimulationFromFile('google_auth_failure.json'))\n\n// remove that pair\nawait client.removeSimulation(buildSimulationFromFile('google_auth_failure.json'))\n\n// or just upload the default set again, overwriting the current state\nawait client.uploadSimulation(buildSimulationFromFile('always_active_stubs.json'))\n```\n\nThere are also two support functions that could be useful when crafting simulation instances manually:\n\n* `mergeSimulations(left: Simulation, right: Simulation): Simulation`\n* `subtractSimulations(left: Simulation, right: Simulation): Simulation`\n\n## Inspecting processed requests\n\nOne of typical assertions in an E2E/integration test suite is something like:\n\n*Assert that some service has been requested with given parameters*\n\nHoverfly provides tooling for such assertions through the concept of `Journal`. Example:\n\n```typescript\n// Testing communication with external payment provider\n\n// pre-requisite: make sure that the communication with the real system has been recorded before\n// then saved as `simulations/payments.json` and modified if required\n\n// prepare Hoverfly for the expected communication with payment provider\nawait client.uploadSimulation(buildSimulationFromFile('simulations/payments.json'))\n// without this simulation being loaded any request to payment provider will result in an exception\n// that's how Hoverfly works in `simulate` mode, and that's what we want in E2E test\n\n// do some actions in the UI, that will make the app under test perform a request to payment provider\nawait browser.submitPaymentButton.click()\n\n// assert that the backend really performed a request to the payment provider\nconst paymentsJournal = await client.searchJournal({request: {destination: [{matcher: \"exact\", value: \"payment.provider\"}]}})\nexpect(paymentsJournal.journal.length).toBe(1)\n```\n\n## Supported REST endpoints\n\n[Hoverfly Proxy REST API](https://docs.hoverfly.io/en/latest/pages/reference/api/api.html#) exposes more than 40 endpoints.\nThis library, at this stage, supports the following subset, represented as methods of `Client` class:\n\n* `GET /api/v2/hoverfly/mode` : `getMode(): Promise<ModePayload>`\n* `PUT /api/v2/hoverfly/mode` : `setMode(payload: SetModePayload): Promise<ModePayload>`\n* `GET /api/v2/hoverfly/destination` : `getDestination(): Promise<DestinationPayload>`\n* `PUT /api/v2/hoverfly/destination` : `setDestination(payload: DestinationPayload): Promise<DestinationPayload>`\n* `GET /api/v2/hoverfly/middleware` : `getMiddleware(): Promise<MiddlewarePayload>`\n* `PUT /api/v2/hoverfly/middleware` : `setMiddleware(payload: MiddlewarePayload): Promise<MiddlewarePayload>`\n* `purgeMiddleware(): Promise<MiddlewarePayload>` - sets current middleware to an empty object\n* `DELETE /api/v2/journal` - `purgeJournal(): Promise<Journal>`\n* `GET /api/v2/journal` - `getJournal(): Promise<Journal>`\n* `POST /api/v2/journal` - `searchJournal(payload: JournalSearchPayload): Promise<Journal>`\n* `DELETE /api/v2/simulation` - `purgeSimulation(): Promise<Simulation>`\n* `GET /api/v2/simulation` - `getSimulation(): Promise<Simulation>`\n* `PUT /api/v2/simulation` - `uploadSimulation(payload: Simulation): Promise<Simulation>`\n\n## Development status\n\nThis library is in its early development stage.\nIt lacks more thorough test coverage and not all endpoints are covered.\n\nThe current functionality is enough for most of E2E/integration testing use cases.\nIt will extended gradually over time.\n\nFeel free to contribute with PRs and report any ideas or bugs are GH issues.\n","readmeFilename":"README.md"}