{"versions":{"1.0.1":{"name":"@lensesio/cypress-websocket-testing","description":"WebSocket testing plugin for Cypress","version":"1.0.1","author":{"name":"Lenses.io"},"license":"Apache","main":"lib/index.js","types":"lib/index.d.ts","repository":{"type":"git","url":"git+https://github.com/Landoopio/cypress-websocket-testing.git"},"bugs":{"url":"https://github.com/Landoopio/cypress-websocket-testing/issues"},"keywords":["cypress","websocket"],"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"scripts":{"build":"tsc","commit":"git add . && git-cz","lint":"tslint src/**/*.ts","fix":"npm run lint --fix","prepare":"npm run build","prepublishOnly":"npm run lint","semantic-release":"semantic-release"},"peerDependencies":{"rxjs":"^6.5.0"},"devDependencies":{"cypress":"3.6.1","cz-conventional-changelog":"3.0.2","git-cz":"3.3.0","prettier":"1.19.1","rxjs":"6.4.0","rxjs-tslint-rules":"4.26.1","tslint":"5.20.1","@semantic-release/npm":"5.3.4","semantic-release":"15.13.30","tslint-config-airbnb":"5.11.2","tslint-config-prettier":"1.18.0","tslint-plugin-prettier":"2.0.1","typescript":"3.7.2"},"publishConfig":{"registry":"https://registry.npmjs.org/","tag":"latest"},"gitHead":"efa7be7eec1a1c676cc4c29119b7ca23169936f7","homepage":"https://github.com/Landoopio/cypress-websocket-testing#readme","_id":"@lensesio/cypress-websocket-testing@1.0.1","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-smZlFhxFC7ucZP302xpz94sV581MTFkWwOIvt/ica7Q0iR314ioX2RSA2V7uz9kbvspQYlrKP+4khdBst7iBNA==","shasum":"0a17ec8431b6f07110875c400ad75b2ce9a78e80","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@lensesio/cypress-websocket-testing/-/cypress-websocket-testing-1.0.1.tgz","fileCount":11,"unpackedSize":26203,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd1shQCRA9TVsSAnZWagAApDUP/1ADoTPesXZZajFnUO91\nNys32AFkorJP3nLUMIwx+F5QrUdTKwK65BdMddfuXsYLEvj0SmO7n6kgHP30\nSspr2H4O/rtJ18iO7HRvNmjKOUI6BUyTOg5aNRU+eZsneu1edgkl4wW/fppG\nbEpCQjGWx6QRchta72Z7r+N3+MYy3mSa8eJhuD7xSvl5jFoAcLTlhIg03RkD\n5LVVgqLrAIFyk7HljRwNLh5vmTBAF240O+aKPXQjTVyiKRrPy16LQpOuh94z\noqheq9vbd9ahRvoFFch+RX5V9Qtl/BqxCnt2u+XQl9XZWxUibyiF0Onls/zu\nYSNK2+DEMmH+F0kKQCwQSNFxtRNVxgAAHukRKphFW0oQroHnPyDun3SPAB7y\n+EHemJSntBohmGYiBMKui650kfRTSC8qzbmmGpzNzbslzpP4reY9NIwDwzPB\nzqSWoDP6sbx2WHfyuv0P3J0TmbFlYdt1AzLkph2Ub5Q/HsvSl4sMQuJV8A5V\nWmQxajV2lJnRNqm1jXxrVojrv+AK4VpbxYJxjixLdTWB4WwlSGDiu2pTWP/+\nzFX9IY9dVSx80xpYBVNAVs6D8DtUoz6rje+uF8PCt7xsR2entEYAoTz06cr/\n1HfeU2af3LrKqaHlgIO5bbvAgw4miGjgrnc07Q/UXKPzdhL5YD+IhvCdWYzM\nc3y7\r\n=7x1g\r\n-----END PGP SIGNATURE-----\r\n","size":8831},"maintainers":[{"name":"anonymous","email":"sebastian@dragomir.co.uk"},{"name":"anonymous","email":"info@landoop.com"}],"_npmUser":{"name":"anonymous","email":"sebastian@dragomir.co.uk"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cypress-websocket-testing_1.0.1_1574357072351_0.7649109370269964"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-24T10:17:23.185Z","contributors":[]}},"dist-tags":{"latest":"1.0.1"},"name":"@lensesio/cypress-websocket-testing","time":{"created":"2022-01-27T08:11:18.901Z","modified":"2022-01-27T08:11:18.901Z","1.0.1":"2019-11-21T17:24:32.538Z"},"readme":"# cypress-websocket-testing\n\nTest your WebSocket endpoints using [Cypress](https://docs.cypress.io/).\n\n[![Build Status](https://travis-ci.com/lensesio/cypress-websocket-testing.svg?branch=master)](https://travis-ci.com/Lensesio/cypress-websocket-testing)\n<br />\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![License: Apache 2](https://img.shields.io/badge/license-Apache-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![TypeScript](https://badges.frapsoft.com/typescript/love/typescript.svg?v=101)](https://github.com/ellerbrock/typescript-badges/)\n\n\n## Table of Contents\n\n- [Background](#Background)\n- [Installation](#Installation)\n- [Usage](#Usage)\n  - [JavaScript](#JavaScript)\n  - [TypeScript](#TypeScript)\n- [Arguments](#Arguments)\n- [Running the examples](#Running-the-examples)\n- [PRs](#prs)\n- [TODO](#TODO)\n- [License](#license)\n\n## Background\n\nCypress comes out of the box with a great set of tools, that allow both UI and API integration tests to be written. Unfortunatelly the cy.request() command is limited to REST endpoints only, so this library is here to help with those cases when WebSockets need to be called/tested as part of more complex integration/E2E tests.\n\n## Installation\n\n```bash\nnpm i -D @lensesio/cypress-websocket-testing\n# or\nyarn add -D @lensesio/cypress-websocket-testing\n```\n\n## Usage\n\n### JavaScript\n\n`@lensesio/cypress-websocket-testing` extends Cypress' `cy` command.\n\nAdd this line to your project's `cypress/support/commands.js`:\n\n```\nimport { addStreamCommands } from '@lensesio/cypress-websocket-testing';\naddStreamCommands();\n```\n\nThen, in your test, you can use both commands that come with this lib. cy.stream and cy.streamRequest.\n\n```javascript\n// For common cases:\ncy.streamRequest(config, options).then(results => {\n        expect(results).to.not.be.undefined;\n})\n// When in need of a bit more flexibility\ncy.stream(config).then(subject => {\n      subject\n        .pipe(\n          takeUntil(timer(1000)),\n          reduce((acc , val) => acc.concat([val]), [])\n        )\n        .subscribe({\n          next: (results) => {\n            expect(results).to.not.be.undefined;\n          },\n          error: (err) => {},\n          complete: done\n        });\n    });\n```\n\n### TypeScript\n\nAs the library is written in Typescript, you can pass the type of the message to the command and to the config/options object. ( make sure that you already configured your Cypress tests to work [with TS](https://github.com/bahmutov/add-typescript-to-cypress) )\n\nFirst, add `@lensesio/cypress-websocket-testing` to the `cypress/tsconfig.json` file\n\n```\n{\n  \"compilerOptions\": {\n    \"types\": [\n        \"cypress\",\n        \"@lensesio/cypress-websocket-testing\"\n    ]\n  }\n}\n```\n\nThen to use in TypeScript tests: \n\n```typescript\n// For full set of config values, check rxjs documentation\nconst config: WebSocketSubjectConfig<IMessage> = {\n  url: \"ws://localhost:8080/\"\n};\n\nlet options: Partial<StreamRequestOptions<IMessage>>;\n\ncy.streamRequest<IMessage>(config, options).then((results?: IMessage[]) => {\n        expect(results).to.not.be.undefined;\n})\ncy.stream<IMessage>(config).then(subject => {\n      subject\n        .pipe(\n          takeUntil(timer(1000)),\n          reduce((acc: IMessage[], val: IMessage) => acc.concat([val]), [])\n        )\n        .subscribe({\n          next: (results?: IMessage[]) => {\n            expect(results).to.not.be.undefined;\n          },\n          error: (err: any) => {},\n          complete: done\n        });\n    });\n```\n\nNote: \nThere are some type conflicts when extending/adding operators to cy.stream() in tests directly. (due to  issues with Cypress including an old rxjs version as a dependency). Best way is to extend cy.stream() by building a custom command with it and use that instead.\n\n\n\n## Arguments\n\n- config\n\nA [WebSocketSubjectConfig](https://rxjs-dev.firebaseapp.com/api/webSocket/WebSocketSubjectConfig) object. See official docs for more information. Is passed as is to the underlying webSocket subject.\n\n- options:StreamRequestOptions (only for streamRequest command. Although optional, at least the takeWhileFn should be set)\n\nUsage `cy.streamRequest(config, options)`.\n\n| Option               | Default                | Description                                                                                                                                               |\n| -------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `streamTimeout`           | `defaultCommandTimeout` | Time to wait for the stream to complete. (if is greater than Cypress defaultCommandTimeout, you need to use the cy.wrap as a workaround. Investigating alternative ways)                                                                                                                            |\n| `retryDelay`            | `4000`                 | How long to way until a new connection attempt is made.                                                                   |\n| `retryAttempts`           | `5`                  | How many times to retry the connection before completing.                                                                                                     |\n| `startUpMessage`        | `any`          | A message to be sent on connection open.                                                                                                             |\n| `takeWhileFn`             | `()=>false`          | Function that will tell the stream when to close. If not set, it will close on the first message received in order to avoid having an open connection. |\n| `retryUntilFn`             | `()=>true`          | Function that will tell the stream how to check the results, and retry if the result is false. |\n\n\n<br />\n<br />\n\n## Running the examples\n\nIn order to try this project locally, you need to `npm install` in both the root and the examples/ folder. \nAfter, build the library using `npm run build` in the root folder, then go to examples/ , start the websocket server `npm start` and cypress using `npm run test:local`.\n\n## PRs\n\nPRs are welcome. Be sure to add \n- Tests\n- Reason for the PR \n<br />\nWhen committing, remember to use `npm run commit`, in order to start commitizen.\n\n\n## TODO\n- [] Find a fix for the cy.wrap workaround.\n- [] Improve error handling.\n- [] Add more examples for cy.stream command.\n\n## LICENSE\n\n[Apache 2.0](LICENSE)","users":{}}