Name: js-handler/node_modules/nodeunit/node_modules/tap/README.md
| 1: | This is a mix-and-match set of utilities that you can use to write test |
| 2: | harnesses and frameworks that communicate with one another using the |
| 3: | Test Anything Protocol. |
| 4: | |
| 5: | If you don't yet know what TAP is, [you better ask |
| 6: | somebody](http://testanything.org/). |
| 7: | |
| 8: | Default Usage: |
| 9: | |
| 10: | 1. Make a directory. Maybe call it 'test'. That'd be nice and obvious. |
| 11: | 2. Put a bunch of test scripts in there. If they're node programs, then |
| 12: | they should be ".js". Anything else is assumed to be some kind of shell |
| 13: | script, which should have a shebang line. |
| 14: | 3. `npm install tap` |
| 15: | 4. Update package.json scripts.test to include `tap ./test` [example |
| 16: | gist](https://gist.github.com/4469613) |
| 17: | 5. `npm test` |
| 18: | |
| 19: | The output will be TAP-compliant. |
| 20: | |
| 21: | For extra special bonus points, you can do something like this: |
| 22: | |
| 23: | var test = require("tap").test |
| 24: | test("make sure the thingie is a thing", function (t) { |
| 25: | t.equal(thingie, "thing", "thingie should be thing") |
| 26: | t.type(thingie, "string", "type of thingie is string") |
| 27: | t.ok(true, "this is always true") |
| 28: | t.notOk(false, "this is never true") |
| 29: | t.test("a child test", function (t) { |
| 30: | t.equal(this, superEasy, "right!?") |
| 31: | t.similar(7, 2, "ever notice 7 is kinda like 2?", {todo: true}) |
| 32: | t.test("so skippable", {skip: true}, function (t) { |
| 33: | t.plan(1) // only one test in this block |
| 34: | t.ok(true, "but when the flag changes, it'll pass") |
| 35: | // no need to end, since we had a plan. |
| 36: | }) |
| 37: | t.end() |
| 38: | }) |
| 39: | t.ok(99, "can also skip individual assertions", {skip: true}) |
| 40: | // end lets it know it's over. |
| 41: | t.end() |
| 42: | }) |
| 43: | test("another one", function (t) { |
| 44: | t.plan(1) |
| 45: | t.ok(true, "It's ok to plan, and also end. Watch.") |
| 46: | t.end() // but it must match the plan! |
| 47: | }) |
| 48: | |
| 49: | Node-tap is actually a collection of several modules, any of which may be |
| 50: | mixed and matched however you please. |
| 51: | |
| 52: | If you don't like this test framework, and think you can do much much |
| 53: | better, *I strongly encourage you to do so!* If you use this library, |
| 54: | however, at least to output TAP-compliant results when `process.env.TAP` |
| 55: | is set, then the data coming out of your framework will be much more |
| 56: | consumable by machines. |
| 57: | |
| 58: | You can also use this to build programs that *consume* the TAP data, so |
| 59: | this is very useful for CI systems and such. |
| 60: | |
| 61: | * tap-assert: A collection of assert functions that return TAP result |
| 62: | objects. |
| 63: | * tap-consumer: A stream interface for consuming TAP data. |
| 64: | * tap-producer: A class that produces a TAP stream by taking in result |
| 65: | objects. |
| 66: | * tap-results: A class for keeping track of TAP result objects as they |
| 67: | pass by, counting up skips, passes, fails, and so on. |
| 68: | * tap-runner: A program that runs through a directory running all the |
| 69: | tests in it. (Tests which may or may not be TAP-outputting tests. But |
| 70: | it's better if they are.) |
| 71: | * tap-test: A class for actually running tests. |
| 72: | * tap-harness: A class that runs tests. (Tests are also Harnesses, |
| 73: | which is how sub-tests run.) |
| 74: | * tap-global-harness: A default harness that provides the top-level |
| 75: | support for running TAP tests. |
| 76: | |
| 77: | ## Experimental Code Coverage with runforcover & bunker: |
| 78: | |
| 79: | ``` |
| 80: | TAP_COV=1 tap ./test [--cover=./lib,foo.js] [--cover-dir=./coverage] |
| 81: | ``` |
| 82: | |
| 83: | This feature is experimental, and will most likely change somewhat |
| 84: | before being finalized. Feedback welcome. |
