{"bugs":{"url":"http://github.com/rsdoiel/harness-js/issues"},"dist":{"shasum":"07a9f6333a2ab5a1d0c644f62ffa69aec0a7da03","tarball":"https://registry.npmjs.org/harness/-/harness-0.0.3.tgz","integrity":"sha512-7Knmbl5LW7ukowTR8ZIqhbkAKXeGiwXFXf1rvVPWSjVlhZiWQDysezjy1Jmgb9dOVGixwGwYDylgh1C7C4dizw==","signatures":[{"sig":"MEUCIF8rbMPm6vIy/Hoq+ixlhcQDilfM0OTyK/6hoQyl3zjvAiEA89ehAtKRW0C/l9GkxKujJnRUdrxCULO6U1SlZyhXnXI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./harness.js","name":"harness","author":{"url":"https://github.com/rsdoiel","name":"R. S. Doiel","email":"rsdoiel@gmail.com"},"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 (test_label) {\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_label);\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 (test_label) {\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_label);\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 (test_label) {\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_label);\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 (test_label) {\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_label);\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```","engines":{"npm":">= 1.1","node":">= 0.8","mongo":">= 2.2"},"scripts":{"test":"node tests/harness_test.js"},"_npmUser":{"name":"rsdoiel","email":"rsdoiel@gmail.com"},"repository":{"url":"https://github.com/rsdoiel/harness-js.git","type":"git"},"_npmVersion":"1.1.62","description":"Yet another test organizer except this one works in NodeJS and Mongo 2.2's shell.","directories":{},"maintainers":[{"name":"rsdoiel","email":"rsdoiel@gmail.com"}],"_id":"harness@0.0.3","version":"0.0.3"}