{"_id":"harness","_rev":"4639668","name":"harness","description":"Yet another test organizer except this one works in NodeJS, Mongo 2.2's shell and modern web browsers.","dist-tags":{"latest":"0.0.6"},"maintainers":[{"name":"rsdoiel","email":""}],"time":{"modified":"2026-04-10T19:37:24.000Z","created":"2012-10-12T18:16:18.952Z","0.0.6":"2012-11-26T19:51:39.410Z","0.0.5":"2012-10-15T05:06:01.947Z","0.0.4":"2012-10-13T06:53:21.345Z","0.0.3":"2012-10-12T18:16:18.952Z"},"users":{},"author":{"name":"R. S. Doiel","email":"rsdoiel@gmail.com","url":"https://github.com/rsdoiel"},"repository":{"type":"git","url":"https://github.com/rsdoiel/harness-js.git"},"versions":{"0.0.6":{"name":"harness","version":"0.0.6","description":"Yet another test organizer except this one works in NodeJS, Mongo 2.2's shell and modern web browsers.","main":"./harness.js","repository":{"type":"git","url":"https://github.com/rsdoiel/harness-js.git"},"author":{"name":"R. S. Doiel","email":"rsdoiel@gmail.com","url":"https://github.com/rsdoiel"},"maintainers":[{"name":"rsdoiel","email":""}],"engines":{"node":">= 0.8","npm":">= 1.1","mongo":">= 2.2"},"scripts":{"test":"node tests/harness_test.js"},"bugs":{"url":"http://github.com/rsdoiel/harness-js/issues"},"readmeFilename":"README.md","_id":"harness@0.0.6","dist":{"shasum":"82475d8a495ee8ccc9b6ed99c6ebfaf50dcd252b","size":5918,"noattachment":false,"key":"/harness/-/harness-0.0.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/harness/download/harness-0.0.6.tgz"},"_npmVersion":"1.1.66","_npmUser":{"name":"rsdoiel","email":"rsdoiel@gmail.com"},"directories":{},"publish_time":1353959499410,"_hasShrinkwrap":false,"_cnpm_publish_time":1353959499410,"_cnpmcore_publish_time":"2021-12-16T19:21:29.055Z"},"0.0.5":{"name":"harness","version":"0.0.5","description":"Yet another test organizer except this one works in NodeJS, Mongo 2.2's shell and modern web browsers.","main":"./harness.js","repository":{"type":"git","url":"https://github.com/rsdoiel/harness-js.git"},"author":{"name":"R. S. Doiel","email":"rsdoiel@gmail.com","url":"https://github.com/rsdoiel"},"maintainers":[{"name":"rsdoiel","email":""}],"engines":{"node":">= 0.8","npm":">= 1.1","mongo":">= 2.2"},"scripts":{"test":"node tests/harness_test.js"},"bugs":{"url":"http://github.com/rsdoiel/harness-js/issues"},"_id":"harness@0.0.5","dist":{"shasum":"ed4194c33aeced7cd05c635fbc8abf4d09796852","size":5911,"noattachment":false,"key":"/harness/-/harness-0.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/harness/download/harness-0.0.5.tgz"},"_npmVersion":"1.1.62","_npmUser":{"name":"rsdoiel","email":"rsdoiel@gmail.com"},"directories":{},"publish_time":1350277561947,"_hasShrinkwrap":false,"_cnpm_publish_time":1350277561947,"_cnpmcore_publish_time":"2021-12-16T19:21:29.258Z"},"0.0.4":{"name":"harness","version":"0.0.4","description":"Yet another test organizer except this one works in NodeJS and Mongo 2.2's shell.","main":"./harness.js","repository":{"type":"git","url":"https://github.com/rsdoiel/harness-js.git"},"author":{"name":"R. S. Doiel","email":"rsdoiel@gmail.com","url":"https://github.com/rsdoiel"},"maintainers":[{"name":"rsdoiel","email":""}],"engines":{"node":">= 0.8","npm":">= 1.1","mongo":">= 2.2"},"scripts":{"test":"node tests/harness_test.js"},"bugs":{"url":"http://github.com/rsdoiel/harness-js/issues"},"_id":"harness@0.0.4","dist":{"shasum":"f925d790d060956f23e83bf0d2370749f525308e","size":4267,"noattachment":false,"key":"/harness/-/harness-0.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/harness/download/harness-0.0.4.tgz"},"_npmVersion":"1.1.62","_npmUser":{"name":"rsdoiel","email":"rsdoiel@gmail.com"},"directories":{},"publish_time":1350111201345,"_hasShrinkwrap":false,"_cnpm_publish_time":1350111201345,"_cnpmcore_publish_time":"2021-12-16T19:21:29.479Z"},"0.0.3":{"name":"harness","version":"0.0.3","description":"Yet another test organizer except this one works in NodeJS and Mongo 2.2's shell.","main":"./harness.js","repository":{"type":"git","url":"https://github.com/rsdoiel/harness-js.git"},"author":{"name":"R. S. Doiel","email":"rsdoiel@gmail.com","url":"https://github.com/rsdoiel"},"maintainers":[{"name":"rsdoiel","email":""}],"engines":{"node":">= 0.8","npm":">= 1.1","mongo":">= 2.2"},"scripts":{"test":"node tests/harness_test.js"},"bugs":{"url":"http://github.com/rsdoiel/harness-js/issues"},"_id":"harness@0.0.3","dist":{"shasum":"07a9f6333a2ab5a1d0c644f62ffa69aec0a7da03","size":4260,"noattachment":false,"key":"/harness/-/harness-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/harness/download/harness-0.0.3.tgz"},"_npmVersion":"1.1.62","_npmUser":{"name":"rsdoiel","email":"rsdoiel@gmail.com"},"directories":{},"publish_time":1350065778952,"_hasShrinkwrap":false,"_cnpm_publish_time":1350065778952,"_cnpmcore_publish_time":"2021-12-16T19:21:29.679Z"}},"readme":"[![build status](https://secure.travis-ci.org/rsdoiel/harness-js.png)](http://travis-ci.org/rsdoiel/harness-js)\nharness-js\n==========\n\nYet another test organizers except that is work in NodeJS, Mongo's shell.  Being able to run across these three environments with depending on things like RequireJS was a major reason to write this module. Hopefully it is helpful to others.\n\n# Overview\n\nHarness provides a simple way of organizing assertive tests in Mongo's shell\n(using mongo-modules), NodeJS and in many web browsers.\n\n## NodeJS example\n\n```JavaScript\n\tvar path = require(\"path\"),\n\t\tassert = require(\"assert\"),\n\t\tharness = require(\"harness\");\n\t\n\t// Setup a test by assigning a function to callback and\n\t// a label to the test group.\n\tharness.push({callback: function () {\n\t\tassert.strictEqual(harness.counts(\"running\"), 1, \"Should have on test running for 'Testing push()'\");\n\t\n\t\t// Now that you've completed this test\n\t\t// group tell harness that this label\n\t\t// is now complete.\n\t\tharness.completed(\"Test group 1\");\n\t}, label: \"Test group 1\"});\n\t\n\t// This is a second test group just to show you can do\n\t// more than one group of tests.\n\t// Setup a test by assigning a function to callback and\n\t// a label to the test group.\n\tharness.push({callback: function () {\n\t\tassert.strictEqual(harness.counts(\"running\"), 2, \"Should have on test running for 'Testing push()'\");\n\t\n\t\t// Now that you've completed this test\n\t\t// group tell harness that this label\n\t\t// is now complete.\n\t\tharness.completed(\"Test group 2\");\n\t}, label: \"Test group 2\"});\n\t\n\tharness.RunIt(path.basename(module.filename), 10);\n```\n\nThe command to run *example/node-example.js* looks like-\n\n```shell\n\tnode example/node-example.js\n```\n\nThe output would look something like-\n\n```shell\n\tStarting [node-example.js] ...\n\t\tStarting Test group 1 ...\n\t\t\tTest group 1 called\n\t\t\tTest group 1 OK\n\t\tStarting Test group 2 ...\n\t\t\tTest group 2 called\n\t\t\tTest group 2 OK\n\tnode-example.js Success!\n```\n\n## Mongo example\n\nHarness support comes with [mongo-modules](git@github.com:rsdoiel/mongo-modules) and mongo-modules will need to be installed for it to work. Other\nthan that it looks much like the NodeJS version above. The difference is\nthat the module.filename object isn't defined by mongo-modules so we must\ndefine that ourselves.\n\n```JavaScript\n\tvar path = require(\"path\"),\n\t\tassert = require(\"assert\"),\n\t\tharness = require(\"harness\"),\n\t\t// mongo-modules does not define the module object's\n\t\t// filename.\n\t\tmodule = {\n\t\t\tfilename: \"mongo-example.js\"\n\t\t};\n\t\n\t// Setup a test by assigning a function to callback and\n\t// a label to the test group.\n\tharness.push({callback: function () {\n\t\tassert.strictEqual(harness.counts(\"running\"), 1,\n\t\t\t\"Should have on test running for 'Testing push()'\");\n\n\t\t// Now that you've completed this test\n\t\t// group tell harness that this label\n\t\t// is now complete.\n\t\tharness.completed(\"Test group 1\");\n\t}, label: \"Test group 1\"});\n\t\n\t// This is a second test group just to show you can do\n\t// more than one group of tests.\n\t// Setup a test by assigning a function to callback and\n\t// a label to the test group.\n\tharness.push({callback: function () {\n\t\tassert.strictEqual(harness.counts(\"running\"), 2, \"Should have on test running for 'Testing push()'\");\n\t\n\t\t// Now that you've completed this test\n\t\t// group tell harness that this label\n\t\t// is now complete.\n\t\tharness.completed(\"Test group 2\");\n\t}, label: \"Test group 2\"});\n\t\n\tharness.RunIt(path.basename(module.filename), 10);\n```\n\nRunning the *example/mongo-example.js* with mongo-modules available is done like-\n\n```shell\n\tmongo ~/.mongojs.rc example/mongo-example.js\n```\n\nThe output should look something like-\n\n```shell\n\tMongoDB shell version: 2.2.0\n\tconnecting to: test\n\tloading file: /Users/johndoe/.mongorc.js\n\tloading file: example/mongo-example.js\n\tStarting [mongo-example.js] ...\n\t\tStarting Test group 1 ...\n\t\t\tTest group 1 called\n\t\t\tTest group 1 OK\n\t\tStarting Test group 2 ...\n\t\t\tTest group 2 called\n\t\t\tTest group 2 OK\n\tmongo-example.js Success!\n```","_attachments":{},"readmeFilename":"README.md","bugs":{"url":"http://github.com/rsdoiel/harness-js/issues"}}