{"id":17983494,"url":"https://github.com/techjacker/tap-wrapper","last_synced_at":"2025-10-30T03:20:01.028Z","repository":{"id":8992965,"uuid":"10742260","full_name":"techjacker/tap-wrapper","owner":"techjacker","description":"Get node-tap results returned in JSON rather than printing to STDOUT","archived":false,"fork":false,"pushed_at":"2013-06-18T18:20:41.000Z","size":160,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T13:36:59.356Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techjacker.png","metadata":{"files":{"readme":"README.md","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":"2013-06-17T16:55:43.000Z","updated_at":"2014-03-02T15:31:12.000Z","dependencies_parsed_at":"2022-09-11T02:20:26.695Z","dependency_job_id":null,"html_url":"https://github.com/techjacker/tap-wrapper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Ftap-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Ftap-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Ftap-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Ftap-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techjacker","download_url":"https://codeload.github.com/techjacker/tap-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247107828,"owners_count":20884797,"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-29T18:17:24.356Z","updated_at":"2025-10-30T03:20:00.973Z","avatar_url":"https://github.com/techjacker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tap-wrapper\n\n[![Build Status](https://secure.travis-ci.org/techjacker/tap-wrapper.png)](http://travis-ci.org/techjacker/tap-wrapper)\n\n## Description\n- utility to prevent [node-tap](https://github.com/isaacs/node-tap) test results printing to STDOUT\n- receive test results in JSON format\n\n### How does it help you?\n- good for testing tap test helpers\n- used in unit tests for [tap-test-helpers](https://npmjs.org/package/tap-test-helpers) module\n\n## Install\n```Shell\nnpm install tap-wrapper\n```\n\n### Docs\n[Yuidocs documentation here](docs/index.html)\n- link only works when checkout repo and preview README locally\n\n\n## Api\n\n#### Helper Test Function (```helperTestFn```) to be wrapped\nMust do 2 things:\n1. call ```this.end(t)``` instead of ```t.end()```\n\t- don't forget to pass the ```t``` param to ```this.end```\n2. bind tap.Test to this, eg:\n\t```return require('tap').Test('test banner', function (t) {....}.bind(this));```\n\n```JavaScript\nvar helperTestFn = function (paramToPass) {\n\treturn require('tap').Test(testName, function (t) {\n\t\tt.equal(paramToPass, testName, 'Integration Test: WrapLoud is called');\n\t\tthis.end(t);\n\t}.bind(this));\n};\n```\n\n#### ```Wrap.WrapSilent(helperTestFn)```\n- Wrap a function and and prevent results for going to STDOUT\n- Listen for tap.Producer 'end evt' for results of tests to be delivered in JSON format, eg:\n\n```JavaScript\nvar helperTestFnSilent = require('tap-wrapper').WrapSilent(function () {\n\treturn require('tap').Test('test banner', function (t) {....}.bind(this));\n});\n\nhelperTestFnSilent.Producer.on(\"end\", function (er, total, ok) {\n\tconsole.log('JSON representation of tap.test results', this.results);\n});\n\n// trigger test after bound to Producer end evt\n// tap test harness is silenced (does not print to STDOUT)\nhelperTestFnSilent.test();\n```\n\n\n#### ```Wrap.WrapLoud(helperTestFn)```\n- Wrap a function and allow tap tests to print to STDOUT as normal\n\n```JavaScript\nvar helperTestFnLoud = require('tap-wrapper').WrapLoud(function () {\n\treturn require('tap').Test('test banner', function (t) {....}.bind(this));\n});\n// tap test harness prints to STDOUT as normal (ie not intercepted)\nhelperTestFnLoud();\n```\n\n\n## Full Example\n\n```JavaScript\nvar test \t\t\t   = require('tap').Test,\n\ttestName           = 'randomTest',\n\thelperTestFn       = function (paramToPass) {\n\t\treturn test(testName, function (t) {\n\t\t\tcounter += 1;\n\t\t\tt.equal(paramToPass, testName, 'Integration Test: WrapLoud is called');\n\t\t\tthis.end(t);\n\t\t}.bind(this));\n\t},\n\thelperTestFnSilent = main.WrapSilent(helperTestFn),\n\thelperTestFnLoud   = main.WrapLoud(helperTestFn);\n\nhelperTestFnSilent.Producer.on(\"end\", function (er, total, ok) {\n\n\t\tvar results = this.results;\n\t\ttest('Integration Test: WrapSilent: wrappedFn.Producer end evt triggered', function (t) {\n\t\t\tt.equal(results.testsTotal, 1, '1 test in total');\n\t\t\tt.equal(results.pass, 1, '1 pass in total');\n\t\t\tt.equal(counter, 2, 'both silent and loud tests are called');\n\t\t\tt.end();\n\t\t});\n\n});\n\n// prints to STDOUT as normal\nhelperTestFnLoud(testName);\n\n// silenced \u003e collect results in JSON thru .Producer 'end' evt\nhelperTestFnSilent.test(testName);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechjacker%2Ftap-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechjacker%2Ftap-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechjacker%2Ftap-wrapper/lists"}