{"bugs":{"url":"http://github.com/rsdoiel/harness-js/issues"},"dist":{"shasum":"82475d8a495ee8ccc9b6ed99c6ebfaf50dcd252b","tarball":"https://registry.npmjs.org/harness/-/harness-0.0.6.tgz","integrity":"sha512-cYqc41YsMXsAWAIQ/E5tj0rI/2IpGB2oUEOCQ1MhtaiEPTX59NFlt5uD7dqsU2w0VSHbCOc5apPm7Xrdxibdpw==","signatures":[{"sig":"MEQCIHHnsntfH68Kf4L04F0r/wzcPyAlPq+Pon+cCs18csY1AiABqKXQAVMfWP5w0+D3XuzcGs/pNa/IgGhfTc98mB0WFA==","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 and\nyou modern web browser.  Being able to run across these three environments \nwithout depending on libraries like RequireJS was a major reason I wrote this\nmodule. 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```\n\n# Including targets for tests\n\nNow that we can run tests on multiple platforms we still have occasion\nto only need to run tests for specific targets. You can test a list\nof targets when you call harness' push method.  The list of supported\ntargets are \"node\", \"mongo\" and \"browser\".  Here's an example of group\ntests for each of these targets-\n\n```JavaScript\n\tvar path = require(\"path\"),\n\t\tassert = require(\"assert\"),\n\t\tharness = require(\"../harness\");\n\t\n\t// This are tests targeted at the browser only\n\tharness.push({callback: function (test_label) {\n\t\tassert.ok(true, \"Browser only\");\n\t\tharness.completed(test_label);\n\t}, label: \"BrowserOnly\", targets: [\"browser\"]});\n\t\n\tharness.push({callback: function (test_label) {\n\t\tassert.ok(true, \"Node only\");\n\t\tharness.completed(test_label);\n\t}, label: \"NodeOnly\", targets: [\"node\"]});\n\t\n\tharness.push({callback: function (test_label) {\n\t\tassert.ok(true, \"Mongo only\");\n\t\tharness.completed(test_label);\n\t}, label: \"MongoOnly\", targets: [\"mongo\"]});\n\t\n\tharness.push({callback: function (test_label) {\n\t\tassert.ok(true, \"Mongo only\");\n\t\tharness.completed(test_label);\n\t}, label: \"Combination\", targets: [\"node\", \"mongo\", \"browser\"]});\n\t\n\tharness.RunIt(\"Target Demo\", 10);\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.66","description":"Yet another test organizer except this one works in NodeJS, Mongo 2.2's shell and modern web browsers.","maintainers":[{"name":"rsdoiel","email":"rsdoiel@gmail.com"}],"readmeFilename":"README.md","_id":"harness@0.0.6","version":"0.0.6"}