{"_id":"trap","_rev":"1760808","name":"trap","description":"A simpler way to test your code.","dist-tags":{"latest":"0.4.2"},"maintainers":[{"name":"danielmoore","email":"polaris@northhorizon.net"}],"time":{"modified":"2026-11-25T21:18:46.000Z","created":"2013-01-15T14:47:49.572Z","0.4.2":"2013-03-01T12:55:34.560Z","0.4.1":"2013-02-18T02:18:32.864Z","0.4.0":"2013-02-08T03:17:53.862Z","0.3.2":"2013-01-21T23:31:33.624Z","0.3.1":"2013-01-21T22:55:18.029Z","0.3.0":"2013-01-20T23:29:00.362Z","0.2.1":"2013-01-17T14:18:17.203Z","0.2.0":"2013-01-17T11:36:11.420Z","0.1.0":"2013-01-15T14:47:49.572Z"},"users":{},"author":{"name":"Daniel Moore"},"repository":{"type":"git","url":"https://github.com/danielmoore/trap.git"},"versions":{"0.4.2":{"name":"trap","version":"0.4.2","description":"A simpler way to test your code.","main":"index.js","bin":{"node-trap":"bin/trap.js","trap":"bin/trap.js"},"scripts":{"test":"node test/_runner"},"repository":{"type":"git","url":"https://github.com/danielmoore/trap.git"},"author":{"name":"Daniel Moore"},"keywords":["tap","test","harness"],"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.php"}],"devDependencies":{"tape":"~0.1.5","proxyquire":"~0.4.0","q":"~0.8.12"},"dependencies":{"optimist":"~0.3.5","glob":"~3.1.14","ansistyles":"~0.1.0","ansicolors":"~0.2.1","diff":"~1.0.4","difflet":"~0.2.3"},"readmeFilename":"README.md","_id":"trap@0.4.2","dist":{"shasum":"c6ede62162196a5c0480a31b0e7a1a0a9758261b","tarball":"http://registry-npm.ywwl.com/trap/download/trap-0.4.2.tgz","integrity":"sha512-gDHwbWqjvvwyURb9oYHW+eaT1D4XlPSUBZ7OHLWmpMAWmVn0VwEaE9+6bCHIJYMVLetKEllnItSsUnsC5atUZA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD2Lc/eR6mbnmwUBe9pf0XGVYCO9LcwUY/OSrpCbaU6hgIhANDMuH02bk4MhH4HcHqnXp8ml0YYbV8YjZphQzAo2CXs"}],"size":10924,"noattachment":false,"key":"/trap/-/trap-0.4.2.tgz"},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"danielmoore","email":"polaris@northhorizon.net"},"maintainers":[{"name":"danielmoore","email":"polaris@northhorizon.net"}],"publish_time":1362142534560,"_cnpm_publish_time":1362142534560},"0.4.1":{"name":"trap","version":"0.4.1","description":"A simpler way to test your code.","main":"index.js","bin":{"node-trap":"bin/trap.js","trap":"bin/trap.js"},"scripts":{"test":"node test/_runner"},"repository":{"type":"git","url":"https://github.com/danielmoore/trap.git"},"author":{"name":"Daniel Moore"},"keywords":["tap","test","harness"],"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.php"}],"devDependencies":{"tape":"~0.1.5","proxyquire":"~0.4.0","q":"~0.8.12"},"dependencies":{"optimist":"~0.3.5","glob":"~3.1.14","ansistyles":"~0.1.0","ansicolors":"~0.2.1","diff":"~1.0.4","difflet":"~0.2.3"},"readmeFilename":"README.md","_id":"trap@0.4.1","dist":{"shasum":"e28ad20e52516070ebe4e90129b731d10440d5ca","tarball":"http://registry-npm.ywwl.com/trap/download/trap-0.4.1.tgz","integrity":"sha512-di/rxanwcSNoY8z6RbhPGW73zo+LYGZ6SoUVCZi3bxXUOX3oFIWzOy5/M2JoDqQQZUDpeLuBE5NNXCaU/h33+A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAQdh1i+utTgJ94Dwysn/faX80bODRSld2pnGoRBMBC1AiEAj3KblhWZYtpzt+pKnND8M594v43LGRJu4HQStOqlswM="}],"size":10531,"noattachment":false,"key":"/trap/-/trap-0.4.1.tgz"},"_from":".","_npmVersion":"1.2.10","_npmUser":{"name":"danielmoore","email":"polaris@northhorizon.net"},"maintainers":[{"name":"danielmoore","email":"polaris@northhorizon.net"}],"publish_time":1361153912864,"_cnpm_publish_time":1361153912864},"0.4.0":{"name":"trap","version":"0.4.0","description":"A simpler way to test your code.","main":"index.js","bin":{"node-trap":"bin/trap.js","trap":"bin/trap.js"},"scripts":{"test":"node test/_runner"},"repository":{"type":"git","url":"https://github.com/danielmoore/trap.git"},"author":{"name":"Daniel Moore"},"keywords":["tap","test","harness"],"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.php"}],"devDependencies":{"tape":"~0.1.5","proxyquire":"~0.4.0","q":"~0.8.12"},"dependencies":{"optimist":"~0.3.5","glob":"~3.1.14","ansistyles":"~0.1.0","ansicolors":"~0.2.1","diff":"~1.0.4","difflet":"~0.2.3"},"readmeFilename":"README.md","_id":"trap@0.4.0","dist":{"shasum":"a0587868d5e0b8d686d6f2661568d71f31b12039","tarball":"http://registry-npm.ywwl.com/trap/download/trap-0.4.0.tgz","integrity":"sha512-7OsM0m7xUurPnxmUteQigFdIsCt/HXb4KgqcfsO9BiJNm72Ln8JOiXKaHw3cniddvnS1eOujKc1UQi3+MgH6gw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDdv8Cz3JCoDlm5ABw4rHM/AAXrvnQq0nY/r60Ycn7JVAIhAPF3TbFl4O7Ka2BmVs8GxpHjfaTLJQSVmgvcUw3X1riB"}],"size":10555,"noattachment":false,"key":"/trap/-/trap-0.4.0.tgz"},"_from":".","_npmVersion":"1.2.10","_npmUser":{"name":"danielmoore","email":"polaris@northhorizon.net"},"maintainers":[{"name":"danielmoore","email":"polaris@northhorizon.net"}],"publish_time":1360293473862,"_cnpm_publish_time":1360293473862},"0.3.2":{"name":"trap","version":"0.3.2","description":"A simpler way to test your code.","main":"index.js","bin":{"node-trap":"bin/trap.js","trap":"bin/trap.js"},"scripts":{"test":"node test/_runner"},"repository":{"type":"git","url":"https://github.com/danielmoore/trap.git"},"author":{"name":"Daniel Moore"},"keywords":["tap","test","harness"],"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.php"}],"devDependencies":{"tape":"~0.1.5","proxyquire":"~0.4.0","q":"~0.8.12"},"dependencies":{"optimist":"~0.3.5","glob":"~3.1.14","ansistyles":"~0.1.0","ansicolors":"~0.2.1","diff":"~1.0.4","difflet":"~0.2.3"},"readmeFilename":"README.md","_id":"trap@0.3.2","dist":{"shasum":"bc1820113458e8b6979c8f134d4e27149d3e1d59","tarball":"http://registry-npm.ywwl.com/trap/download/trap-0.3.2.tgz","integrity":"sha512-CGl7M0XXUPIqQZ9ljE9s2wHH+iwk6eGKTaRV6cpChW7ItMnz8DJ1HDamQPiVv9i0gnAnaV8OwipZ3lGklicirw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDJnxqWI0jlv69fEnDm+PDmLBluYcSqyPqPkkzHpG68RAIgQyjpdyJSm54s7aMDZTXYZCGecH5oo9plWfX7OoK/CwE="}],"size":9978,"noattachment":false,"key":"/trap/-/trap-0.3.2.tgz"},"_npmVersion":"1.1.66","_npmUser":{"name":"danielmoore","email":"polaris@northhorizon.net"},"maintainers":[{"name":"danielmoore","email":"polaris@northhorizon.net"}],"publish_time":1358811093624,"_cnpm_publish_time":1358811093624},"0.3.1":{"name":"trap","version":"0.3.1","description":"A simpler way to test your code.","main":"index.js","bin":{"node-trap":"bin/trap.js","trap":"bin/trap.js"},"scripts":{"test":"node test/_runner"},"repository":{"type":"git","url":"https://github.com/danielmoore/trap.git"},"author":{"name":"Daniel Moore"},"keywords":["tap","test","harness"],"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.php"}],"devDependencies":{"tape":"~0.1.5","proxyquire":"~0.4.0","q":"~0.8.12"},"dependencies":{"optimist":"~0.3.5","glob":"~3.1.14","ansistyles":"~0.1.0","ansicolors":"~0.2.1","diff":"~1.0.4"},"readmeFilename":"README.md","_id":"trap@0.3.1","dist":{"shasum":"4363d451f82c692fa8e4135ac4c8ad6511d1379e","tarball":"http://registry-npm.ywwl.com/trap/download/trap-0.3.1.tgz","integrity":"sha512-e5at4AjfbWUWrwA7XhHEdOBkfmJTcnvKV3Em9mOjRAx+zDW1g8KljPQesa7iEvIbiIvXf0Efd7kk7yq4Ysxdcg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHb6nzmb6LHO8UAJXgQEq3tieABBz3n4Kv4Arg8o2Y0TAiEAhiD3g4IZNUs6A5Wx0C/9YuVRDvOW7Na7T08xjsdYJdI="}],"size":9954,"noattachment":false,"key":"/trap/-/trap-0.3.1.tgz"},"_npmVersion":"1.1.66","_npmUser":{"name":"danielmoore","email":"polaris@northhorizon.net"},"maintainers":[{"name":"danielmoore","email":"polaris@northhorizon.net"}],"directories":{},"publish_time":1358808918029,"_cnpm_publish_time":1358808918029},"0.3.0":{"name":"trap","version":"0.3.0","description":"A simpler way to test your code.","main":"index.js","bin":{"node-trap":"bin/trap.js","trap":"bin/trap.js"},"scripts":{"test":"node test/_runner"},"repository":{"type":"git","url":"https://github.com/danielmoore/trap.git"},"author":{"name":"Daniel Moore"},"keywords":["tap","test","harness"],"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.php"}],"devDependencies":{"tape":"~0.1.5","proxyquire":"~0.4.0","q":"~0.8.12"},"dependencies":{"optimist":"~0.3.5","glob":"~3.1.14","ansistyles":"~0.1.0","ansicolors":"~0.2.1"},"readmeFilename":"README.md","_id":"trap@0.3.0","dist":{"shasum":"7d8b14c6a7d08bcdc0e3e29a6648f59f43929bf2","tarball":"http://registry-npm.ywwl.com/trap/download/trap-0.3.0.tgz","integrity":"sha512-npnrE4uL9Z3MA1cOi+qneGD1c+fxC9MCH5w35hIDIw02h5ky8s7ySyP7cN+vOiIo6+XRGZBEQa6a/cDwpr9eWQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDVMoL+k1Ht3SjZhSmfoHAjNvnC0wepqwAoJ4pgbQbVBAiEA9GpNj33PJKJ/V2lYj6KQJRc4c0WXkesViHPGtz8XeOQ="}],"size":9961,"noattachment":false,"key":"/trap/-/trap-0.3.0.tgz"},"_npmVersion":"1.1.66","_npmUser":{"name":"danielmoore","email":"polaris@northhorizon.net"},"maintainers":[{"name":"danielmoore","email":"polaris@northhorizon.net"}],"directories":{},"publish_time":1358724540362,"_cnpm_publish_time":1358724540362},"0.2.1":{"name":"trap","version":"0.2.1","description":"A simpler way to test your code.","main":"index.js","bin":{"node-trap":"bin/trap.js","trap":"bin/trap.js"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/danielmoore/trap.git"},"author":{"name":"Daniel Moore"},"keywords":["tap","test","harness"],"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.php"}],"devDependencies":{"tape":"~0.1.5","proxyquire":"~0.4.0","q":"~0.8.12"},"dependencies":{"colors":"~0.6.0-1","optimist":"~0.3.5","glob":"~3.1.14"},"readmeFilename":"README.md","_id":"trap@0.2.1","dist":{"shasum":"95d1911a717a2163f5535a1ce5c4395bafd5390f","tarball":"http://registry-npm.ywwl.com/trap/download/trap-0.2.1.tgz","integrity":"sha512-ULQlDt1H5IueRCEV/L94VjTR3M72WBkH8ZMrCNi3wGvoOkIx0uK+KIUyIeOxcgJ8s4sdHMSygL+BFepvqxrnOQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBloJFtn9+ze0z5Ga6Lf/oPKIL1HJuPIcbC3faYHbH8OAiBFZopAshABqPVjxm6gTyzB8kc+FtsDapAxRgUqUHf9zQ=="}],"size":8611,"noattachment":false,"key":"/trap/-/trap-0.2.1.tgz"},"_npmVersion":"1.1.66","_npmUser":{"name":"danielmoore","email":"polaris@northhorizon.net"},"maintainers":[{"name":"danielmoore","email":"polaris@northhorizon.net"}],"directories":{},"publish_time":1358432297203,"_cnpm_publish_time":1358432297203},"0.2.0":{"name":"trap","version":"0.2.0","description":"A simpler way to test your code.","main":"index.js","bin":{"node-trap":"bin/trap.js","trap":"bin/trap.js"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/danielmoore/trap.git"},"author":{"name":"Daniel Moore"},"keywords":["tap","test","harness"],"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.php"}],"devDependencies":{"tape":"~0.1.5","proxyquire":"~0.4.0","q":"~0.8.12"},"dependencies":{"colors":"~0.6.0-1","optimist":"~0.3.5"},"readmeFilename":"README.md","_id":"trap@0.2.0","dist":{"shasum":"6dce407b9e5ca56aa969a76e7ca7a9b695dee472","tarball":"http://registry-npm.ywwl.com/trap/download/trap-0.2.0.tgz","integrity":"sha512-Jb7t0zom1k83sfsmFFurkSWhCrz31AHOfFjRkHyGdjlwS6l39qMR3TD+02HJl1NpVPXmSMQmptWAH7AKTqbANg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC5asr1QSKw9oivacMsZ4k9N+2UL0Uy5MPGjQWQOet3QwIhAMJ8zmjB35vqBItCCazSZSIk/CSi9IlMSfZ1aelZ01zp"}],"size":8564,"noattachment":false,"key":"/trap/-/trap-0.2.0.tgz"},"_npmVersion":"1.1.66","_npmUser":{"name":"danielmoore","email":"polaris@northhorizon.net"},"maintainers":[{"name":"danielmoore","email":"polaris@northhorizon.net"}],"directories":{},"publish_time":1358422571420,"_cnpm_publish_time":1358422571420},"0.1.0":{"name":"trap","version":"0.1.0","description":"A simpler way to test your code.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/danielmoore/trap.git"},"author":{"name":"Daniel Moore"},"keywords":["tap","test","harness"],"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.php"}],"devDependencies":{"tape":"~0.1.5","proxyquire":"~0.4.0"},"dependencies":{"colors":"~0.6.0-1"},"readmeFilename":"README.md","_id":"trap@0.1.0","dist":{"shasum":"839f983e19e72a5a39340fcdc4937c784d1c8b85","tarball":"http://registry-npm.ywwl.com/trap/download/trap-0.1.0.tgz","integrity":"sha512-iq1fpAej/2+zk0AYvIXTvHQD8a79Fc4hvKrz+sKzWcGCpr4jX02eD3EAH8FtLITs7Gfl9+srOzCUaIFqiTkY+g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCJUbINwZkCbTxQipkgQS7inF5kjWow1CTqoeSRivm78AIhAMVhApIWtZhQpVr55hLuquzMc+NA5zKdUKFcbNnN4iyn"}],"size":6651,"noattachment":false,"key":"/trap/-/trap-0.1.0.tgz"},"_npmVersion":"1.1.66","_npmUser":{"name":"danielmoore","email":"polaris@northhorizon.net"},"maintainers":[{"name":"danielmoore","email":"polaris@northhorizon.net"}],"directories":{},"publish_time":1358261269572,"_cnpm_publish_time":1358261269572}},"readme":"# trap [![build status](https://secure.travis-ci.org/danielmoore/trap.png)](http://next.travis-ci.org/danielmoore/trap)\n\ntrap is simply the most dead-simple test framework you can pick up. It builds and simplifies\nthe already simple structure of of `node-tap` or `tape`, but is extensible like `mocha`.\n\nGet started with\n\n    npm install trap\n\n![Output Sample][output-sample]\n\n## What do I need to know?\n\nTwo things: `test`, and `t.cb`. It's really that simple. You can use the assertion framework\nyou already know. By default trap uses the standard node assertion library. To run the tests in\nsingle file, just `node` the file.\n\n### `test`\n\nLike tap, we make new test blocks with the `test` function.\n\n```javascript\nvar test = require('trap').test;\n\ntest('This is a test block!', function (t) {\n  t.test('This is a child test block!', function (t) {\n    // continue to your heart's content.\n  });\n});\n```\n\n### `t.cb`\n\nUnlike tap, you don't need to figure out when your async tests are done runnning, nor\ndo you need to count how many assertions you have and plan them. Instead, simply register\nall of your callbacks with `t.cb`.\n\n```javascript\nvar test = require('trap').test;\n\ntest('Async stuff', function (t) {\n  setTimeout(t.cb(function() {\n    t.ok(true, 'This is still part of the \"Async stuff\" test!');\n  }), 100);\n});\n```\n\n#### Promises\n\nIf you happen to prefer promises over callbacks, we support that, too! Instead of using\n`t.cb()`, perform all of your assertions in a `.then(...)` continuation and return a\npromise that encompasses all of the work. Trap will wait for your promise to finish before\nrunning the next test. If your promise fails (e.g. unhandled exception), trap will report\nthat as an assertion failure.\n\n```javascript\nvar test = require('trap').test;\nvar Q = require('q'); // I'm using Q here, but you can use any promise-compliant library.\n\ntest('Promise stuff', function(t) {\n  var firstFired, secondFired;\n\n  return Q.all([\n    Q.delay(100).then(function() {\n      firstFired = true;\n      t.ok(!secondFired, 'First comes first');\n    }),\n    Q.delay(150).then(function() {\n      secondFired = true;\n      t.ok(firstFired, 'Second comes second');\n    })\n  ]);\n});\n```\n\n### Assertions\n\nTo get the maximum prettiness and documentation of trap, customize\n`config.createTextContext` to wrap your favorite assertion library. Otherwise\nyou can just throw exceptions like you normally do, and those will be interpreted as\nassertion failures. Hopefully soon we can get plugins for all the major assertion\nlibraries so this will be even easier.\n\n## Batch-Running Tests\n\nTrap has a command-line runner so you can run a whole suite of tests together. First, install trap globally:\n\n    npm install -g trap\n\nThen call trap like this:\n\n    node-trap [--config /path/to/config] [path1 [path2 [...]]]\n\nThe paths may use glob features supported by [minimatch][]. `--config` defaults to `./test/trap.config.js`\nand `path1` defaults to `./test/**/*.trap.js`.\n\nUnfortunately, `trap` is already taken by a bash builtin, so overriding it by default would be a little\npresumptuous. But, if you happen to not care about the builtin `trap` function and you really hate typing\n`node-`, you can disable the builtin and simultaneously enable `trap` by calling:\n\n    enable -n trap\n\nIf you change your mind, you can return to the usual `trap` functionality with:\n\n    enable trap\n\n## Examples\n\nCheck out the examples folder.\n\n[minimatch]: https://github.com/isaacs/minimatch\n[output-sample]: https://www.evernote.com/shard/s219/sh/fe24811a-5dad-4bce-94c1-360f2a7ad7b6/4674dfbf9231a0b14db31c631243da00/res/ac8f0327-dba1-42ea-830f-9dc9fb6cf6af/skitch.png\n","_attachments":{},"readmeFilename":"README.md"}