{"id":15629707,"url":"https://github.com/anko/tapsoneer","last_synced_at":"2026-01-07T14:53:25.487Z","repository":{"id":36260515,"uuid":"40564942","full_name":"anko/tapsoneer","owner":"anko","description":"Node.js asynchronous test framework—emits tapson","archived":false,"fork":false,"pushed_at":"2015-08-11T21:08:50.000Z","size":140,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-04T19:14:41.543Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"LiveScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anko.png","metadata":{"files":{"readme":"readme.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-11T20:58:28.000Z","updated_at":"2015-08-11T20:59:11.000Z","dependencies_parsed_at":"2022-09-04T13:11:44.805Z","dependency_job_id":null,"html_url":"https://github.com/anko/tapsoneer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anko%2Ftapsoneer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anko%2Ftapsoneer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anko%2Ftapsoneer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anko%2Ftapsoneer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anko","download_url":"https://codeload.github.com/anko/tapsoneer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246223325,"owners_count":20743168,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T10:28:14.491Z","updated_at":"2026-01-07T14:53:25.457Z","avatar_url":"https://github.com/anko.png","language":"LiveScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tapsoneer [![](https://img.shields.io/npm/v/tapsoneer.svg?style=flat-square)][1] [![](https://img.shields.io/travis/anko/tapsoneer.svg?style=flat-square)][2]\n\nA simple Node.js/io.js interface to the [tapson][3] test protocol, version\n1.0.0.\n\nTests are planned, then run asynchronously.  If some of your tests depend on\neach other, you can specify how.\n\nExports a readable tapson protocol stream.\n\n    npm i tapsoneer\n\n## Tutorial\n\n```js\n// Instantiate\nvar taps = require(\"tapsoneer\")();\n\n// Create 2 tests that finish in 0 - 1 seconds\nvar test1 = taps.plan(\"this runs first\", function(cb) {\n    setTimeout(function() { cb(null, \"first ok\") }, Math.random() * 1000);\n});\nvar test2 = taps.plan(\"this runs second\", function(cb) {\n    setTimeout(function() { cb(null, \"second ok\") }, Math.random() * 1000);\n});\n// Tell tapsoneer we're done with planning tests\ntaps.done();\n\n// Run the tests in parallel\ntest1();\ntest2();\n\n// Read the output data stream\ntaps.out.on(\"data\", function(d) { console.log(d); });\n```\n\nWith the above, tapsoneer runs both tests in parallel.  You can expect output that\nlooks like—\n\n```json\n{\"id\":\"5a10fa17-1783-4b72-afa5-5cab41209dae\",\"expected\":\"this runs first\"}\n{\"id\":\"68cb2ae4-f769-4f86-82d9-a15fdab4180a\",\"expected\":\"this runs second\"}\n{\"id\":\"4f4ac792-f37f-4dc3-a97d-5004e05ca669\",\"ok\":true,\"actual\":\"second ok\"}\n{\"id\":\"4b157358-603f-49c3-aec5-a0498ff89447\",\"ok\":true,\"actual\":\"first ok\"}\n```\n\n## Exported things\n\n### `var tests = tapsoneer([options])`\n\nCreates a new tapsoneer test set, ready and waiting for tests.\n\nBy default, the emitted stream outputs Node Buffers.  If you want a stream of\nobjects instead, pass an options object with `{ objectMode : true }`.\n\n### `var test = tests.plan([description], testFunction)`\n\nPlans a new test with an optional description and a function that runs it.\nReturns a function that you can call to immediately run the test.\n\nThe `test` will be passed a callback function as its only argument, which it\nshould call once it is finished.  As is the usual Node.js practice, if there's\na failure, pass an `Error` object or `String` error message as the first\nparameter.  If it succeeded, pass `null` as the first parameter and an optional\nString describing the success as the second.\n\n### `test([callback])`\n\nRuns the given test immediately.  Its results will be on the output stream as\nsoon as the test completes.\n\nYou can optionally pass it a `callback` argument, to be notified when the test\nfinishes.  This is handy if some of your tests depend on other tests, and means\nyou can use [async.js][4] to do stuff like—\n\n```js\n\nvar databaseConnection = null;\n\nvar testSetupDatabase = tests.plan(\"database sets up\", function(cb) {\n    // Do whatever you need to set up the database, and call `cb`.\n});\nvar testQuery = tests.plan(\"query some values\", function(cb) {\n    // Use the `databaseConnection` to do stuff and call `cb`.\n});\n\ntests.done();\n\nasync.series([ testSetupDatabase, testQuery ]);\n```\n\n—to ensure they run sequentially.  If you have a tangly mess of dependencies,\n[`async.auto`][5] is your friend.\n\nIf you want to run a test immediately after you plan it because it has no\ndependencies on anything, that's fine too.  It'll run in parallel with other\ntests:\n\n```js\ntests.plan(\"this runs right away\", function(cb) { cb(null, \"no problemo\") })();\n```\n\nIf you want to pass data between tests (some stuff from a database, say), just\ncall your test function's result callback with that data as additional\narguments.  They'll be prepended to the test callback's arguments in a way\nthat's compatible with [`async.waterfall`][6]:\n\n```js\nvar queryDatabase = tests.plan(\"database opens\", function(cb) {\n    db.query(\"some-query\", function(e, data) {\n        if (e) {\n            cb(e); // fail\n        }\n        else {\n            cb(null, \"database ok\", data);\n        }\n    });\n});\n\nvar checkData = tests.plan(\"data looks fine\", function(data, cb) {\n    if (data == \"correct value\") {\n        cb(null, \"yep\");\n    } else {\n        cb(\"Got bad data: \" + data); // fail\n    }\n}\n\ntests.done();\n\nasync.waterfall([ queryDatabase, checkData ]);\n```\n\n### `tests.out`\n\nThis is a [stream][7] containing tapson.  All test plans and test results are\nemitted from it as they happen.  The stream finishes when all the tests finish.\n\nIf you want it on `stdout`, just do `tests.out.pipe(process.stdout)`.\n\n## License\n\n[ISC][8].\n\n[1]: https://www.npmjs.com/package/tapsoneer\n[2]: https://travis-ci.org/anko/tapsoneer\n[3]: https://github.com/anko/tapson\n[4]: https://github.com/caolan/async\n[5]: https://github.com/caolan/async#auto\n[6]: https://github.com/caolan/async#waterfalltasks-callback\n[7]: http://nodejs.org/api/stream.html\n[8]: LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanko%2Ftapsoneer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanko%2Ftapsoneer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanko%2Ftapsoneer/lists"}