{"_id":"@blueday-technology/cypress-plugin-signalr","_rev":"1-40d95f4e0f21cf67972642107fabf538","name":"@blueday-technology/cypress-plugin-signalr","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.3":{"name":"@blueday-technology/cypress-plugin-signalr","version":"0.0.3","description":"Verify and publish actions from and to your SignalR hubs","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","test":"echo \"Error: no test specified\" && exit 1","release":"standard-version && git push --follow-tags"},"repository":{"type":"git","url":"git+https://github.com/longcui/cypress-plugin-signalr.git"},"keywords":["cypress","plugin","signalr","mock","verify","publish","trigger"],"author":{"name":"Bas Slagter"},"license":"ISC","bugs":{"url":"https://github.com/longcui/cypress-plugin-signalr/issues"},"homepage":"https://github.com/longcui/cypress-plugin-signalr#readme","devDependencies":{"@types/node":"^13.13.4","cypress":"^4.5.0","standard-version":"^8.0.1","typescript":"^3.8.3"},"gitHead":"7ce5964eea76cbdf4cd53a56390abe273fafbf03","_id":"@blueday-technology/cypress-plugin-signalr@0.0.3","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-JZ432KVej9czep9deA8mLvZ0wox4jn5Yj2lihJfqdqYeQXipNxhIrte1EuDFvZZlDh3NsiYzj+wKN93EAXWOZw==","shasum":"faf461eff2106a62ea6551b6e9528e0c410b206e","tarball":"https://registry.npmjs.org/@blueday-technology/cypress-plugin-signalr/-/cypress-plugin-signalr-0.0.3.tgz","fileCount":31,"unpackedSize":17966,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJft4VgCRA9TVsSAnZWagAADXgP/jZgsE+pngbqVclf5ZzR\nju26364Jt7nuC33TTbt/RCZ7jhrWMwIGqyjJZSrN0FDVflkvpYo8Thug/NT6\nKcI7EsHytUA5Do3CgslBWjSV2aKqqYV7Snj3Nxd+tzpHvvPh32x1Z1lO7sY9\nnAiGceItq7/BgWCJGhLei28EsbXWbNB+P0TqdGcze+flTuoHZ8BbtLSD5Rie\n7wU5ZdNhHBwxnI7HbGfBxhMr8gm7LB674OKr0pt/xRqRPW76/N6Y7wJsNGQ1\noTm/OixIjORSGtQkdqn/GTD3e7zR39zQX5VNeTV8dp78Mx2Npur6bj36hCan\n1VrdFW/CFTju5gyIIZvohZ0cDMZBv1lrDs+xkqdLEHY6e3+S4cnCMyoGutt7\np5pdEA9caflHD0pC5P0g2fqirTX8Q/xgdml0Tbn2Q8RMQlTzDl2e4EwYG/fL\nSVElYI5NRHDhYlRP2XzpmOwCirGGbPdnU2lmDOlCmyC7w5zjakn8cmj8Xg1S\nRUfoCo2ibBAbdpNgESHrzm++BeGvtFAfGxxATQXe+PPJIQ4hPjEKzoFFbtcF\nK+RnMyppnNlv/Lr2phuKjRAEpkjfBuNqRPQWqERjTHeSGTLe99kBV7bomi5G\nqGNNVZljlQvTGEw/ys9OIRBlGPjMjc/GYoKl7qnA/zwE9qc/scSeoTR/UU/3\neQB3\r\n=11+J\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICilbr4g5Stgv9uaAN7Qb0yCeRdRWnvoqSZx0pd0/Q26AiEAiFmpzqt+wwVl+mFD8C1y1JZuGU7+QwMsLvxVJ4nI2Nk="}]},"_npmUser":{"name":"longcui","email":"long.cui@outlook.com"},"directories":{},"maintainers":[{"name":"longcui","email":"long.cui@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cypress-plugin-signalr_0.0.3_1605862751808_0.4389519724058264"},"_hasShrinkwrap":false}},"time":{"created":"2020-11-20T08:59:11.519Z","0.0.3":"2020-11-20T08:59:11.948Z","modified":"2022-04-04T19:46:45.118Z"},"maintainers":[{"name":"longcui","email":"long.cui@outlook.com"}],"description":"Verify and publish actions from and to your SignalR hubs","homepage":"https://github.com/longcui/cypress-plugin-signalr#readme","keywords":["cypress","plugin","signalr","mock","verify","publish","trigger"],"repository":{"type":"git","url":"git+https://github.com/longcui/cypress-plugin-signalr.git"},"author":{"name":"Bas Slagter"},"bugs":{"url":"https://github.com/longcui/cypress-plugin-signalr/issues"},"license":"ISC","readme":"<div>\r\n    <a href=\"https://npmcharts.com/compare/webpack?minimal=true\">\r\n        <img src=\"https://img.shields.io/npm/dm/cypress-plugin-signalr.svg\">\r\n    </a>\r\n    <a href=\"https://packagephobia.now.sh/result?p=webpack\">\r\n        <img src=\"https://packagephobia.now.sh/badge?p=cypress-plugin-signalr\" alt=\"install size\">\r\n    </a>\r\n    <a href=\"https://github.com/webpack/webpack/graphs/contributors\">\r\n        <img src=\"https://img.shields.io/github/contributors/basslagter/cypress-plugin-signalr.svg\">\r\n    </a>\r\n</div>\r\n\t\r\n<h1>cypress-plugin-signalr</h1>\r\n<p>Verify and publish actions from and to your SignalR hubs</p>\r\n\r\n## Table of Contents\r\n\r\n1. [Install](#install)\r\n2. [Introduction](#introduction)\r\n3. [Get started](#get-started)\r\n4. [Usage](#usage)\r\n\r\n<h2 align=\"center\">Install</h2>\r\n\r\nInstall with npm:\r\n\r\n```bash\r\nnpm install --save-dev cypress-plugin-signalr\r\n```\r\n\r\nInstall with yarn:\r\n\r\n```bash\r\nyarn add cypress-plugin-signalr --dev\r\n```\r\n\r\n<h2 align=\"center\">Introduction</h2>\r\n\r\ncypress-plugin-signalr is a plugin for cypress that provides a mock for the SignalR hub connection\r\nand adds cypress commands to publish (hubPublish) and/or verify (hubVerify) actions from and to your\r\nSignalR hub.\r\n\r\n<h2 align=\"center\">Get started</h2>\r\n\r\nAfter installing the package include an import in the cypress/support/index.js file, like:\r\n```javascript\r\nimport 'cypress-plugin-signalr';\r\n```\r\nThe plugin exposes the SignalRMock on the global object as 'signalrMock';\r\nYou can decide for yourself how to use this object in your app but in most cases you probably\r\nwant to pass it to your application, for example on the window object, like:\r\n\r\n```javascript\r\nCypress.Commands.overwrite('visit', (originalFn, url) => {\r\n  return originalFn(url, {\r\n    onBeforeLoad(window) {\r\n      window.signalrMock = signalrMock;\r\n    },\r\n  });\r\n});\r\n```\r\nIn your app you have to take this object and use it when defined, like:\r\n\r\n```javascript\r\nconst connection = window.signalrMock || new signalR.HubConnectionBuilder()\r\n    .withUrl(hubUrl)\r\n    .build();\r\n```\r\n\r\n<h2 align=\"center\">Usage</h2>\r\n\r\nWithin cypress you now have three new commands:\r\n<br/><br/>\r\n1. hubPublish\r\nThis command publishes the specified action with the specified attribute, like:\r\n\r\n```javascript\r\n  it('should publish an action', () => {\r\n    cy\r\n      .hubPublish('notification:receive', 'My notification');\r\n  });\r\n```\r\n\r\nThis will execute the code in registered subscribers, like:\r\n\r\n```javascript\r\n    connection.on('notification:receive', (message) => {\r\n      console.log(message); // logs: 'My notification'\r\n    });\r\n```\r\n\r\n2. hubVerify\r\nThis command verifies that a specific message is invoked, like:\r\n\r\n```javascript\r\n  it('should invoke an action', () => {\r\n    cy\r\n      .hubVerify('DeleteNotification', 1, (invokes) => {\r\n        expect(invokes[0].args[0]).to.equal(123);\r\n      });\r\n  });\r\n```\r\nAs you can see it provides you with the invocations occurred for this action.\r\nAn action is invoked with SignalR like:\r\n\r\n```javascript\r\n   connection.invoke('DeleteNotification', 123);\r\n```\r\n\r\n3. hubClear\r\nThis command clears the current state of the mock. this is most likely used to clear invocations between tests.\r\nYou can call this command after each test, like:\r\n\r\n```javascript\r\n  afterEach(() => {\r\n      cy\r\n        .hubClear();\r\n  });\r\n```\r\n\r\nOptionally you can specify whether you want to clear both the invokes as the subscribers, like:\r\n\r\n```javascript\r\n  afterEach(() => {\r\n      cy\r\n        .hubClear({\r\n            subscribers: false,\r\n            invokes: true, // default\r\n         });\r\n  });\r\n```\r\n\r\n4. InvocationReply\r\nPass variable `signalRInvocationResults` to `window`. The variable is in json form: \r\neg\r\n```json\r\n {\r\n   \"DeleteNotification\": \"here is the reply\"\r\n }\r\n```\r\nHow to use in Cypress\r\n```javascript\r\n  cy.fixture(\"signalRInvocationResults/standard.json\").then((jsonObj) => {\r\n    window.signalRInvocationResults = jsonObj;\r\n    cy.log(\r\n      \"signalRInvocationResults saved to Cypress window global variable to be used by 'cypress-plugin-signalr'.\"\r\n    );\r\n    cy.visit(url, {\r\n      mockSignalR: true,\r\n    });\r\n  });\r\n```","readmeFilename":"README.md"}