{"_id":"@ama-team/voxengine-stubs","_rev":"5-2a225dfed1cdabe9d5daa8debb5ccec5","name":"@ama-team/voxengine-stubs","description":"VoxImplant application environment stubs for testing","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@ama-team/voxengine-stubs","version":"0.1.0","description":"VoxImplant application environment stubs for testing","main":"lib/index.js","scripts":{"test":"jake test"},"repository":{"type":"git","url":"git+https://github.com/ama-team/voxengine-stubs.git"},"keywords":["voximplant","voxengine"],"author":{"name":"AMA Team","email":"dev@amagroup.ru"},"license":"MIT","bugs":{"url":"https://github.com/ama-team/voxengine-stubs/issues"},"homepage":"https://github.com/ama-team/voxengine-stubs#readme","dependencies":{"glob":"^7.1.2","js-yaml":"^3.9.1","sinon":">= 1.0.0"},"devDependencies":{"@ama-team/allure-polyfill":"^0.1.0","allure-mocha":"0.0.1","chai":"^4.1.1","chai-as-promised":"^7.1.1","coveralls":"^2.13.1","fs-extra":"^4.0.1","istanbul":"^0.4.5","jake":"^8.0.15","mocha":"^3.5.0","mocha-allure-reporter":"^1.3.2","mocha-junit-reporter":"^1.13.0","mocha-multi-reporters":"^1.1.4","standard":"^10.0.3"},"gitHead":"6420d8e1cd12d022e37cf0b6b0cd740bbdb692e5","_id":"@ama-team/voxengine-stubs@0.1.0","_shasum":"898eb5fc0f8f4808440e1ad1ca249aaa4b09ac4c","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.2","_npmUser":{"name":"ama-team","email":"dev@amagroup.ru"},"dist":{"shasum":"898eb5fc0f8f4808440e1ad1ca249aaa4b09ac4c","tarball":"https://registry.npmjs.org/@ama-team/voxengine-stubs/-/voxengine-stubs-0.1.0.tgz","integrity":"sha512-9S7sT50WK2+w/3bBP5p0I60PiggW8E5URDrlileIynJzFZhfTfQ7gYh/FnZI17kWHblE/gIhx2nXkoNNUWtWeQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCi3dFSHrN3qsLKmvEbDD8eyKB0ImLEZ1n4uQ8HZEreWgIhAMR2VtNlB+Zl/Xpo9BGsd6lLgKyc2US31t453qTzRZcN"}]},"maintainers":[{"name":"ama-team","email":"dev@amagroup.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/voxengine-stubs-0.1.0.tgz_1504177787601_0.8932537359651178"},"directories":{}}},"readme":"# VoxEngine Stubs\n\n[![npm](https://img.shields.io/npm/v/@ama-team/voxengine-stubs.svg?style=flat-square)](https://www.npmjs.com/package/@ama-team/voxengine-stubs)\n[![CircleCI/Master](https://img.shields.io/circleci/project/github/ama-team/voxengine-stubs/master.svg?style=flat-square)](https://circleci.com/gh/ama-team/voxengine-stubs/tree/master)\n[![Coveralls/Master](https://img.shields.io/coveralls/ama-team/voxengine-stubs/master.svg?style=flat-square)](https://coveralls.io/github/ama-team/voxengine-stubs?branch=master)\n[![Scrutinizer/Master](https://img.shields.io/scrutinizer/g/ama-team/voxengine-stubs/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/ama-team/voxengine-stubs)\n[![Code Climate](https://img.shields.io/codeclimate/github//ama-team/voxengine-stubs.svg?style=flat-square)](https://codeclimate.com/github/ama-team/voxengine-stubs)\n\nThis repository contains stubs for VoxEngine-specific global objects to\nhelp in testing VoxImplant applications.\n\n## Installation\n\n```bash\nnpm i @ama-team/voxengine-stubs\n```\n\n## Usage\n\nLibrary has main entrypoint:\n\n```js\nvar Stubs = require('@ama-team/voxengine-stubs')\n```\n\nIt exposes several methods: `.setup()`, `.install()`, \n`.uninstall()`, `.reset()` and `.flush()`. First three are\nterribly self-explanatory:\n\n```js\nbeforeEach(function() {\n  Stubs.setup({global: {allure: {enabled: true}}})\n  Stubs.install()\n})\nafterEach(function() {\n  Stubs.uninstall()\n})\n```\n\nReset and flush are different things. When dealing with stubs like\nLogger, you'll want to a) save what's been in there (that's `.flush()` \nmethod) and b) clear that before every test (and that's `.reset()`).\nReset method is a little bit redundant if you constantly call install \nand uninstall methods, but may come handy in hard cases. `.uninstall()`\nmethod calls `.flush()` automatically, so usually you won't need to \ncall it either.\n\n## Configuration\n\nThere are four levels of configuration:\n\n- Stub defaults\n- Global defaults\n- Global configuration\n- Stub configuration\n\nWhen it comes to work, all three levels are recursively merged into \none, and lower level keys take precedence of upper ones. Defaults are\nhard-boiled inside library and can't be changed, while the latter two\nlevels are configured as single object:\n\n```js\nStubs.setup({\n  global: {\n    allure: {\n      enabled: true\n    }\n  },\n  Logger: {\n    allure: {\n      filename: 'voxengine.log'\n    }\n  }\n})\n```\n\n## Sinon integration\n\nEvery stubbed function is wrapped in `Sinon.spy`, so you may call\nsomething like `Logger.write.getCall(0).args[0]` in your tests without\nany hassle.\n\nSpies are recreated on every reset call, so calls don't accumulate.\n\n## Per-stub work\n\nSometimes you will need to work with stubs directly. Most of the stubs\nhave corresponding `._setup()`, `._reset()` and `._flush()` methods \nthat practically do the same thing you expect.\n\n## Logger\n\nLogger saves passed data to internal state and flushes it as\n`voxengine.log` Allure attachment.\n\nIt's configuration schema is:\n\n```yaml\nallure:\n  enabled: true\n  filename: voxengine.log\n  mimeType: text/plain\n```\n\n## VoxEngine\n\nVoxEngine stubs `.terminate`, `.customData`, `.addEventListener` and \n`.removeEventListener` functions. You can use `._emit(event)` function\nto invoke event raise.\n\nConfiguration:\n```yaml\nallure:\n  enabled: true\n  events:\n    filename: events.yml\n    mimeType: application/x-yaml\n  listeners:\n    filename: listeners.yml\n    mimeType: application/x-yaml\n  customData:\n    filename: custom-data.yml\n    mimeType: application/x-yaml\ncustomData:\n  default: ''\nterminate:\n  # Whether to throw on second VoxEngine.terminate call\n  throwOnMultipleCalls: false\n  # Whether to throw if `this` is lost. Such call may result in\n  # undesired behavior in VoxEngine.\n  throwOnLostContext: true\n```\n\n## Net\n\nOnly HTTP part has been stubbed yet.\n\n```yaml\nallure:\n  enabled: true\n  pattern: http-interaction-%d.yml\n  mimeType: application/yaml\n# list\nhttp:\n  # list of HttpRequestResult-alike structures\n  # example:\n  #   code: 200\n  #   headers:\n  #     - key: Server\n  #       value: elasticsearch/5.5.2\n  #   raw_headers: |\n  #     Server: elasticsearch/5.5.2\n  #   text: '{\"acknowledged\":true}'\n  responses: []\n  # whether to throw when last response have been reached or\n  # just start from beginning\n  roundRobin: false\n```\n\n## AppEvents and CallEvents\n\nBoth of these namespace have been stubbed. You can create events \nyourself by just calling `new AppEvents.Something({property: value})`\nconstructor. Events come with some dumb defaults, so most of the time\nyou will have correct types even if you don't feed constructor with\nanything.\n\n## Hey, i don't see X in that list!\n\nThat's probably because i had no time to implement it. Pull requests\nare appreciated.\n\n## Allure integration\n\nCurrently all flushing boils down to saving Allure attachments if it's\nturned on and is present as `allure` global object. [Allure][] is a\nbeautiful reporting tool made just for case like this: collect all\ndata about tests and present it in beautiful view. If you haven't \ngot a chance to get acquainted with it earlier, do it now, because it\nwill save you tons of testing time.\n\n## License\n\nMIT\n\n## Dev branch state\n\n[![CircleCI/Dev](https://img.shields.io/circleci/project/github/ama-team/voxengine-stubs/dev.svg?style=flat-square)](https://circleci.com/gh/ama-team/voxengine-stubs/tree/dev)\n[![Coveralls/Dev](https://img.shields.io/coveralls/ama-team/voxengine-stubs/dev.svg?style=flat-square)](https://coveralls.io/github/ama-team/voxengine-stubs?branch=dev)\n[![Scrutinizer/Dev](https://img.shields.io/scrutinizer/g/ama-team/voxengine-stubs/dev.svg?style=flat-square)](https://scrutinizer-ci.com/g/ama-team/voxengine-stubs)\n\n  [allure]: https://github.com/allure-framework/allure2\n","maintainers":[{"email":"dev@amagroup.ru","name":"ama-master"},{"email":"ops@amagroup.ru","name":"ama-bot"},{"email":"etki@etki.me","name":"etki"}],"time":{"modified":"2022-06-12T14:36:17.227Z","created":"2017-08-31T11:09:48.675Z","0.1.0":"2017-08-31T11:09:48.675Z"},"homepage":"https://github.com/ama-team/voxengine-stubs#readme","keywords":["voximplant","voxengine"],"repository":{"type":"git","url":"git+https://github.com/ama-team/voxengine-stubs.git"},"author":{"name":"AMA Team","email":"dev@amagroup.ru"},"bugs":{"url":"https://github.com/ama-team/voxengine-stubs/issues"},"license":"MIT","readmeFilename":"README.md"}