@tapjs/before
Advanced tools
Comparing version 0.0.0-15 to 0.0.0-16
{ | ||
"name": "@tapjs/before", | ||
"version": "0.0.0-15", | ||
"version": "0.0.0-16", | ||
"description": "a built-in tap extension for t.before()", | ||
@@ -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/before` | ||
A default tap plugin providing `t.before()` | ||
A default tap plugin providing `t.before()`. | ||
## USAGE | ||
This plugin is installed with tap by default. If you had | ||
previously removed it, you can `tap plugin add @tapjs/before` to | ||
bring it back. | ||
```ts | ||
import t from 'tap' | ||
t.before(() => { | ||
// this will run before the tests in this file start | ||
}) | ||
``` | ||
If the method returns a promise, it will be awaited before moving | ||
on to the next test. | ||
A `t.before()` method will run prior to any _subsequent_ child | ||
tests. If it's called before any child tests have started, then | ||
it will be run right away. | ||
So, this test: | ||
```js | ||
import t from 'tap' | ||
t.before(() => { | ||
console.error('before initial') | ||
}) | ||
t.test('first test', t => { | ||
t.before(async () => { | ||
// this will wait before moving on | ||
await new Promise(res => setTimeout(res, 100)) | ||
console.error('before in first test') | ||
}) | ||
console.error('in first test') | ||
t.test('child test', (t) => { | ||
console.error('child of first test') | ||
t.end() | ||
}) | ||
t.end() | ||
}) | ||
t.before(() => { | ||
console.error('before between') | ||
}) | ||
t.test('second test', t => { | ||
console.error('in second test') | ||
t.end() | ||
}) | ||
``` | ||
will print: | ||
``` | ||
before initial | ||
in first test | ||
before in first test | ||
child of first test | ||
before between | ||
in second test | ||
``` | ||
Essentially, `t.before()` is a bit like a child test method that | ||
doesn't get a `Test` object as an argument. |
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
16515
71