{"name":"@tapjs/filter","version":"4.3.9","keywords":["tapjs plugin"],"author":{"url":"https://blog.izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"license":"BlueOak-1.0.0","_id":"@tapjs/filter@4.3.9","maintainers":[{"name":"ljharb","email":"ljharb@gmail.com"},{"name":"isaacs","email":"i@izs.me"}],"homepage":"https://github.com/tapjs/tapjs/tree/main/src/filter#readme","bugs":{"url":"https://github.com/tapjs/tapjs/issues"},"tap":{"typecheck":false},"dist":{"shasum":"df5143e8e404114081dd37e9869e113992b2000d","tarball":"http://registry-npm.ywwl.com/@tapjs/filter/download/@tapjs/filter-4.3.9.tgz","fileCount":13,"integrity":"sha512-gT42mLyZ6QbMYl0cBtlooERa6EfR6GzrdiGAxyp+F+F2lOh5+21KNxjwvafnDiYjiC/txRm+C3iKn8yTH1mwNw==","signatures":[{"sig":"MEQCIDErztjWwh7Np6yd0gSxC0jUoWd6Fon4x2KYm/NfHxZ0AiAsJFWJzTOglnHmtRvzxpmYlLN+3L18S8SYR9hL3v0AZQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":56604,"size":9093,"noattachment":false,"key":"/@tapjs/filter/-/@tapjs/filter-4.3.9.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":"0ab7f3cdf804a5d481a7ab78ffc00aee600c7092","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/filter","type":"git"},"_npmVersion":"11.12.1","description":"tap plugin providing t.only() and grep option","directories":{},"_nodeVersion":"26.0.0","_hasShrinkwrap":false,"peerDependencies":{"@tapjs/core":"4.5.7"},"_npmOperationalInternal":{"tmp":"tmp/filter_4.3.9_1778712850772_0.6156967325182292","host":"s3://npm-registry-packages-npm-production"},"readme":"# `@tapjs/filter`\n\nA default tap plugin providing `only` and `grep` functionality.\n\nOccasionally, you just want to run a small subset of the tests in\na file, without the trouble of going into the file itself and\ncommenting out all the other ones.\n\nThis plugin gives you a handy way to do that.\n\n## USAGE\n\nThis plugin is installed with tap by default. If you had\npreviously removed it, you can `tap plugin add @tapjs/filter` to\nbring it back.\n\n### `grep`\n\nImagine if you had a test like this:\n\n```ts\n// test.mts\nimport t from 'tap'\nimport { MyThing } from '../src/my-thing.ts'\n\nt.test('foo the bars', async t => {\n  const mt = new MyThing()\n  // this takes a while...\n  await mt.foo(mt.bars)\n  for (const b of mt.bars) {\n    t.equal(b.foo, true)\n  }\n})\n\nt.test('bar all the foos', async t => {\n  const mt = new MyThing()\n  // this takes a while...\n  await mt.bar(mt.foos)\n  for (const f of mt.foos) {\n    t.equal(f.bar, true)\n  }\n})\n```\n\nThings are great, and my module seems to work, but then someone\nfinds a case where the `mt.bar` function throws an error. While\nworking on fixing this issue, I can run _just_ the second test by\ndoing this:\n\n```\n$ tap --grep 'bar all the foos' test.mts\n```\n\nThe `--grep` argument can be specified multiple times on the\ncommand line (or as an array in a config file), to grep through a\nseries of child tests.\n\n```ts\n// test.mts\nimport t from 'tap'\nt.test('parent test', t => {\n  t.test('child one', () => {\n    t.test('subtest a', t => t.end())\n    t.test('the b test', t => t.end())\n    t.end()\n  })\n  t.test('child two', () => {\n    t.test('subtest a', t => t.end())\n    t.test('the b test', t => t.end())\n    t.end()\n  })\n  t.end()\n})\n```\n\nIf you run `tap -g parent -g one -g a` then it will run only\n`subtest a` under `child one`.\n\n### Grep Flags\n\nYou can specify grep flags by writing the argument as a\nJavaScript RegExp literal.\n\n```ts\n// test.mts\n// run with `-g /foo/i` to run both foo and FOO tests, but not bar\nimport t from 'tap'\nt.test('foo', t => t.end())\nt.test('FOO', t => t.end())\nt.test('bar', t => t.end())\n```\n\n### Grep Invert\n\nSpecify the `--grep-invert` (or `-i`) flag to invert the matches.\nThat is, then the things matching the pattern will _not_ be run,\nand other tests will be.\n\n## `only`\n\nAnother way, if you don't mind editing the file a little bit, is to\nput `{ only: true }` in the subtest options, like this:\n\n```ts\nt.test('bar all the foos', { only: true }, async t => {\n  const mt = new MyThing()\n  // this takes a while...\n  await mt.bar(mt.foos)\n  for (const f of mt.foos) {\n    t.equal(f.bar, true)\n  }\n})\n```\n\nOr, you can use the `t.only()` function instead of `t.test`:\n\n```ts\nt.only('bar all the foos', async t => {\n  const mt = new MyThing()\n  // this takes a while...\n  await mt.bar(mt.foos)\n  for (const f of mt.foos) {\n    t.equal(f.bar, true)\n  }\n})\n```\n\nThen, run `tap --only test.mts`, and it will only run tests\nmarked with `only`.\n\nIn order to make this work, a `runOnly` flag is added in the test\noptions and on the test object itself, which you can set\nexplicitly as well. This is handy if you want the `only`\nfiltering happening in just one test file, or just one subtest in\na file:\n\n```ts\nimport t from 'tap'\nt.runOnly = true\nt.only('this will run', t => t.end())\nt.test('this will be skipped', t => t.end())\n```\n\nOr, in a subtest:\n\n```ts\nimport t from 'tap'\nt.test('parent test', { runOnly: true }, async t => {\n  t.only('this will run', t => t.end())\n  t.test('this will be skipped', t => t.end())\n})\nt.test('this will run', t => t.end())\n```\n\nYou can also explicitly _disable_ `only` behavior, even if it's\nset on the command line, by setting `runOnly` explicitly to\nfalse.\n\n```ts\nimport t from 'tap'\n// override the --only flag\nt.runOnly = false\nt.only('this will run', t => t.end())\nt.test('so will this, even with --only', t => t.end())\n```\n\n## `--filter-quietly`\n\nBy default, when a test is skipped with `--grep` or `--only`, a\nskip message is applied, indicating why it was omitted.\n\nThis is often desireable, but can be noisy. The\n`--filter-quietly` config flag will disable this reporting,\nmaking filtered tests look like empty passing assertions.\n\nSince a skip message will cause failures when `--fail-skip` is\nset, in that case `--filter-quietly` will be enabled by default.\nPresumably, if you tell tap \"fail on skipped tests\", you don't\nalso mean for it to fail on tests that you have told it to skip\nin that very same command with `--grep` or `--only`.\n\nIf you _do_ mean to have it fail on intentionally skipped tests,\nthen you can set `--no-filter-quietly` (or `filter-quietly:\nfalse` in a `.taprc` file) along with `--fail-skip`.\n","publish_time":1778712850916,"_cnpm_publish_time":1778712850916,"dist-tags":{"latest":"4.3.13","pre":"1.0.0"}}