{"name":"tap","version":"21.7.2","keywords":["assert","tap","test","testing","framework","cli","tapjs","tapjs plugin"],"author":{"url":"https://blog.izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"license":"BlueOak-1.0.0","_id":"tap@21.7.2","maintainers":[{"name":"isaacs","email":"i@izs.me"}],"homepage":"https://github.com/tapjs/tapjs/tree/main/src/tap#readme","bugs":{"url":"https://github.com/tapjs/tapjs/issues"},"bin":{"tap":"dist/esm/run.mjs"},"tap":{"typecheck":false,"coverage-map":"map.js"},"dist":{"shasum":"a8ec60b98867d2f7f955fcc1c687ffc0bad72b0b","tarball":"http://registry-npm.ywwl.com/tap/download/tap-21.7.2.tgz","fileCount":33,"integrity":"sha512-i5dPkJcojXqrbo+liVpRGvhxN0/h+oweqxHmoztIJ5+E2//11mVUL6D0dU2ugriFUNdjdI7G9GR7nW6koEeYlA==","signatures":[{"sig":"MEQCIGLwFU98cA1/LFk0rmSnejedmcYA0RbEt+CFIVx2gK2VAiAKlLwAiP07pN8gwv+1zqZiAxFfjLEPnGcvn2+w5u8dTA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":80917,"size":16686,"noattachment":false,"key":"/tap/-/tap-21.7.2.tgz"},"main":"./dist/commonjs/index.js","tshy":{"main":true,"exports":{".":"./src/index.ts","./package.json":"./package.json"},"selfLink":false},"type":"module","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","engines":{"node":"20 || >=22"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"funding":{"url":"https://github.com/sponsors/isaacs"},"gitHead":"e79377683b8ec7853984771353b16175050b2541","scripts":{"snap":"tap","test":"tap","format":"prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache","prepare":"tshy","presnap":"npm run prepare","pretest":"npm run prepare","typedoc":"typedoc --tsconfig tsconfig/esm.json ./src/*.ts"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"repository":{"url":"git+ssh://git@github.com/tapjs/tapjs.git","path":"src/tap","type":"git"},"_npmVersion":"10.9.7","description":"A Test-Anything-Protocol library for JavaScript","directories":{},"_nodeVersion":"22.22.2","dependencies":{"@tapjs/run":"4.5.6","@tapjs/core":"4.5.6","@tapjs/mock":"4.4.6","@tapjs/test":"4.4.6","@tapjs/after":"3.3.8","@tapjs/chdir":"3.3.8","@tapjs/spawn":"4.3.8","@tapjs/stdin":"4.3.8","@tapjs/before":"4.3.8","@tapjs/filter":"4.3.8","@tapjs/worker":"4.3.8","@tapjs/asserts":"4.3.8","@tapjs/fixture":"4.3.8","resolve-import":"^2.4.0","@tapjs/snapshot":"4.3.8","@tapjs/intercept":"4.3.8","@tapjs/after-each":"4.3.8","@tapjs/typescript":"3.5.8","@tapjs/before-each":"4.3.8","@tapjs/node-serialize":"4.3.8"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tap_21.7.2_1777657057646_0.5459080678092965","host":"s3://npm-registry-packages-npm-production"},"readme":"# node-tap\n\nA <abbr title=\"Test Anything Protocol\">TAP</abbr> test framework\nfor Node.js.\n\n_Just wanna see some code? [Get\nstarted!](http://www.node-tap.org/basics/)_\n\nIt includes a command line test runner for consuming\nTAP-generating test scripts, and a JavaScript framework for\nwriting such scripts.\n\n<!-- TODO: update with new website docs links -->\n\n- [Getting started guide](http://node-tap.org/basics/)\n- Built-in [test coverage](http://node-tap.org/coverage/)\n- Many [reporter formats](http://node-tap.org/reporter/)\n- Extensive [API](http://node-tap.org/api/)\n- [Command-line interface](http://node-tap.org/cli/) for\n  running tests (whether they use node-tap or not)\n- [Machine-generated API docs](https://tapjs.github.io/tapjs)\n\nSee [the changelog](http://node-tap.org/changelog/) for recent\nupdates, or just get started with [the\nbasics](http://www.node-tap.org/basics/).\n\nAll this is too much to manage in a single README file, so head\nover to [the website](http://node-tap.org/) to learn more.\n\n## Why TAP?\n\nWhy should you use this thing!? **LET ME TELL YOU!**\n\nJust kidding.\n\nMost frameworks spend a lot of their documentation telling you\nwhy they're the greatest. This isn't that.\n\n### <i lang=\"it\" title=\"all tastes are tastes\">tutti i gusti sono gusti</i>\n\nSoftware testing is a software and user experience design\nchallenge that balances on the intersection of many conflicting\ndemands.\n\nNode-tap is based on [my](http://izs.me) opinions about how a\ntest framework should work, and what it should let you do. I do\n_not_ have any opinion about whether or not you share those\nopinions. If you do share them, you will probably enjoy this test\nlibrary.\n\nHere are the design principles that shape this test framework.\n\n### Test files are \"normal\" programs\n\nAny TAP test can be run directly as a plain old JavaScript\nprogram. Of course, if it's written in TypeScript, you'll\nhave to run it with a TypeScript loader, but otherwise, they\nshould be just like normal programs that run in a normal\nenvironment.\n\nBut there's no runner required to run tests, they don't\nexecute in a special simulated memory space with injected\nglobals, and so on. Because each test runs in its own process,\nthere's no chance of tests becoming dependent on one another's\nleaked globals or causing other confusing situations.\n\n### Tests should help, not get in the way\n\nThe goal of tests is to help you write code. They add reliability\nto your program by adding a layer of \"yes, this does what I think\nit does\". Whether you're doing strict Red-Green-Refactor style\nTDD, or just finger-painting until it feels right and then\nwriting tests to verify what it actually does, writing the tests\nshould feel empowering and straightforward, _reducing_ cognitive\nload rather than increasing it.\n\n### All types must be accurate and complete\n\nThis is simply not reasonable to do with a hand-edited type\ndefinition in `.d.ts` file.\n\nTAP's exported types are built up from its set of plugins and\ninternal classes, assembled into the `Test` class that your test\nprograms interact with. When a plugin is added or removed, the\n`t` in your editor can accurately tell you its new shape.\n\nIf you have to look at the docs too often, that's a bug in my\nopinion. Lean into the beautiful power of code completion.\n\n### TypeScript, ESM, and CommonJS supported out of the box\n\nWith the changes to the module system in Node.js over the\nlast several years, TAP fell down on this requirement in\nversions prior to v18. As of version 18, the entire system has\nbeen rewritten in TypeScript, and built as hybrid ESM/CommonJS\npackages.\n\nYour tests should be written just like your program, with as few\nbarriers as possible. If you can do it in CommonJS, you can do it\nin ESM, and vice versa (at least as far as TAP is concerned).\nWhatever is in your `tsconfig.json` or `package.json`, it should\nJust Work.\n\n### Anything that _can_ be a plugin _is_ a plugin\n\nThe plugin system is leveraged for anything that does not\nabsolutely need to be included in the core.\n\nBasic [TAP](https://testanything.org) generation and flow\ncontrol, error handling, config loading, process management and\nso on, are all included in the core. But TypeScript support,\nmocking, almost all assertion methods, method and property\ninterception and spying, spawning/forking subtests, creating\nfixtures, snapshots, and attaching lifecycle methods (among\nothers) are all relegated to plugins.\n\nThis means that features can be switched on or off or extended\nvery easily.\n\n### Plugins must be powerful and trivial to write correctly\n\nThe plugin interface is extremely simple. Export a `plugin`\nfunction that returns an object. That's it, that's a plugin.\n\nPlugins can also export configuration definitions, which are\nfolded into the set of fields that TAP knows how to parse from\nthe command line or from your `.taprc` file, or export a `loader`\nstring, which will be invoked when spawning test processes.\n\n### High Signal, Low Noise\n\nIt is important to give a lot of information about test failures,\nthrows, and so on, so that you can easily jump straight to the\nappropriate place in the code to fix the problem. And, it's\nusually helpful to see which tests are actually running.\n\nHowever, a screen full of green checkmarks and `100% Covered!`\nisn't very useful. It should be just enough to know what happened\nand easily diagnose any problems, and otherwise fairly quiet.\n\nLow information output has been trimmed down as much as possible\nfrom the default reporters. Coverage information is only shown\nwhen it has something relevant to say. TAP tries to show you\nexactly what you need to see, and nothing else. Stack traces have\nnoisy internals trimmed out, so it's easier to see exactly where\nin _your_ code the problem happened. Source maps are always\nenabled, because you need to know where the actual code is, not\njust which built artifact failed.\n\nIf the default reporter isn't terse enough for your liking, try\n`tap -Rterse`.\n\n### Assertions don't throw (but throws are handled nicely)\n\nI frequently write programs that have many hundreds of assertions\nbased on some list of test cases. If the first failure throws,\nthen I don't know if I've failed 100 tests or 1, without wrapping\neverything in a try-catch. Furthermore, I usually want to see\nsome kind of output or reporting to verify that each one actually\nran.\n\nBasically, it should be your decision whether you want to throw\nor not. The test framework shouldn't force that on you, and\nshould make either case easy.\n\n### Test reporting should be useful, extensible, and accessible\n\nThe [raw test output](https://www.node-tap.org/tap-format/)\nis machine-parseable and human-intelligible, a separate component\nconsumes test output and turns it into a [pretty summarized\nreport](https://www.node-tap.org/reporting/). This means that\ntest data can be stored and parsed later, dug into for additional\ndetails, and so on.\n\nRed and green are the conventional colors meaning \"removed\" and\n\"added\", but they're also exactly the same color for many people.\nAll of the color choices in the reporter are tested rigorously\nagainst simulators for protanopia, deuteranopia, tritanopia, and\nmonochromicity.\n\n### Test coverage is always on\n\nRunning tests with coverage changes the way that you think\nabout your programs, and provides much deeper insight.\nTAP uses V8's internal coverage mechanisms directly, and verifies\nthat tests provide 100% coverage of all lines, branches,\nfunctions, and statements in the system under test. It uses\n[C8](https://npmjs.com/c8) to analyze the V8 coverage data and\ngenerate coverage reports.\n\nMissing coverage means that you are relying on untested code, so\nthis is treated as a test failure. If you have some bit of code\nwhich is actually _impossible_ to test for some reason, wrap it\nin the appropriate `/* c8 ignore start */` / `/* c8 ignore end\n*/` comments to exclude those lines from the analysis. But think\ncarefully about whether that's really the case. Usually, if you\nhave to coverage-ignore something, it's a sign that you need to\neither delete that code or refactor it into a more easily tested\nmodule.\n\n---\n\nSoftware testing should help you build software. It should be a\nsecurity blanket and a quality ratchet, giving you the support to\nundertake massive refactoring and fix bugs without worrying. It\nshouldn't be a purification rite or a hazing ritual. It should be\nfun, because making stuff is fun, and it helps you make better\nstuff.\n\nThere are many opinions left off of this list! Reasonable people\ncan disagree. But if you find yourself nodding along, [maybe tap\nis for you](https://www.node-tap.org/basics/).\n","publish_time":1777657057872,"_cnpm_publish_time":1777657057872,"dist-tags":{"latest":"21.8.1","legacy":"12.7.0","legacy-v16":"16.3.10","totally-bundled":"14.10.2-totally-bundled.1","unbundled":"14.10.2-unbundled","v14-legacy":"14.11.0","v15-beta":"15.0.0-3"}}