{"_id":"@tapjs/reporter@4.5.0","tap":{"typecheck":false,"coverage-map":"map.js"},"bugs":{"url":"https://github.com/tapjs/tapjs/issues"},"dist":{"shasum":"4254045e01abd4af127b212c69ac65c5f7fc6070","tarball":"http://registry-npm.ywwl.com/@tapjs/reporter/download/@tapjs/reporter-4.5.0.tgz","fileCount":164,"integrity":"sha512-aowTYTTHOC/J9lLwpHbTvSBnHC5alAY/G+VVS11e4toRWs/aa99c9fVqu5ldQDiruGpE9fs2Ihs8mxyq+gImNQ==","signatures":[{"sig":"MEUCIQCJQNDQVTs4sxAEV1UTZCGeZh2MZyfbcBo9BtaWLhZxvgIgf41ti3vVzyB3ygiSNWk6Zdw1Pe0jQ16R7orqUbyJ5gI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICYLzcaz9GUs37tMiMiZnzVbLtpkSAKeW+cJf+8L42W6AiAN8efkKkf3CVZlEim2JG90WIC50/SGADPRc9Upz5Di6Q=="}],"unpackedSize":248111,"size":58614,"noattachment":false,"key":"/@tapjs/reporter/-/@tapjs/reporter-4.5.0.tgz"},"name":"@tapjs/reporter","tshy":{"exports":{".":"./src/index.tsx","./hooks":"./src/hooks.ts","./utils":"./src/utils.ts","./components":"./src/components.ts","./package.json":"./package.json"},"dialects":["esm"],"selfLink":false},"type":"module","author":{"url":"https://blog.izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"module":"./dist/esm/index.js","engines":{"node":"20 || >=22"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"}},"./hooks":{"import":{"types":"./dist/esm/hooks.d.ts","default":"./dist/esm/hooks.js"}},"./utils":{"import":{"types":"./dist/esm/utils.d.ts","default":"./dist/esm/utils.js"}},"./components":{"import":{"types":"./dist/esm/components.d.ts","default":"./dist/esm/components.js"}},"./package.json":"./package.json"},"funding":{"url":"https://github.com/sponsors/isaacs"},"gitHead":"8ab84eb1daae6dedbfcf07b8e0bf2c2a965ad81f","license":"BlueOak-1.0.0","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 ./src/*.ts"},"version":"4.5.0","_npmUser":{"name":"isaacs","email":"i@izs.me"},"homepage":"https://github.com/tapjs/tapjs/tree/main/src/reporter#readme","keywords":["tapjs","ink","reporter"],"repository":{"url":"git+ssh://git@github.com/tapjs/tapjs.git","path":"src/reporter","type":"git"},"_npmVersion":"11.17.0","description":"Pretty test output reporters for tap","directories":{},"maintainers":[{"name":"ljharb","email":"ljharb@gmail.com"},{"name":"isaacs","email":"i@izs.me"}],"_nodeVersion":"26.5.0","dependencies":{"ms":"^2.1.3","ink":"^5.2.1","chalk":"^5.6.2","react":"^18.2.0","minipass":"^7.0.4","tap-yaml":"4.4.2","tcompare":"9.3.2","tap-parser":"18.3.4","@tapjs/stack":"4.3.3","@tapjs/config":"5.6.6","patch-console":"^2.0.0","string-length":"^6.0.0","prismjs-terminal":"^1.2.3"},"_hasShrinkwrap":false,"peerDependencies":{"@tapjs/core":"4.6.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/reporter_4.5.0_1788477712788_0.22902840526621904"},"readme":"# `@tapjs/reporter`\n\nA set of [ink](https://github.com/vadimdemedes/ink) based\nreporters for tap, and utilities you can use to write your own.\n\nThe modern reincarnation of [treport](http://npm.im/treport).\n\n## Reporters in Node-Tap\n\nThe following reporters are built into this module, and always\navailable in node-tap.\n\n### base\n\n`--reporter=base` is the default. It provides a reasonable amount\nof information about what's going on, without too much noise. If\nyou run tap with `--passes`, then it'll show all the passing\nassertions, though that's often excessive, so it's off by\ndefault.\n\n### terse\n\nAs the name suggests, the `terse` report shows much less\ninformation than `base`. But otherwise, they are very similar. If\ntests pass, it shows a very brief summary. When tests fail, it\nshows the same diffs, traces, and so on.\n\n### min\n\nMore terse than `terse`. Shows information about failures and\n`todo` items, but no summaries, counts, etc. For successful test\nruns, this is equivalent to `silent`.\n\n### silent\n\nThe `silent` report prints nothing at all to the terminal, but\nstill exits with an error status code if the tests did not pass.\n\n### tap\n\nThe `--reporter=tap` option will output raw the `TAP` content,\nsimilar to just running the test programs directly.\n\n### junit\n\nXML output format used by JUnit. The [testmoapp/junitxml\nrepo](https://github.com/testmoapp/junitxml) has a good\ndescription of the format.\n\n### json\n\nA single JSON object, somewhat similar in shape to the XML produced by the\n`junit` reporter.\n\n`Suite` objects contain metadata about a test, and a list of\n`suites` and `cases` (ie, test point assertions). Suites can\ncontain other suites.\n\n### jsonstream\n\nThe same data as the `json` format, but streamed as\nnewline-delimited JSON.\n\nEach line is an array with two members. The first is a string,\none of `'start'`, `'end'`, `'pass'`, `'fail'`, `'skip'` or\n`'todo'`. The second is a data object, as follows:\n\n- `start` Initial metadata about a suite, before it has loaded\n  any sub-suites or test cases.\n- `end` Final data about a suite, with counts and summary data.\n- `pass`, `fail`, `skip`, `todo` A test point of the specified\n  type.\n\n### markdown\n\nSimilar data as shown by the `jsonstream` report, but formatted in\nMarkdown.\n\n## Other Reporters\n\nThe `reporter` config option can also be set to:\n\n- **Any executable program** - The TAP stream will be written\n  to the program's standard input.\n- **A module that exports a Stream class** - The class will be\n  instantiated, and the TAP stream piped into it.\n- **A module that exports a React component** - The component\n  will be rendered using\n  [Ink](https://github.com/vadimdemedes/ink), with the TAP object\n  provided as the `test` prop, and the `LoadedConfig` as the\n  `config` prop.\n\n## Writing Custom Reporters\n\nFor streams and command-line reporters written in JavaScript, the\n[tap-parser](https://tapjs.github.io/tapjs/modules/tap_parser.html)\nmodule is the best way to parse the incoming TAP stream. For\nother languages, there are [many other TAP consumer libraries\navailable](http://testanything.org/consumers.html).\n\nFor React component reporters, the components, hooks, and\nutilities in this package are likely very useful.\n\nThe easiest way to write a custom React reporter is as an\nESM-only module that default exports its `Reporter` function on\nthe main package module. Then, users can do `--reporter\n<package-name>` in their configs to use it.\n\nAnother way, if a reporter comes along with some other plugin\nfunctionality, is to add it to the default set via the API\npresented here. However, some care must be taken in that case,\nbecause `@tapjs/reporter` is ESM-only, and plugins must be\ncompatible with both CommonJS and ESM. The [`@tapjs/dummy-plugin`\npackage](https://github.com/tapjs/tapjs/tree/main/src/dummy-plugin)\ncontains an example of this.\n\n## `@tapjs/reporter` API\n\nThe API available at `import '@tapjs/reporter'`.\n\n### interface `TapReportOpts`\n\nThe options provided to reports.\n\n```ts\ninterface TapReportOpts {\n  test: TestBase\n  config: LoadedConfig\n}\n```\n\n### type `Reporter`\n\nAlias for `React.FC<TapReportOpts>`\n\n### `types: Record<string, Reporter>`\n\nA record of all the known reporters, indexed by their config name.\n\n### `addType(name: string, reporter: Reporter)`\n\nAdd a reporter at the name provided, so that it can be used on\nthe `--reporter` config.\n\n### `report(Type: string | Reporter, tap: TAP, config: LoadedConfig)`\n\nRender the specified reporter with the `tap` object and loaded\nconfig.\n\n### Base\n\nThe `--reporter=base` implementation\n\n### Terse\n\nThe `--reporter=terse` implementation\n\n### hooks\n\nAlias for the `@tapjs/reporter/hooks` module\n\n### components\n\nAlias for the `@tapjs/reporter/components` module\n\n### utils\n\nAlias for the `@tapjs/reporter/utils` module\n\n## `@tapjs/reporter/components` API\n\nThis provides a collection of useful components for building tap\nreports.\n\nThe relevant tags are listed here, but this module also exports\nseveral types and interfaces that they use for their property\ndefinitions.\n\n### BailedOut\n\n```jsx\n<BailedOut test={tap} />\n```\n\nPrint a bold red \"Bailout!\" message if the test bails out.\n\n### Diff\n\n```jsx\n<Diff diff={diffString} />\n```\n\nCreate a colorized diff from a patch string.\n\n### HangingIndent\n\n```jsx\n<HangingIndent indent={4}>\n  Some very long string, which might wrap to multiple lines. Every line\n  after the first is indented.\n</HangingIndent>\n```\n\nIndent every line after the first, useful when printing long\nstack frame lines.\n\nAny ink `Text` properties are allowed.\n\n### Log\n\n```jsx\n<Log includeTests test={tap} config={loadedConfig} />\n```\n\nCreates an ink `<Static />` component containing console output,\nstandard output, and (if `includeTests` is set) tests as they\ncomplete.\n\n#### TestLogLine\n\nThe component used by `<Log />` to show lines for each test as it\ncompletes.\n\n#### ConsoleLogLine\n\nThe component used by `<Log />` to show `console` output in the\nrunner process.\n\n#### StdioLogLine\n\nThe component used by `<Log />` to show `stdio` output from child\ntest processes.\n\n### ResultDetailList\n\n```jsx\n<ResultDetailList\n  test={tap}\n  filter={t =>\n    !!t.counts.fail || !!t.counts.skip || !!t.counts.todo || !t.parser.ok\n  }\n  Banner={\n    <Box>\n      <Text>tests complete</Text>\n    </Box>\n  }\n/>\n```\n\nWhen the test suite is completed, this prints the `Banner` if\nprovided, and then the detailed results of all tests that pass the filter.\n\nBy default, passing tests are excluded from this report.\n\n### ResultDetails\n\n```jsx\n<ResultDetails result={result} />\n```\n\nPrint detailed information about a test point's diagnostics.\n\n### Runs\n\n```jsx\n<Runs test={tap} />\n```\n\nPrint a line for each test in progress, removing the line when it\ncompletes.\n\n### Source\n\n```jsx\n<Source source={result.diag.source} at={result.diag.at} />\n```\n\nPass in a test result.diag that has a source and callsite, and\nit'll return a prettied up source line with the callsite\nhighlighted.\n\n### Stack\n\n```jsx\n<Stack stack={stackString} />\n```\n\nPrint a stack string nicely.\n\nLong lines are given a hanging indent, and local filenames are\nhighlighted.\n\n### SuiteSummary\n\n```jsx\n<SuiteSummary test={tap} />\n```\n\nThe `10 pass  3 fail  2 skip  of 18 complete` lines at the bottom\nof the test run.\n\nAlso prints `Bailout!` and `Timeout` messages.\n\n### TestBadge\n\n```jsx\n<TestBadge test={subtest} />\n```\n\nThe `PASS`, `FAIL`, etc. badges for a subtest.\n\n### TestResultsList\n\n```jsx\n<TestResultsList test={subtest} details />\n```\n\nShow the list of results for a completed test. (Shows nothing if\nthe test is not yet complete.)\n\n`details` is set in the display in the final test summary,\n`false` when used in the log.\n\n### TestSummary\n\n```jsx\n<TestSummary test={subtest} details omitPassing />\n```\n\nShow the summary for a completed test with its test badge, result\ndetails, and so on.\n\nThe `details` flag will cause it to print the full diagnostic\noutput for failing test points. It is set false when printing in\nthe log, true when printing in the final test results report.\n\n### TimedOut\n\n```jsx\n<TimedOut test={tap} />\n```\n\nPrint a bold red `Timeout` message when the suite times out.\n\n## `@tapjs/reporter/hooks` API\n\nHook functions that can be used in components providing helpful\ntest information that updates at the appropriate times.\n\n### `useAssertTotals(test: TestBase)`\n\nAn up to date\n[`test.assertTotals`](https://tapjs.github.io/tapjs/classes/_tapjs_core.test_base.TestBase.html#assertTotals)\n\n### `useBailedOut(test: Base)`\n\n`true` or the bailout reason if/when the test bails out. `false`\notherwise.\n\n### `useCleanup(effect: CleanupEffect, deps: any[])`\n\nThe `CleanupEffect` type is a function that may take an array of\ncleanup methods as its first argument, and a `doCleanup` function\nas its second, and can optionally return a cleanup function as\nwell.\n\nBy pushing onto the array, or returning a cleanup function of\nits own, the effect will be properly disposed as needed.\n\nUseful in cases where you need to listen to multiple events, and\nclean them all up at the appropriate time.\n\nExample:\n\n```js\nimport { useCleanup } from '@tapjs/reporter/hooks'\nimport { listenCleanup } from '@tapjs/reporter/utils'\nconst useMyHook = emitter => {\n  const [firsts, updateFirsts] = useState([])\n  const [seconds, updateSeconds] = useState([])\n  useCleanup((list, doCleanup) => {\n    // these event handlers will be cleaned up properly now\n    list.push(\n      listenCleanup(emitter, 'first', f =>\n        updateFirsts(firsts.concat([f])),\n      ),\n    )\n    list.push(\n      listenCleanup(emitter, 'second', f =>\n        updateSeconds(seconds.concat([f])),\n      ),\n    )\n  }, emitter)\n\n  return [firsts, seconds]\n}\n```\n\n### `useComments(test: Base) => string[]`\n\nReturns a list of the comments made by the test.\n\n### `useCountsLists(test: Base) => [Counts, Lists]`\n\nUp to date `t.counts` and `t.lists` properties.\n\n### `useIsDone(test: Base)`\n\nTrue if the test is done, false otherwise.\n\n### `useLog(test: TestBase, config: LoadedConfig, includeTests: boolean)`\n\nReturns an array of `LogEntry` items describing each entry in the\nlog.\n\n### `useSubtests(test: TestBase, which: 'active'|'finished'|'all') => Base[]`\n\nReturn an array of all subtests meeting the `which` criteria.\n\n- `active` Tests that have started, but not completed.\n- `finished` Tests that have completed.\n- `all` All of the above.\n\n### `useSuiteTotals(test: Base) => Counts`\n\nReturn a\n[`Counts`](https://tapjs.github.io/tapjs/classes/_tapjs_core.counts.Counts.html)\nobject describing the suites in the test run.\n\n### `useTestTime(test: Base, interval: MILLISECONDS = 247) => number`\n\nThe time this test has taken to complete, updated every\n`interval` milliseconds. `247` chosen as a default because it's\nfast and un-round enough to feel organic, without taxing the\nsystem with excessive time checks.\n\n### `useTimedOut(t: Base): undefined | Extra`\n\nIf the test has not timed out, returns `undefined`.\n\nOtherwise, returns the\n[`Extra`](https://tapjs.github.io/tapjs/interfaces/_tapjs_core.index.Extra.html)\nobject describing the timeout failure. (Typically, `extra.signal`\nis the thing to care about.)\n\n## `@tapjs/reporter/utils` API\n\nSome helpful utilities that are useful to have when creating\nreports.\n\n### `assertName(r: Result, t: Base)`\n\nReturns the appropriate full result name, including the test\nname, without repeating it.\n\n### `listenCleanup(e: EventEmitter, ev: string, fn: Function) => cleanupMethod`\n\nAdd the function as an event listener, returning a function that\nwill remove the listener, for use with `useEffect` and\n`useLayoutEffect` hooks.\n\n### `ms(n: number)`\n\nA slightly more granular form of the `ms` module from npm.\n\nVery small float values are printed in µs, and only 3 digits of\nprecision are ever shown.\n","publish_time":1788477712873,"_cnpm_publish_time":1788477712873,"dist-tags":{"latest":"4.5.1","pre":"1.0.0"}}