Tape version 5.x+ supports promises (and thus async/await) and so this module is no longer necessary.
Please consider upgrading to Tape 5.x.
If you can’t right now, you can still install and use version 1.0.1 of this module:
npm install @small-tech/[email protected]
-
Install tape:
npm install tape
-
Remove this module:
npm remove @small-tech/tape-with-promises
-
In your test files, import the tape instead of this module:
// Replace: import test from '@small-tech/tape-with-promises' // With: import test from 'tape'
Adds promise support (rejects()
, doesNotReject()
) to tape by decorating it using tape-promise.
npm install --save-dev @small-tech/tape-with-promises
import test from '@small-tech/tape-with-promises'
test('promises', async t => {
await t.rejects(() => {
return new Promise((resolve, reject) => {
setTimeout(() => {
// This does, indeed, reject.
reject('Oh, no!')
}, 100)
})
})
await t.doesNotReject(() => {
return new Promise((resolve, reject) => {
setTimeout(() => {
// This does, indeed, resolve.
resolve('Yay!')
})
})
})
})
If you save the above test in tests/index.js, you can run it with:
npx tape tests/**/*.js
Or, in your package.json file:
{
"scripts": {
"test": "tape tests/**/*.js"
}
}
npm -s test
Small Technology Foundation is a tiny, independent not-for-profit.
We exist in part thanks to patronage by people like you. If you share our vision and want to support our work, please become a patron or donate to us today and help us continue to exist.
- tap-monkey: A tap formatter that’s also a monkey. Displays test runner status using a static single-line spinner (hint: it’s a monkey) and only fills your screen with text on failures and with your coverage report.
- tape by James Halliday et al.
- tape-promise by JP Richardson
Copyright ⓒ 2022-present, Aral Balkan, Small Technology Foundation.
Released under GNU AGPL version 3.0 or later.