{"_id":"@tapjs/after@3.3.13","tap":{"typecheck":false},"bugs":{"url":"https://github.com/tapjs/tapjs/issues"},"dist":{"shasum":"028c7b975de3b8fda3c6665b5871ba347feb1877","tarball":"http://registry-npm.ywwl.com/@tapjs/after/download/@tapjs/after-3.3.13.tgz","fileCount":13,"integrity":"sha512-hpuekuhtdcyHOu+O8fLlU7P+N6IhifnAXtZJn44x8L/M1C5AP3fUJx2ycSKqAkj+coTCWaU9GuWJSj+eGlVskQ==","signatures":[{"sig":"MEQCIBctx0+rMulzJO7CxLXGP/+eJ0uP3ROGJhOlY6ikPuMcAiBaRuLgyfdU6t0Vdd6Xwa7tz8/4YBsEityrE9E0z55U2Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDvbJtswOqdfqvc9AkoRGyZRCugewLhgEW4m+IdiHsFoQIgRZ/p7DVCuMTotyLePzuSAG91GN52HhYAN4Rg0SUm7hI="}],"unpackedSize":18975,"size":4437,"noattachment":false,"key":"/@tapjs/after/-/@tapjs/after-3.3.13.tgz"},"main":"./dist/commonjs/index.js","name":"@tapjs/after","tshy":{"main":true,"exports":{".":"./src/index.ts","./package.json":"./package.json"},"selfLink":false},"type":"module","types":"./dist/commonjs/index.d.ts","author":{"name":"Isaac Z. Schlueter"},"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"},"gitHead":"6874ffcc3e671f64b5dbabdd25b26904d3e2ed84","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 --tsconfig tsconfig/esm.json ./src/*.ts"},"version":"3.3.13","_npmUser":{"name":"isaacs","email":"i@izs.me"},"homepage":"https://github.com/tapjs/tapjs/tree/main/src/after#readme","keywords":["tapjs plugin"],"repository":{"url":"git+ssh://git@github.com/tapjs/tapjs.git","path":"src/after","type":"git"},"_npmVersion":"12.2.0","description":"a built-in tap extension for t.after() and t.teardown()","directories":{},"maintainers":[{"name":"ljharb","email":"ljharb@gmail.com"},{"name":"isaacs","email":"i@izs.me"}],"_nodeVersion":"26.5.0","dependencies":{"is-actual-promise":"^1.0.1"},"_hasShrinkwrap":false,"peerDependencies":{"@tapjs/core":"4.6.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/after_3.3.13_1793744226862_0.04126631488477239"},"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":1793744226944,"_cnpm_publish_time":1793744226944,"dist-tags":{"latest":"3.3.13","pre":"1.0.0"}}