{"_id":"protractor-http-client","_rev":"8-5666018fabdced4c5461e430ea35c858","name":"protractor-http-client","dist-tags":{"latest":"1.0.4"},"versions":{"0.1.0":{"name":"protractor-http-client","version":"0.1.0","description":"HTTP client to be used in protractor tests","keywords":["protractor","http","rest","client","test","selenium","webdriver"],"homepage":"https://github.com/marcodave/protractor-http-client","scripts":{"build":"npm run compile && npm test","compile":"tsc","test":"protractor dist/test/protractor.conf.js","preversion":"npm build","postversion":"git push && git push --tags"},"dependencies":{"request":"^2.83.0"},"devDependencies":{"protractor":"^4","@types/request":"2.47.0","typescript":"^2.7"},"author":{"name":"Marco Dalla Vecchia","email":"mdallav@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/marcodave/protractor-http-client.git"},"main":"dist/lib/http-client.js","gitHead":"b9ecaa29d7476f90384fd199948a11c6e946852f","bugs":{"url":"https://github.com/marcodave/protractor-http-client/issues"},"_id":"protractor-http-client@0.1.0","_shasum":"92133d95f2e5fa91c8cc224a447ad353357265d0","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"marcodave","email":"mdallav@gmail.com"},"dist":{"shasum":"92133d95f2e5fa91c8cc224a447ad353357265d0","tarball":"https://registry.npmjs.org/protractor-http-client/-/protractor-http-client-0.1.0.tgz","fileCount":5,"unpackedSize":7652,"integrity":"sha512-vZZnLA9D8/3eCf6krb3iSGaW9ClIkVBMv8SiYg8kojOnHd9l1RPVMM8MYAETHTkqs+ZSjeaf7YVRxZZUIZBmRg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDlteDe3DN3QCGZY0hUAG+MNqh1g0x1ij3yIQb4EaHRiQIgNdyfdhvBR4/FsW/CH9A8U16wDZ4lEWaZSvDC1vZx12k="}]},"maintainers":[{"name":"marcodave","email":"mdallav@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/protractor-http-client_0.1.0_1519578963688_0.1895157429581924"},"_hasShrinkwrap":false},"1.0.0-0":{"name":"protractor-http-client","version":"1.0.0-0","description":"HTTP client to be used in protractor tests","keywords":["protractor","http","rest","client","test","selenium","webdriver"],"homepage":"https://github.com/marcodave/protractor-http-client","scripts":{"postinstall":"webdriver-manager update","build":"npm test","compile":"tsc","pretest":"tsc","test":"protractor dist/test/protractor.conf.js","prepublish":"npm test && npm version patch","postpublish":"npm version prerelease && git push --all"},"dependencies":{"request":"^2.83.0"},"devDependencies":{"@types/request":"2.47.0","@types/jasminewd2":"2.x","phantomjs-prebuilt":"^2.1.16","protractor":"^4","typescript":"^2.7"},"author":{"name":"Marco Dalla Vecchia","email":"mdallav@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/marcodave/protractor-http-client.git"},"main":"dist/lib/http-client.js","gitHead":"2e015d1297fa8762121f25fb63683f3c4193c427","bugs":{"url":"https://github.com/marcodave/protractor-http-client/issues"},"_id":"protractor-http-client@1.0.0-0","_shasum":"55cbf2e3c3fbdddc9d9d260103b82fa059f79f89","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"marcodave","email":"mdallav@gmail.com"},"dist":{"shasum":"55cbf2e3c3fbdddc9d9d260103b82fa059f79f89","tarball":"https://registry.npmjs.org/protractor-http-client/-/protractor-http-client-1.0.0-0.tgz","fileCount":5,"unpackedSize":8170,"integrity":"sha512-rJNxLPazCtDlMVdVRL/rQhuiw18LnWmgnZZnMnXnATrKx5uif/eq7S7u90wDRb3LsGNxKy18WSN0EGbvPCgM3A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGJMoAGlvA2JrhmTFGZqi0szJGJ55KNpjMjCBK+ERzocAiAnrnWACo5Yhq3F84epSwCaCfVst0MzwFC+n9tcMvMm6Q=="}]},"maintainers":[{"name":"marcodave","email":"mdallav@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/protractor-http-client_1.0.0-0_1519838327670_0.9929165767191246"},"_hasShrinkwrap":false},"1.0.1":{"name":"protractor-http-client","version":"1.0.1","description":"HTTP client to be used in protractor tests","keywords":["protractor","http","rest","client","test","selenium","webdriver"],"homepage":"https://github.com/marcodave/protractor-http-client","scripts":{"postinstall":"webdriver-manager update","build":"npm test","compile":"tsc","pretest":"tsc","test":"protractor dist/test/protractor.conf.js","release":"npm version patch && npm publish","prepublish":"npm test","postpublish":"npm version prerelease && git push --all"},"dependencies":{"request":"^2.83.0"},"devDependencies":{"@types/request":"2.47.0","@types/jasminewd2":"2.x","phantomjs-prebuilt":"^2.1.16","protractor":"^4","typescript":"^2.7"},"author":{"name":"Marco Dalla Vecchia","email":"mdallav@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/marcodave/protractor-http-client.git"},"main":"dist/lib/http-client.js","gitHead":"da027974ca80d0914793b3857d76cfa564b8da0f","bugs":{"url":"https://github.com/marcodave/protractor-http-client/issues"},"_id":"protractor-http-client@1.0.1","_shasum":"23df64283d976ccd0489b4e7db8820de377396e0","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"marcodave","email":"mdallav@gmail.com"},"dist":{"shasum":"23df64283d976ccd0489b4e7db8820de377396e0","tarball":"https://registry.npmjs.org/protractor-http-client/-/protractor-http-client-1.0.1.tgz","fileCount":5,"unpackedSize":8200,"integrity":"sha512-lKoLdClPYzk9ocR8D2dHBQa3BNScHefdx52t7eQ0xtmg4SC/AUea4I2B2Uj1OgimNuiZfF1nGlAWYTCDfHIFYQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC7DHLOcvy3KAtpcSwIsgXWN31elwzln96tyy1e5HAZgwIgWdP1BEieV+GIBzxzZfWMh2qD5YTqKFMK8GpQhyCC84Q="}]},"maintainers":[{"name":"marcodave","email":"mdallav@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/protractor-http-client_1.0.1_1519838914514_0.48471101205145795"},"_hasShrinkwrap":false},"1.0.2":{"name":"protractor-http-client","version":"1.0.2","description":"HTTP client to be used in protractor tests","keywords":["protractor","http","rest","client","test","selenium","webdriver"],"homepage":"https://github.com/marcodave/protractor-http-client","scripts":{"build":"npm test","compile":"tsc","pretest":"tsc","test":"webdriver-manager update && protractor dist/test/protractor.conf.js","prepublish":"npm test","postpublish":"npm version patch && git push && git push --tags"},"dependencies":{"request":"^2.83.0"},"devDependencies":{"@types/request":"2.47.0","@types/jasminewd2":"2.x","phantomjs-prebuilt":"^2.1.16","protractor":"^4","typescript":"^2.7"},"author":{"name":"Marco Dalla Vecchia","email":"mdallav@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/marcodave/protractor-http-client.git"},"main":"dist/lib/http-client.js","gitHead":"df18b6001674647b8872c1562f7954ccaa600026","bugs":{"url":"https://github.com/marcodave/protractor-http-client/issues"},"_id":"protractor-http-client@1.0.2","_shasum":"64c5c6673cee2458c8098c67898b1e12d047ff81","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"marcodave","email":"mdallav@gmail.com"},"dist":{"shasum":"64c5c6673cee2458c8098c67898b1e12d047ff81","tarball":"https://registry.npmjs.org/protractor-http-client/-/protractor-http-client-1.0.2.tgz","fileCount":5,"unpackedSize":8138,"integrity":"sha512-VOK4+VT3xssj2/tj/5yC4sb8jCKTHeifTwcLBjHJALfyeRyJ+PxMrSd7cPT1lA6YQ3bKkfhJlPg2wbLIPqUeGg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE9SQAMLV1zR7E03u648OPdH6aqb0DNkpTzKxhZyFLm+AiAmlHIBPsz+OezGmHtEX7E3CZCAEmGkYy1SRogcLj1DwQ=="}]},"maintainers":[{"name":"marcodave","email":"mdallav@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/protractor-http-client_1.0.2_1519889598035_0.21261648023953428"},"_hasShrinkwrap":false},"1.0.3":{"name":"protractor-http-client","version":"1.0.3","description":"HTTP client to be used in protractor tests","keywords":["protractor","http","rest","client","test","selenium","webdriver"],"homepage":"https://github.com/marcodave/protractor-http-client","scripts":{"compile":"tsc","pretest":"tsc","test":"webdriver-manager update && protractor dist/test/protractor.conf.js","prepublish":"npm test"},"dependencies":{"request":"^2.83.0"},"devDependencies":{"@types/request":"2.47.0","@types/jasminewd2":"2.x","phantomjs-prebuilt":"^2.1.16","protractor":"^4","typescript":"^2.7"},"author":{"name":"Marco Dalla Vecchia","email":"mdallav@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/marcodave/protractor-http-client.git"},"main":"dist/http-client.js","gitHead":"ab2b153d9ee34f9657d8665abd14ce77bacb10da","bugs":{"url":"https://github.com/marcodave/protractor-http-client/issues"},"_id":"protractor-http-client@1.0.3","_shasum":"9d7e56b8d197a5cb65866c24060af90035527bc2","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"marcodave","email":"mdallav@gmail.com"},"dist":{"shasum":"9d7e56b8d197a5cb65866c24060af90035527bc2","tarball":"https://registry.npmjs.org/protractor-http-client/-/protractor-http-client-1.0.3.tgz","fileCount":11,"unpackedSize":19359,"integrity":"sha512-QPzjhv3Bxc6jx7llWTznG46iG2XHqjcLGMhIlwdf2QaZEBYdDwDJ5ykWEcSd26mghP5CAbc1gNCn8zEMrvallA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE8w+OTzO3JDzr5erBriZkbRfpVZLRF2vPrNvBScM6o4AiEAjvjRQ21Hv4dcEoyp/8/Aw1mobboBHpP/hrbBkE/dM2Q="}]},"maintainers":[{"name":"marcodave","email":"mdallav@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/protractor-http-client_1.0.3_1519939847465_0.9076912900035052"},"_hasShrinkwrap":false},"1.0.4":{"name":"protractor-http-client","version":"1.0.4","description":"HTTP client to be used in protractor tests","keywords":["protractor","http","rest","client","test","selenium","webdriver"],"homepage":"https://github.com/marcodave/protractor-http-client","scripts":{"compile":"tsc","pretest":"tsc","test":"webdriver-manager update && protractor dist/test/protractor.conf.js"},"dependencies":{"request":"^2.83.0"},"devDependencies":{"@types/request":"2.47.0","@types/jasminewd2":"2.x","phantomjs-prebuilt":"^2.1.16","protractor":"^4","typescript":"^2.7"},"author":{"name":"Marco Dalla Vecchia","email":"mdallav@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/marcodave/protractor-http-client.git"},"main":"dist/http-client.js","gitHead":"46066704ce083880b923c3bef25739fb169e350f","bugs":{"url":"https://github.com/marcodave/protractor-http-client/issues"},"_id":"protractor-http-client@1.0.4","_shasum":"f8eeaf273ec13e28d75b9630268b00715cb8fca6","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"marcodave","email":"mdallav@gmail.com"},"dist":{"shasum":"f8eeaf273ec13e28d75b9630268b00715cb8fca6","tarball":"https://registry.npmjs.org/protractor-http-client/-/protractor-http-client-1.0.4.tgz","fileCount":11,"unpackedSize":19011,"integrity":"sha512-lEwlYky76XfYU5rXU/N9MoIls8Ee8YusDhGcgXPNbKXSFC/qnINEMML6wM7Mq00GUL7cbH1U4695ePncFmwc9A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHo5sJHptrQzIwOFxmENcvAxVKbyTrOcWAb3JKrAcnQXAiAU0iGKtM97UXj11mKMlQqhb40eNdqMQFxDaCMJxbbgtg=="}]},"maintainers":[{"name":"marcodave","email":"mdallav@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/protractor-http-client_1.0.4_1519941265703_0.856149672526227"},"_hasShrinkwrap":false}},"time":{"created":"2018-02-25T17:16:03.688Z","0.1.0":"2018-02-25T17:16:03.753Z","modified":"2022-06-24T21:25:37.977Z","1.0.0-0":"2018-02-28T17:18:47.931Z","1.0.1":"2018-02-28T17:28:34.556Z","1.0.2":"2018-03-01T07:33:18.092Z","1.0.3":"2018-03-01T21:30:47.509Z","1.0.4":"2018-03-01T21:54:25.753Z"},"maintainers":[{"name":"marcodave","email":"mdallav@gmail.com"}],"description":"HTTP client to be used in protractor tests","homepage":"https://github.com/marcodave/protractor-http-client","keywords":["protractor","http","rest","client","test","selenium","webdriver"],"repository":{"type":"git","url":"git+https://github.com/marcodave/protractor-http-client.git"},"author":{"name":"Marco Dalla Vecchia","email":"mdallav@gmail.com"},"bugs":{"url":"https://github.com/marcodave/protractor-http-client/issues"},"license":"MIT","readme":"# protractor-http-client\r\nHTTP Client library to use in protractor tests\r\n\r\n[![Build Status](https://api.travis-ci.org/marcodave/protractor-http-client.svg?branch=master)](https://travis-ci.org/marcodave/protractor-http-client)\r\n\r\n# What this library is about\r\nAre you using [protractor](https://www.npmjs.com/package/protractor) ? me too, and it's awesome! This library is a little utility\r\nthat allows you to make any HTTP call (GET, PUT, POST, ...) , leveraging the powerful [request](https://www.npmjs.com/package/request) library.\r\n\r\nThis library allows you to call HTTP services before, after or during interactions within the browser.\r\n\r\n## Why is it useful?\r\nfor example, for setting up test data via REST API before a test is run, or cleaning up after a test has finished running.\r\n\r\nIt won't be easy to do the same with plain 'http' or 'request' module, as you will have to wait for the HTTP\r\ncall promise to complete, before using the protractor browser calls.\r\n\r\nInstead, you have to just call e.g.\r\n```javascript\r\nhttp.post(\"/database/users\", {\r\n    username: \"marco\", password: \"bigsecret\"\r\n})\r\nbrowser.get(\"/login\") // this will wait for the previous call to finish\r\n// initiate login with \"marco\" user\r\n```\r\nand the subsequent calls to protractor API will wait until the previous call finishes.\r\n\r\n# Requirements\r\n* Protractor 3+ (tested with 3.3.0 and 4.0.14)\r\n* Node 4.2+\r\n\r\n# Usage\r\nIf using Javascript specs\r\n```javascript\r\nconst HttpClient = require(\"protractor-http-client\").HttpClient\r\n```\r\nIf using Typescript specs\r\n```typescript\r\nimport {HttpClient} from \"protractor-http-client\"\r\n```\r\n\r\n```typescript\r\nconst http = new HttpClient(\"https://example.com/\")\r\n\r\n// HTTP GET\r\nconst userGetResponse:ResponsePromise = http.get(\"/users/marco\");\r\n// HTTP POST with JSON, automatically sets Content-Type: application/json\r\nhttp.post(\"/users\", {\r\n    username: \"marco\", password: \"bigsecret\"\r\n}));\r\n// HTTP POST, with form data and custom content type\r\nhttp.post(\"/form\", \"param1=value1&param2=value2\", {\r\n    \"Content-Type\": \"application/x-www-form-urlencoded\"\r\n}));\r\n// make HTTP calls fail and throw an exception when response code is not 2xx\r\n// default behavior is to continue on any HTTP status code\r\nhttp.failOnError = true\r\n```\r\n\r\nYou have `get`, `post`, `put`, `delete` methods available.\r\n`get` and `delete` methods do NOT accept request body.\r\nFor more complex requests, use the `request` method shown below.\r\n\r\n## Passing complex request options\r\nYou can pass [any options accepted by the request library](https://www.npmjs.com/package/request#requestoptions-callback), by passing an object to the request method\r\n```javascript\r\nlet options = { .... }\r\nhttp.request(options)\r\n```\r\n\r\n## Helper methods on response to check status and body\r\n```typescript\r\nlet response:ResponsePromise = http.get(\"/users/marco\")\r\nlet jsonResponse:JsonPromise = response.jsonBody\r\nlet stringBody:Promise<string> = response.stringBody\r\nlet rawBody:Promise<Buffer> = response.body\r\n\r\nlet jsonPropertyValue:JsonPromise = response.jsonBody.get(\"propertyName\")\r\n\r\nexpect(response.statusCode).toEqual(200)\r\nexpect(response.header(\"Content-Type\")).toEqual(\"application/json\")\r\nexpect(response.stringBody).toEqual('{\"username\":\"marco\",\"password\":\"bigsecret\"}')\r\nexpect(response.jsonBody.get(\"username\")).toEqual(\"marco\")\r\n```\r\n\r\n## Example spec with API setup\r\n```javascript\r\ndescribe(\"the login page\", () => {\r\n    beforeEach(() => {\r\n        // create a user\r\n        const postResponse = http.post(\"/users\", {\r\n            username: \"marco\", password: \"bigsecret\"\r\n        });\r\n        expect(postResponse.statusCode).toEqual(200)\r\n    })\r\n    afterEach(() => {\r\n        // delete user\r\n        const deleteResponse = http.delete(\"/users/marco\");\r\n        expect(deleteResponse.statusCode).toEqual(200)\r\n    })\r\n\r\n    it(\"will allow login with new user\", () => {\r\n        // now you can use the browser to login with the new user\r\n        browser.get(\"/login\");\r\n        element(by.id(\"username\")).sendKeys(\"marco\")\r\n        element(by.id(\"password\")).sendKeys(\"bigsecret\")\r\n        element(by.id(\"login-button\")).click()\r\n        // expectations here\r\n    })\r\n})\r\n```\r\n","readmeFilename":"README.md"}