1.0.1 • Published 2 years ago

@small-tech/tape-with-promises v1.0.1

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
github
Last release
2 years ago

Tape With Promises

Adds promise support (rejects(), doesNotReject()) to tape by decorating it using tape-promise.

Install

npm install --save-dev @small-tech/tape-with-promises

Use

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"
  }
}

Test

npm -s test

Like this? Fund us!

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.

Related projects

  • 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.

Credits

Copyright

Copyright ⓒ 2022-present, Aral Balkan, Small Technology Foundation.

License

Released under GNU AGPL version 3.0 or later.