{"name":"@tapjs/after","version":"3.3.12","description":"a built-in tap extension for t.after() and t.teardown()","tshy":{"main":true,"exports":{"./package.json":"./package.json",".":"./src/index.ts"},"selfLink":false},"type":"module","main":"./dist/commonjs/index.js","module":"./dist/esm/index.js","types":"./dist/commonjs/index.d.ts","exports":{"./package.json":"./package.json",".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}}},"scripts":{"prepare":"tshy","pretest":"npm run prepare","presnap":"npm run prepare","test":"tap","snap":"tap","format":"prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache","typedoc":"typedoc --tsconfig tsconfig/esm.json ./src/*.ts"},"author":{"name":"Isaac Z. Schlueter"},"license":"BlueOak-1.0.0","dependencies":{"is-actual-promise":"^1.0.1"},"peerDependencies":{"@tapjs/core":"4.6.0"},"tap":{"typecheck":false},"repository":{"type":"git","url":"git+ssh://git@github.com/tapjs/tapjs.git","path":"src/after"},"homepage":"https://github.com/tapjs/tapjs/tree/main/src/after#readme","bugs":{"url":"https://github.com/tapjs/tapjs/issues"},"keywords":["tapjs plugin"],"engines":{"node":"20 || >=22"},"gitHead":"8ab84eb1daae6dedbfcf07b8e0bf2c2a965ad81f","_id":"@tapjs/after@3.3.12","_nodeVersion":"26.5.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-09zxTnM88tv14EjLpJgx0nVRHvCyfIqJ5WrXmGWkODLT6KJ6zmF/cO2ElldNdcLqY4GY69D7BjMtf/Te777YHw==","shasum":"a9354dda6145d860b3e2029a5b703d6120edf1d5","tarball":"http://registry-npm.ywwl.com/@tapjs/after/download/@tapjs/after-3.3.12.tgz","fileCount":13,"unpackedSize":18975,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCe7p5wbfx+blokdPOtJHLnAcO0fKg9wwNrc5TMz4w6wQIgFEJP/Se/y6/ffrotKBQnayDHSIAVnQN8zNSwt5QMggA="}],"size":4438,"noattachment":false,"key":"/@tapjs/after/-/@tapjs/after-3.3.12.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"ljharb","email":"ljharb@gmail.com"},{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/after_3.3.12_1788477712120_0.677806890198849"},"_hasShrinkwrap":false,"readme":"# `@tapjs/after`\n\nA default tap plugin providing `t.after()` and `t.teardown()`.\n\n## USAGE\n\nThis plugin is installed with tap by default. If you had\npreviously removed it, you can `tap plugin add @tapjs/after` to\nbring it back.\n\n```ts\nimport t from 'tap'\nt.after(() => {\n  // this will run after all the tests in this file are done\n})\n```\n\nThe method can be called as either `t.teardown()` or `t.after()`.\nIn an earlier version of tap, these had slightly different\nbehaviors, but they are now the same.\n\nIf the method returns a promise, it will be awaited before moving\non to the next test.\n\nSo, this test:\n\n```js\nimport t from 'tap'\n\nt.test('first test', t => {\n  t.teardown(async () => {\n    // this will wait before moving on\n    await new Promise(res => setTimeout(res, 100))\n    console.error('end of first test teardown')\n  })\n  console.error('in first test')\n  t.end()\n})\nt.test('second test', t => {\n  console.error('in second test')\n  t.end()\n})\n```\n\nwill print:\n\n```\nin first test\nend of first test teardown\nin second test\n```\n\n## Order\n\nIf multiple teardown methods are assigned to a single test, they\nwill be run in _reverse_ order of how they are assigned. This is\na change from earlier versions of tap, and provides symmetry with\n`t.before()`.\n\nIn practice, it can make things more straightforward, by keeping\ncleanup methods close to their associated setup logic. For\nexample:\n\n```js\nconst connection = await connectToDB()\nt.ok(connection, 'connected to database')\nt.teardown(() => disconnectFromDB(connection))\n\nconst user1 = await createUser(connection)\nt.ok(user1, 'created user 1')\nt.teardown(() => deleteUser(connection, user1))\n\nconst user2 = await createUser(connection)\nt.ok(user2, 'created user 2')\nt.teardown(() => deleteUser(connection, user2))\n```\n\nIf we delete the connection created in the first step _before_\ndeleting the user records, then we can't use that connection to\ndelete the user records.\n\nThis can also be accomplished with subtests, and a single\nteardown in each section:\n\n```js\nt.test('user db tests', async t => {\n  const connection = await connectToDB()\n  t.ok(connection, 'connected to database')\n  t.teardown(() => disconnectFromDB(connection))\n\n  t.test('user 1', async t => {\n    const user1 = await createUser(connection)\n    t.ok(user1, 'created user 1')\n    t.teardown(() => deleteUser(connection, user1))\n  })\n\n  t.test('user 2', async t => {\n    const user2 = await createUser(connection)\n    t.ok(user2, 'created user 2')\n    t.teardown(() => deleteUser(connection, user2))\n  })\n})\n```\n","publish_time":1788477712256,"_cnpm_publish_time":1788477712256,"dist-tags":{"latest":"3.3.13","pre":"1.0.0"}}