{"name":"tape-cluster","version":"3.1.0","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","istanbul":"^0.3.5","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":"istanbul cover --report html --print detail -- test/index.js && npm run check-cover -s","check-cover":"istanbul check-coverage --branches=100 --lines=100 --functions=100","view-cover":"opn ./coverage/index.html","travis":"npm run cover -s && istanbul 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":"92ab815e9af7947ea4d81b8cb7f4d195cfd243ea","_id":"tape-cluster@3.1.0","_npmVersion":"5.3.0","_nodeVersion":"10.15.3","_npmUser":{"name":"raynos","email":"raynos2@gmail.com"},"dist":{"integrity":"sha512-XsiRSZQgnPZQOCofRCaA5L/3FI+ar106SU0uZYdr5XPMBHAOantNq8SBwPPY6AktrEVuvhMaHMTUa2LGi0aujw==","shasum":"8ba7e66fafd5878541202d3c8f49132f387aacdc","tarball":"http://registry-npm.ywwl.com/tape-cluster/download/tape-cluster-3.1.0.tgz","fileCount":8,"unpackedSize":22973,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcrhg5CRA9TVsSAnZWagAAs34P/R9S4xj1IEaHKrqflVS0\nLHLzrlXj1tNmlirUBlhUVeokeFHVzjcJL2zc4zbo+0tLhY+zdc5GuY1eZHFX\n/Ac/Ib5GWeEtUuyKoVJNiC+tWRVuESuSYc5r11BAm8xy7Y3mW8ZbUkPnsvYV\nkUsgT6pDQEzGorSDwB0uKZeGvSmyDiPPJU9piduuwCfxonZOUs5OXU3p7xbL\nkFpiafGnQMFESZ9mhGgw7TOxXjLS0RAlvtqsDvw4u9iy02RXOWL+a0AiNxo3\na/q9jAqmw8TZmp4yWes3IRaKWSVUOmTOn8JCxsjUZemcYaFLCYnUa0oJhPHo\nirGOSK/wznPpb1pqrhCzb6Pbdl5d3Kxd6pOS+o8psr+bOUvXyfbGr7yETJ0a\njavetj5gwszpOeAlOqLL6zYCU8YeUr48H1dwsZY8o277atTDffmgaMIQJq9R\n0S0atPPN7twgzNzVpb+VvXp+eqQ9iNaHeM7WpWvqVh8PkPRsHEmeoH+7m9Vq\nlQ9xAOCtXjKC8tkk4jEtnhujxqGD8UWumz2NMd5zE34XEyOjIu750o40wWV+\nwaQU7FKSx3beNsilL4ZwuMcaJ4MJY1zmr+lzffXKRlCGOgLP6Dw1yPOXqvx3\nayfENitPWmuByTE+3MQr6W4ESUP1VN4j0Nt+4nv6JZyf2nV7FgGAwvt7X9+T\nQE6D\r\n=JZwW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCqcN3or+bOce+yZG+7zZZJg+lMosSButQp5AmnoFSIAwIgZjfJUdcHLOpy7yDXo6qNhnW36JzS/b9c0knEAd0cdb4="}],"size":5429,"noattachment":false,"key":"/tape-cluster/-/tape-cluster-3.1.0.tgz"},"maintainers":[{"name":"raynos","email":"raynos2@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tape-cluster_3.1.0_1554913337023_0.7098900617137376"},"_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":1554913337207,"_cnpm_publish_time":1554913337207,"dist-tags":{"latest":"3.2.1"}}