{
  "name": "nodeunit",
  "version": "0.8.8",
  "description": "Easy unit testing for node.js and the browser.",
  "maintainers": [
    {
      "name": "Caolan McMahon",
      "url": "https://github.com/caolan"
    }
  ],
  "contributors": [
    {
      "name": "Romain Beauxis",
      "url": "https://github.com/toots"
    },
    {
      "name": "Alex Gorbatchev",
      "url": "https://github.com/alexgorbatchev"
    },
    {
      "name": "Alex Wolfe",
      "url": "https://github.com/alexkwolfe"
    },
    {
      "name": "Carl Fürstenberg",
      "url": "https://github.com/azatoth"
    },
    {
      "name": "Gerad Suyderhoud",
      "url": "https://github.com/gerad"
    },
    {
      "name": "Kadir Pekel",
      "url": "https://github.com/coffeemate"
    },
    {
      "name": "Oleg Efimov",
      "url": "https://github.com/Sannis"
    },
    {
      "name": "Orlando Vazquez",
      "url": "https://github.com/orlandov"
    },
    {
      "name": "Ryan Dahl",
      "url": "https://github.com/ry"
    },
    {
      "name": "Sam Stephenson",
      "url": "https://github.com/sstephenson"
    },
    {
      "name": "Thomas Mayfield",
      "url": "https://github.com/thegreatape"
    },
    {
      "name": "Elijah Insua",
      "email": "tmpvar@gmail.com",
      "url": "http://tmpvar.com"
    }
  ],
  "repository": {
    "type": "git",
    "url": "http://github.com/caolan/nodeunit.git"
  },
  "devDependencies": {
    "uglify-js": ">=1.1.0",
    "should": ">=0.4.2"
  },
  "bugs": {
    "url": "http://github.com/caolan/nodeunit/issues"
  },
  "licenses": [
    {
      "type": "MIT",
      "url": "http://github.com/caolan/nodeunit/raw/master/LICENSE"
    }
  ],
  "directories": {
    "lib": "./lib",
    "doc": "./doc",
    "man": "./man1"
  },
  "bin": {
    "nodeunit": "./bin/nodeunit"
  },
  "dependencies": {
    "tap": ">=0.2.3"
  },
  "scripts": {
    "test": "node ./bin/nodeunit test"
  },
  "man": [
    "/home/mrhoz/.npm/nodeunit/0.8.8/package/man1/nodeunit.1"
  ],
  "readme": "Nodeunit\n========\n\nSimple syntax, powerful tools. Nodeunit provides easy async unit testing for\nnode.js and the browser.\n\n* Simple to use\n* Just export the tests from a module\n* Works with node.js and in the browser\n* Helps you avoid common pitfalls when testing asynchronous code\n* Easy to add test cases with setUp and tearDown functions if you wish\n* Flexible reporters for custom output, built-in support for HTML and jUnit XML\n* Allows the use of mocks and stubs\n\n__Contributors__\n\n* [alexgorbatchev](https://github.com/alexgorbatchev)\n* [alexkwolfe](https://github.com/alexkwolfe)\n* [azatoth](https://github.com/azatoth)\n* [kadirpekel](https://github.com/kadirpekel)\n* [lambdalisue](https://github.com/lambdalisue)\n* [luebken](https://github.com/luebken)\n* [orlandov](https://github.com/orlandov)\n* [Sannis](https://github.com/Sannis)\n* [sstephenson](https://github.com/sstephenson)\n* [thegreatape](https://github.com/thegreatape)\n* [mmalecki](https://github.com/mmalecki)\n* and thanks to [cjohansen](https://github.com/cjohansen) for input and advice\n  on implementing setUp and tearDown functions. See\n  [cjohansen's fork](https://github.com/cjohansen/nodeunit).\n\nAlso, check out gerad's [nodeunit-dsl](https://github.com/gerad/nodeunit-dsl)\nproject, which implements a 'pretty dsl on top of nodeunit'.\n\nMore contributor information can be found in the\n[CONTRIBUTORS.md](https://github.com/caolan/nodeunit/blob/master/CONTRIBUTORS.md)\nfile.\n\nUsage\n-----\n\nHere is an example unit test module:\n\n    exports.testSomething = function(test){\n        test.expect(1);\n        test.ok(true, \"this assertion should pass\");\n        test.done();\n    };\n\n    exports.testSomethingElse = function(test){\n        test.ok(false, \"this assertion should fail\");\n        test.done();\n    };\n\nWhen run using the included test runner, this will output the following:\n\n<img src=\"https://github.com/caolan/nodeunit/raw/master/img/example_fail.png\" />\n\nInstallation\n------------\n\nThere are two options for installing nodeunit:\n\n1. Clone / download nodeunit from [github](https://github.com/caolan/nodeunit),\n   then:\n\n    make && sudo make install\n\n2. Install via npm:\n\n    npm install nodeunit -g\n\nAPI Documentation\n-----------------\n\nNodeunit uses the functions available in the node.js\n[assert module](http://nodejs.org/docs/v0.4.2/api/assert.html):\n\n* __ok(value, [message])__ - Tests if value is a true value.\n* __equal(actual, expected, [message])__ - Tests shallow, coercive equality\n  with the equal comparison operator ( == ).\n* __notEqual(actual, expected, [message])__ - Tests shallow, coercive\n  non-equality with the not equal comparison operator ( != ).\n* __deepEqual(actual, expected, [message])__ - Tests for deep equality.\n* __notDeepEqual(actual, expected, [message])__ - Tests for any deep\n  inequality.\n* __strictEqual(actual, expected, [message])__ - Tests strict equality, as\n  determined by the strict equality operator ( === )\n* __notStrictEqual(actual, expected, [message])__ - Tests strict non-equality,\n  as determined by the strict not equal operator ( !== )\n* __throws(block, [error], [message])__ - Expects block to throw an error.\n* __doesNotThrow(block, [error], [message])__ - Expects block not to throw an\n  error.\n* __ifError(value)__ - Tests if value is not a false value, throws if it is a\n  true value. Useful when testing the first argument, error in callbacks.\n\nNodeunit also provides the following functions within tests:\n\n* __expect(amount)__ - Specify how many assertions are expected to run within a\n  test. Very useful for ensuring that all your callbacks and assertions are\n  run.\n* __done()__ - Finish the current test function, and move on to the next. ALL\n  tests should call this!\n\nNodeunit aims to be simple and easy to learn. This is achieved through using\nexisting structures (such as node.js modules) to maximum effect, and reducing\nthe API where possible, to make it easier to digest.\n\nTests are simply exported from a module, but they are still run in the order\nthey are defined.\n\n__Note:__ Users of old nodeunit versions may remember using `ok`, `equals` and \n`same` in the style of qunit, instead of the assert functions above. These \nfunctions still exist for backwards compatibility, and are simply aliases to \ntheir assert module counterparts.\n\n\nAsynchronous Testing\n--------------------\n\nWhen testing asynchronous code, there are a number of sharp edges to watch out\nfor. Thankfully, nodeunit is designed to help you avoid as many of these\npitfalls as possible. For the most part, testing asynchronous code in nodeunit\n_just works_.\n\n\n### Tests run in series\n\nWhile running tests in parallel seems like a good idea for speeding up your\ntest suite, in practice I've found it means writing much more complicated\ntests. Because of node's module cache, running tests in parallel means mocking\nand stubbing is pretty much impossible. One of the nicest things about testing\nin javascript is the ease of doing stubs:\n\n    var _readFile = fs.readFile;\n    fs.readFile = function(path, callback){\n        // it's a stub!\n    };\n    // test function that uses fs.readFile\n\n    // we're done\n    fs.readFile = _readFile;\n\nYou cannot do this when running tests in parallel. In order to keep testing as\nsimple as possible, nodeunit avoids it. Thankfully, most unit-test suites run\nfast anyway.\n\n\n### Explicit ending of tests\n\nWhen testing async code it's important that tests end at the correct point, not\njust after a given number of assertions. Otherwise your tests can run short,\nending before all assertions have completed. It's important to detect too\nmany assertions as well as too few. Combining explicit ending of tests with\nan expected number of assertions helps to avoid false test passes, so be sure\nto use the `test.expect()` method at the start of your test functions, and\n`test.done()` when finished.\n\n\nGroups, setUp and tearDown\n--------------------------\n\nNodeunit allows the nesting of test functions:\n\n    exports.test1 = function (test) {\n        ...\n    }\n\n    exports.group = {\n        test2: function (test) {\n            ...\n        },\n        test3: function (test) {\n            ...\n        }\n    }\n\nThis would be run as:\n\n    test1\n    group - test2\n    group - test3\n\nUsing these groups, Nodeunit allows you to define a `setUp` function, which is\nrun before each test, and a `tearDown` function, which is run after each test\ncalls `test.done()`:\n\n    module.exports = {\n        setUp: function (callback) {\n            this.foo = 'bar';\n            callback();\n        },\n        tearDown: function (callback) {\n            // clean up\n            callback();\n        },\n        test1: function (test) {\n            test.equals(this.foo, 'bar');\n            test.done();\n        }\n    };\n\nIn this way, it's possible to have multiple groups of tests in a module, each\ngroup with its own setUp and tearDown functions.\n\n\nRunning Tests\n-------------\n\nNodeunit comes with a basic command-line test runner, which can be installed\nusing `sudo make install`. Example usage:\n\n    nodeunit testmodule1.js testfolder [...]\n\nThe default test reporter uses color output, because I think that's more fun :) I\nintend to add a no-color option in future. To give you a feeling of the fun you'll\nbe having writing tests, lets fix the example at the start of the README:\n\n<img src=\"https://github.com/caolan/nodeunit/raw/master/img/example_pass.png\" />\n\nAhhh, Doesn't that feel better?\n\nWhen using the included test runner, it will exit using the failed number of\nassertions as the exit code.  This means it exits with 0 when all tests pass.\n\n\n### Command-line Options\n\n* __--reporter FILE__ - you can set the test reporter to a custom module or\non of the modules in nodeunit/lib/reporters, when omitted, the default test runner\nis used.\n* __--list-reporters__ - list available built-in reporters.\n* __--config FILE__ - load config options from a JSON file, allows\nthe customisation of color schemes for the default test reporter etc. See\nbin/nodeunit.json for current available options.\n* __--version__ or __-v__ - report nodeunit version\n* __--help__ - show nodeunit help\n\n\nRunning tests in the browser\n----------------------------\n\nNodeunit tests can also be run inside the browser. For example usage, see\nthe examples/browser folder. The basic syntax is as follows:\n\n__test.html__\n\n    <html>\n      <head>\n        <title>Example Test Suite</title>\n        <link rel=\"stylesheet\" href=\"nodeunit.css\" type=\"text/css\" />\n        <script src=\"nodeunit.js\"></script>\n        <script src=\"suite1.js\"></script>\n        <script src=\"suite2.js\"></script>\n      </head>\n      <body>\n        <h1 id=\"nodeunit-header\">Example Test Suite</h1>\n        <script>\n          nodeunit.run({\n            'Suite One': suite1,\n            'Suite Two': suite2\n          });\n        </script>\n      </body>\n    </html>\n\nHere, `suite1` and `suite2` are just object literals containing test functions\nor groups, as would be returned if you did `require('test-suite')` in node.js:\n\n__suite1.js__\n\n    this.suite1 = {\n        'example test': function (test) {\n            test.ok(true, 'everything is ok');\n            test.done();\n        }\n    };\n\nIf you wish to use a commonjs format for your test suites (using exports), it is\nup to you to define the commonjs tools for the browser. There are a number of\nalternatives and it's important it fits with your existing code, which is\nwhy nodeunit does not currently provide this out of the box.\n\nIn the example above, the tests will run when the page is loaded.\n\nThe browser-version of nodeunit.js is created in dist/browser when you do, `make\nbrowser`. You'll need [UglifyJS](https://github.com/mishoo/UglifyJS) installed in\norder for it to automatically create nodeunit.min.js.\n\n\nAdding nodeunit to Your Projects\n--------------------------------\n\nIf you don't want people to have to install the nodeunit command-line tool,\nyou'll want to create a script that runs the tests for your project with the\ncorrect require paths set up. Here's an example test script, that assumes you\nhave nodeunit in a suitably located node_modules directory.\n\n    #!/usr/bin/env node\n    var reporter = require('nodeunit').reporters.default;\n    reporter.run(['test']);\n\nIf you're using git, you might find it useful to include nodeunit as a\nsubmodule. Using submodules makes it easy for developers to download nodeunit\nand run your test suite, without cluttering up your repository with\nthe source code. To add nodeunit as a git submodule do the following:\n\n    git submodule add git://github.com/caolan/nodeunit.git node_modules/nodeunit\n\nThis will add nodeunit to the node_modules folder of your project. Now, when\ncloning the repository, nodeunit can be downloaded by doing the following:\n\n    git submodule init\n    git submodule update\n\nLet's update the test script above with a helpful hint on how to get nodeunit,\nif it's missing:\n\n    #!/usr/bin/env node\n    try {\n        var reporter = require('nodeunit').reporters.default;\n    }\n    catch(e) {\n        console.log(\"Cannot find nodeunit module.\");\n        console.log(\"You can download submodules for this project by doing:\");\n        console.log(\"\");\n        console.log(\"    git submodule init\");\n        console.log(\"    git submodule update\");\n        console.log(\"\");\n        process.exit();\n    }\n\n    process.chdir(__dirname);\n    reporter.run(['test']);\n\nNow if someone attempts to run your test suite without nodeunit installed they\nwill be prompted to download the submodules for your project.\n\n\nBuilt-in Test Reporters\n-----------------------\n\n* __default__ - The standard reporter seen in the nodeunit screenshots\n* __minimal__ - Pretty, minimal output, shows errors and progress only\n* __html__ - Outputs a HTML report to stdout\n* __junit__ - Creates jUnit compatible XML reports, which can be used with\n  continuous integration tools such as [Hudson](http://hudson-ci.org/).\n* __machineout__ - Simple reporter for machine analysis. There is\n  [nodeunit.vim](https://github.com/lambdalisue/nodeunit.vim) which is useful for TDD on VIM.\n\n\nWriting a Test Reporter\n---------------------\n\nNodeunit exports runTest(fn, options), runModule(mod, options) and\nrunFiles(paths, options). You'll most likely want to run test suites from\nfiles, which can be done using the latter function. The _options_ argument can\ncontain callbacks which run during testing. Nodeunit provides the following\ncallbacks:\n\n* __moduleStart(name)__ - called before a module is tested\n* __moduleDone(name, assertions)__ - called once all test functions within the\n  module have completed (see assertions object reference below)\n  ALL tests within the module\n* __testStart(name)__ - called before a test function is run\n* __testReady(test)__ - called before a test function is run with the test object that will be passed to the test function\n* __testDone(name, assertions)__ - called once a test function has completed\n  (by calling test.done())\n* __log(assertion)__ - called whenever an assertion is made (see assertion\n  object reference below)\n* __done(assertions)__ - called after all tests/modules are complete\n\nThe __assertion__ object:\n\n* __passed()__ - did the assertion pass?\n* __failed()__ - did the assertion fail?\n* __error__ - the AssertionError if the assertion failed\n* __method__ - the nodeunit assertion method used (ok, same, equals...)\n* __message__ - the message the assertion method was called with (optional)\n\nThe __assertionList__ object:\n\n* An array-like object with the following new attributes:\n  * __failures()__ - the number of assertions which failed\n  * __duration__ - the time taken for the test to complete in msecs\n\nFor a reference implementation of a test reporter, see lib/reporters/default.js in\nthe nodeunit project directory.\n\n\nSandbox utility\n---------------\n\nThis is a function which evaluates JavaScript files in a sandbox and returns the\ncontext. The sandbox function can be used for testing client-side code or private\nun-exported functions within a module.\n\n    var sandbox = require('nodeunit').utils.sandbox;\n    var example = sandbox('example.js');\n\n__sandbox(files, sandbox)__ - Evaluates JavaScript files in a sandbox, returning\nthe context. The first argument can either be a single filename or an array of\nfilenames. If multiple filenames are given their contents are concatenated before\nevaluation. The second argument is an optional context to use for the sandbox.\n\nNote: When working with the sandbox if your script depends on outside sources\n(i.e. using `require`) then you will want to pass that into the optional\ncontext when setting up the sandbox.\n\n    var sandbox = require('nodeunit').utils.sandbox;\n    // pass in some node globals\n    var box_globals = {\n        // Passing module.exports into the sandbox will give your code  access to it.\n        module: {exports: exports},\n        // Passing require into the sandbox will give your code  access to use it AND \n        // will share the cache with modules already required from outside the sandbox.\n        require: require,\n        // Passing console into the sandbox will give your code access to it\n        console: console\n    };\n    var example = sandbox('example.js', box_globals);\n\n\nRunning the nodeunit Tests\n--------------------------\n\nThe tests for nodeunit are written using nodeunit itself as the test framework.\nHowever, the module test-base.js first does some basic tests using the assert\nmodule to ensure that test functions are actually run, and a basic level of\nnodeunit functionality is available.\n\nTo run the nodeunit tests do:\n\n    make test\n\n__Note:__ There was a bug in node v0.2.0 causing the tests to hang, upgrading\nto v0.2.1 fixes this.\n\n\n__machineout__ reporter\n----------------------------------------------\n\nThe default reporter is readable for human but not for machine analysis. \nWhen you want to analyze the output of nodeunit, use __machineout__ reporter and you will get\n\n<img src=\"https://github.com/caolan/nodeunit/raw/master/img/example_machineout.png\" />\n\n\nnodeunit with vim\n----------------------------------\nThere is [nodeunit.vim](https://github.com/lambdalisue/nodeunit.vim) so you can use\nnodeunit with VIM.\n\nThat compiler uses __machineout__ reporter and it is useful to use\nwith [vim-makegreen](https://github.com/reinh/vim-makegreen).\n\n    \n\nContributing\n------------\n\nContributions to the project are most welcome, so feel free to fork and improve.\nWhen submitting a pull request, please run `make lint` first to ensure\nwe're following a consistent coding style.\n",
  "readmeFilename": "README.md",
  "homepage": "https://github.com/caolan/nodeunit",
  "_id": "nodeunit@0.8.8",
  "_shasum": "51e97226ba3a1f996e7ae0ee6a7a2837643aeb02",
  "_from": "nodeunit@~0.8.0",
  "_resolved": "https://registry.npmjs.org/nodeunit/-/nodeunit-0.8.8.tgz"
}
