{"name":"tape-cluster","version":"3.2.1","description":"A helper to run tests against a cluster","keywords":[],"author":{"name":"Raynos","email":"raynos2@gmail.com"},"repository":{"type":"git","url":"git://github.com/Raynos/tape-cluster.git"},"main":"index","homepage":"https://github.com/Raynos/tape-cluster","bugs":{"url":"https://github.com/Raynos/tape-cluster/issues","email":"raynos2@gmail.com"},"contributors":[{"name":"Raynos"}],"dependencies":{},"devDependencies":{"coveralls":"^2.10.0","nyc":"^14.1.1","opn":"^1.0.1","request":"2.55.0","standardx":"^3.0.1","tap":"^12.6.0","tap-spec":"^2.1.1","tape":"^3.4.0"},"eslintConfig":{"rules":{"indent":["error",4]}},"licenses":[{"type":"MIT","url":"http://github.com/Raynos/tape-cluster/raw/master/LICENSE"}],"scripts":{"test":"npm run jshint -s && npm run cover -s","unit-test":"node test/index.js | tap-spec","jshint":"standardx","cover":"nyc --report html --print detail -- tap test/*.js && npm run check-cover -s","check-cover":"nyc check-coverage --branches=100 --lines=100 --functions=100","view-cover":"opn ./coverage/index.html","travis":"npm run cover -s && nyc report lcov && ((cat coverage/lcov.info | coveralls) || exit 0)"},"engine":{"node":">= 0.8.x"},"pre-commit":["test"],"pre-commit.silent":true,"ngen-version":"5.1.0","gitHead":"5ade55a8f7036fd6854853e8b6cc8badae0f2fec","_id":"tape-cluster@3.2.1","_nodeVersion":"10.15.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-G9JyI6xi78w6ATZaRCxTKCY+0ZZXM/jptgj2cZhGiqnDHT8rtc4v0cTb7lk2AQ8xURYCdi60dEohhcgCdlYNig==","shasum":"7823a060431f7fce31397eab6b4e7bfa9c16e7fa","tarball":"http://registry-npm.ywwl.com/tape-cluster/download/tape-cluster-3.2.1.tgz","fileCount":16,"unpackedSize":46372,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdFKeoCRA9TVsSAnZWagAAwYUP/3D4JWMtPnLhpWO+6aFu\na3qeI5aG9d9545h+OO4F27YY9r6ENsWL+O/Q3g73UvIieixf6qQH0oQb75Ri\nNXB0hy/0XkNeVKrJtFLtWdUJ2Fi67g6uEZFvD8d8Rc+FoKRYEtlop3aTYEUw\n2nmk0LDJdwu4I35TZcbVNjchOPQsK9z8Zei6+eKsjoVYk/eErVUI2dZGqEPl\n+k37VjIYBKzi/AxOz4csvH1eO/1T55PSrt/WPhqSovk4HhWUGXIRwyf0m7/4\nRuGkewLCLE7vzFuBT3ajDpbFoibBVDvVC7Cn0Qsvcug+pkMvaFMqjWnED2+X\norAvW8ZhKuIojSk0Tj19Y0R/Rnt0VCU/noorRgEmMzNL9nVyQU8x5VpiahCR\nDVSXliMsZSjGo/tWV61Ky8GbY1ZIQM/EPNS+crkyY+ed7eBIYAcQk+kzwzxq\nbLDZpBkZNI9knweQdf0IPQYpTNSloOEgtYJemwCaWNP8VrmpqcNQuChRK7cC\nj26H5EBGUohqd+wVXgqmrwEFYpHMDnxkhYbSYI8xcFWOBKWM9g+7cvZqOxe0\nx6e0TCzTibyPZUARG6VUthe4SO4EBrEYR8adN4b0GPuHSSj7LNvWT5DBnPyC\ngnjojhOMqJ9fWN84XVaTcxei53PhVSuydzaQLxkG8mBnzBJTbsG6lR0EZYg7\npXsJ\r\n=cmA/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDITUeebDq2/pspTCunDGx+0K5OiyE71GB1ZMvL1rOzBQIhAN03ovSJQKoBfIr4KVx0uqSXCa1OIhozHzB/+82Kqkle"}],"size":8515,"noattachment":false,"key":"/tape-cluster/-/tape-cluster-3.2.1.tgz"},"maintainers":[{"name":"raynos","email":"raynos2@gmail.com"}],"_npmUser":{"name":"raynos","email":"raynos2@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tape-cluster_3.2.1_1561634727850_0.8267186744333974"},"_hasShrinkwrap":false,"readme":"# tape-cluster\n\n<!--\n    [![build status][build-png]][build]\n    [![Coverage Status][cover-png]][cover]\n    [![Davis Dependency status][dep-png]][dep]\n-->\n\n<!-- [![NPM][npm-png]][npm] -->\n\nA helper to run integration tests against an application\n\n## Motivation\n\nWhen writing integration tests against a service you generally\nwant to spawn up an instance of the application or spawn up\na cluster of applications.\n\nWriting tests against such a cluster can be tedious without\na helper to setup your cluster before and after every test.\n\nThe `tape-cluster` package will setup your test harness / runner / application before each test block and spin them down after each test block.\n\nThis functionality is similar to `beforeEach` or `afterEach` that might exist in other testing libraries but is instead implemented as a standalone library that's compatible with vanilla `tape` and `tap`\n\n## Example\n\nYour test file\n\n```js\n// test/what.js\n'use strict';\n\nvar tape = require('tape');\nvar request = require('request');\n\nvar MyTestCluster = require('./lib/test-cluster.js');\n\nMyTestCluster.test('a test', {\n    port: 8000\n}, function t(cluster, assert) {\n    request({\n        url: 'http://localhost:' + cluster.port + '/foo'\n    }, function onResponse(err, resp, body) {\n        assert.ifError(err);\n\n        assert.equal(resp.statusCode, 200);\n        assert.equal(resp.body, '/foo');\n\n        assert.end();\n    });\n});\n\ntape('a test without tape-cluster', function t(assert) {\n    var cluster = new MyTestCluster({\n        port: 8000\n    });\n    cluster.bootstrap(function (err) {\n        assert.ifError(err);\n        request({\n            url: 'http://localhost:' + cluster.port + '/foo'\n        }, function onResponse(err, resp, body) {\n            assert.ifError(err);\n\n            assert.equal(resp.statusCode, 200);\n            assert.equal(resp.body, '/foo');\n\n            cluster.close(function (err) {\n                assert.ifError(err);\n                assert.end();\n            });\n        });\n    });\n});\n```\n\nYour actual `test-cluster.js`\n\n```js\n// test-cluster.js\n'use strict';\n\nvar tape = require('tape');\nvar http = require('http');\nvar tapeCluster = require('tape-cluster');\n\nMyTestCluster.test = tapeCluster(tape, MyTestCluster);\n\nmodule.exports = MyTestCluster;\n\nfunction MyTestCluster(opts) {\n    if (!(this instanceof MyTestCluster)) {\n        return new MyTestCluster(opts);\n    }\n\n    var self = this;\n\n    self.assert = opts.assert;\n    self.port = opts.port;\n    self.server = http.createServer();\n\n    self.server.on('request', onRequest);\n\n    function onRequest(req, res) {\n        res.end(req.url);\n    }\n}\n\nMyTestCluster.prototype.bootstrap = function bootstrap(cb) {\n    var self = this;\n\n    self.server.once('listening', cb);\n    self.server.listen(self.port);\n};\n\nMyTestCluster.prototype.close = function close(cb) {\n    var self = this;\n\n    self.server.close(cb);\n};\n```\n\n## ES6 example\n\n```js\nconst fetch = require('node-fetch')\n\nconst MyTestCluster = require('./lib/test-cluster.js');\n\nMyTestCluster.test('a test', {\n    port: 8000\n}, async function t(cluster, assert) {\n    const res = await fetch(`http://localhost:${cluster.port}/foo`)\n\n    const text = await res.text()\n    assert.equal(res.status, 200)\n    assert.equal(text, '/foo')\n});\n```\n\n```js\nconst tape = require('tape');\nconst http = require('http');\nconst tapeCluster = require('tape-cluster');\n\nclass TestCluster {\n    constructor(opts) {\n        this.port = opts.port\n        this.server = http.createServer()\n\n        this.server.on('request', (req, res) => {\n            res.end(req.url)\n        })\n    }\n\n    async bootstrap() {\n        return new Promise((resolve) => {\n            this.server.once('listening', resolve)\n            this.server.listen(this.port)\n        })\n    }\n\n    async close() {\n        return new Promise((resolve, reject) => {\n            this.server.close((err) => {\n                if (err) return reject(err)\n                resolve()\n            })\n        })\n    }\n}\n\nTestCluster.test = tapeCluster(tape, TestCluster)\n```\n\n## Installation\n\n`npm install tape-cluster`\n\n## Tests\n\n`npm test`\n\n## Contributors\n\n - Raynos\n\n## MIT Licensed\n\n  [build-png]: https://secure.travis-ci.org/Raynos/tape-cluster.png\n  [build]: https://travis-ci.org/Raynos/tape-cluster\n  [cover-png]: https://coveralls.io/repos/Raynos/tape-cluster/badge.png\n  [cover]: https://coveralls.io/r/Raynos/tape-cluster\n  [dep-png]: https://david-dm.org/Raynos/tape-cluster.png\n  [dep]: https://david-dm.org/Raynos/tape-cluster\n  [npm-png]: https://nodei.co/npm/tape-cluster.png?stars&downloads\n  [npm]: https://nodei.co/npm/tape-cluster\n","publish_time":1561634728019,"_cnpm_publish_time":1561634728019,"dist-tags":{"latest":"3.2.1"}}