@tapjs/after-each
Advanced tools
+3
-3
| { | ||
| "name": "@tapjs/after-each", | ||
| "version": "0.0.0-15", | ||
| "version": "0.0.0-16", | ||
| "description": "a built-in tap extension for t.afterEach()", | ||
@@ -46,3 +46,3 @@ "type": "module", | ||
| "peerDependencies": { | ||
| "@tapjs/core": "0.0.0-15" | ||
| "@tapjs/core": "0.0.0-16" | ||
| }, | ||
@@ -53,3 +53,3 @@ "dependencies": { | ||
| "engines": { | ||
| "node": "^14.17.0 || ^16.13.0 || >=18.0.0" | ||
| "node": ">=16" | ||
| }, | ||
@@ -56,0 +56,0 @@ "repository": { |
+48
-1
| # `@tapjs/after-each` | ||
| A default tap plugin providing `t.afterEach()` | ||
| A default tap plugin providing `t.afterEach()`. | ||
| ## USAGE | ||
| This plugin is installed with tap by default. If you had | ||
| previously removed it, you can `tap plugin add @tapjs/after-each` to | ||
| bring it back. | ||
| ```ts | ||
| import t from 'tap' | ||
| t.afterEach((t) => { | ||
| // this will run after each child test, all of their child | ||
| // tests, and so on | ||
| // the parameter is the child test that just ended. | ||
| }) | ||
| ``` | ||
| If the method returns a promise, it will be awaited before moving | ||
| on to the next test. | ||
| The `afterEach` method is called for _all_ child tests, not just | ||
| direct children. "Closer" ancestor `afterEach` methods are called | ||
| before further ancestors. | ||
| For example, this test: | ||
| ```js | ||
| import t from 'tap' | ||
| t.afterEach(t => { | ||
| console.error('root after each', t.name) | ||
| }) | ||
| t.test('parent test', t => { | ||
| t.afterEach(t => { | ||
| console.error('parent after each', t.name) | ||
| }) | ||
| t.test('child test', t => t.end()) | ||
| t.end() | ||
| }) | ||
| ``` | ||
| will print: | ||
| ``` | ||
| parent after each child test | ||
| root after each child test | ||
| root after each parent test | ||
| ``` |
17839
5.58%51
1175%