@tapjs/after
Advanced tools
Comparing version 0.0.0-15 to 0.0.0-16
{ | ||
"name": "@tapjs/after", | ||
"version": "0.0.0-15", | ||
"version": "0.0.0-16", | ||
"description": "a built-in tap extension for t.after() and t.teardown()", | ||
@@ -46,6 +46,6 @@ "type": "module", | ||
"peerDependencies": { | ||
"@tapjs/core": "0.0.0-15" | ||
"@tapjs/core": "0.0.0-16" | ||
}, | ||
"engines": { | ||
"node": "^14.17.0 || ^16.13.0 || >=18.0.0" | ||
"node": ">=16" | ||
}, | ||
@@ -52,0 +52,0 @@ "repository": { |
# `@tapjs/after` | ||
A default tap plugin providing `t.after()` and `t.teardown()` | ||
A default tap plugin providing `t.after()` and `t.teardown()`. | ||
## USAGE | ||
This plugin is installed with tap by default. If you had | ||
previously removed it, you can `tap plugin add @tapjs/after` to | ||
bring it back. | ||
```ts | ||
import t from 'tap' | ||
t.after(() => { | ||
// this will run after all the tests in this file are done | ||
}) | ||
``` | ||
The method can be called as either `t.teardown()` or `t.after()`. | ||
In an earlier version of tap, these had slightly different | ||
behaviors, but they are now the same. | ||
If the method returns a promise, it will be awaited before moving | ||
on to the next test. | ||
So, this test: | ||
```js | ||
import t from 'tap' | ||
t.test('first test', t => { | ||
t.teardown(async () => { | ||
// this will wait before moving on | ||
await new Promise(res => setTimeout(res, 100)) | ||
console.error('end of first test teardown') | ||
}) | ||
console.error('in first test') | ||
t.end() | ||
}) | ||
t.test('second test', t => { | ||
console.error('in second test') | ||
t.end() | ||
}) | ||
``` | ||
will print: | ||
``` | ||
in first test | ||
end of first test teardown | ||
in second test | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17155
52